freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [1/2] incubator-freemarker git commit: Removing _TemplateAPI and fetting rid of most _CoreAPI methods, as now things that technically belong together tend to be in the same package usually. Some other minor cleanup.
Date Sun, 26 Feb 2017 00:17:18 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 dcb0e0634 -> 946a42372


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapperConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapperConfiguration.java
b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapperConfiguration.java
index b2b5e91..94997cb 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapperConfiguration.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapperConfiguration.java
@@ -20,7 +20,7 @@
 package org.apache.freemarker.core.model.impl.beans;
 
 import org.apache.freemarker.core.Version;
-import org.apache.freemarker.core._TemplateAPI;
+import org.apache.freemarker.core._CoreAPI;
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateDateModel;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapperBuilder;
@@ -74,7 +74,7 @@ public abstract class BeansWrapperConfiguration implements Cloneable {
      * @since 2.3.22
      */
     protected BeansWrapperConfiguration(Version incompatibleImprovements, boolean isIncompImprsAlreadyNormalized)
{
-        _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements);
+        _CoreAPI.checkVersionNotNullAndSupported(incompatibleImprovements);
         
         incompatibleImprovements = isIncompImprsAlreadyNormalized
                 ? incompatibleImprovements

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/main/java/org/apache/freemarker/servlet/InitParamParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/servlet/InitParamParser.java b/src/main/java/org/apache/freemarker/servlet/InitParamParser.java
index a572214..9d1b619 100644
--- a/src/main/java/org/apache/freemarker/servlet/InitParamParser.java
+++ b/src/main/java/org/apache/freemarker/servlet/InitParamParser.java
@@ -40,6 +40,8 @@ import org.slf4j.Logger;
 
 final class InitParamParser {
 
+    // [FM3] Can't we just use the same syntax for TemplateLoader-s as Configuration does?
Then we wouldn't depend on
+    // _ObjectBuilderSettingEvaluator either, and it could become package visible.
     static final String TEMPLATE_PATH_PREFIX_CLASS = "class://";
     static final String TEMPLATE_PATH_PREFIX_CLASSPATH = "classpath:";
     static final String TEMPLATE_PATH_PREFIX_FILE = "file://";

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index db28a0e..72c0666 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -173,8 +173,8 @@ public class FMParser {
         // If this is a Template under construction, we do the below.
         // If this is just the enclosing Template for ?eval or such, we must not modify it.
         if (newTemplate) {
-            _TemplateAPI.setAutoEscaping(template, autoEscaping);
-            _TemplateAPI.setOutputFormat(template, outputFormat);
+            template.setAutoEscaping(autoEscaping);
+            template.setOutputFormat(outputFormat);
         }
     }
     
@@ -946,7 +946,7 @@ TOKEN:
             // doesn't match any directive starter tokens, because that token requires whitespace
after the
             // name as it should be followed by parameters. For now we work this around so
we don't report
             // unknown directive:
-            if (_CoreAPI.ALL_BUILT_IN_DIRECTIVE_NAMES.contains(dn)) {
+            if (ASTDirective.ALL_BUILT_IN_DIRECTIVE_NAMES.contains(dn)) {
                 throw new TokenMgrError(
                         "#" + dn + " is an existing directive, but the tag is malformed.
" 
                         + " (See FreeMarker Manual / Directive Reference.)",
@@ -4061,7 +4061,7 @@ void HeaderElement() :
                                 autoEscapingPolicy = Configuration.DISABLE_AUTO_ESCAPING_POLICY;
                             }
                             recalculateAutoEscapingField();
-                            _TemplateAPI.setAutoEscaping(template, autoEscaping);
+                            template.setAutoEscaping(autoEscaping);
                         } else if (ks.equalsIgnoreCase("output_format") || ks.equals("outputFormat"))
{
                             if (vs == null) {
                                 throw new ParseException("Expected a string constant for
\"" + ks + "\".", exp);
@@ -4074,8 +4074,8 @@ void HeaderElement() :
 					            throw new ParseException(e.getMessage(), exp, e.getCause());
 					        }
                             recalculateAutoEscapingField();                             
  
-                            _TemplateAPI.setOutputFormat(template, outputFormat);
-                            _TemplateAPI.setAutoEscaping(template, autoEscaping);
+                            template.setOutputFormat(outputFormat);
+                            template.setAutoEscaping(autoEscaping);
                         } else if (ks.equalsIgnoreCase("ns_prefixes") || ks.equals("nsPrefixes"))
{
                             if (!(value instanceof TemplateHashModelEx)) {
                                 throw new ParseException("Expecting a hash of prefixes to
namespace URI's.", exp);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/test/java/org/apache/freemarker/core/ASTPrinter.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ASTPrinter.java b/src/test/java/org/apache/freemarker/core/ASTPrinter.java
index f4baf3f..9068255 100644
--- a/src/test/java/org/apache/freemarker/core/ASTPrinter.java
+++ b/src/test/java/org/apache/freemarker/core/ASTPrinter.java
@@ -248,11 +248,11 @@ public class ASTPrinter {
     
     public static void validateAST(Template t) throws InvalidASTException {
         final _ASTElement node = t.getRootTreeNode();
-        if (node.getParentElement() != null) {
+        if (node.getParent() != null) {
             throw new InvalidASTException("Root node parent must be null."
                     + "\nRoot node: " + node.dump(false)
                     + "\nParent"
-                    + ": " + node.getParentElement().getClass() + ", " + node.getParentElement().dump(false));
+                    + ": " + node.getParent().getClass() + ", " + node.getParent().dump(false));
         }
         validateAST(node);
     }
@@ -261,12 +261,12 @@ public class ASTPrinter {
         int childCount = te.getChildCount();
         for (int i = 0; i < childCount; i++) {
             _ASTElement child = te.getChild(i);
-            _ASTElement parentElement = child.getParentElement();
+            _ASTElement parentElement = child.getParent();
             // As ASTImplicitParent.accept does nothing but returns its children, it's optimized
out in the final
             // AST tree. While it will be present as a child, the parent element also will
have children
             // that contains the children of the ASTImplicitParent directly. 
-            if (parentElement instanceof ASTImplicitParent && parentElement.getParentElement()
!= null) {
-                parentElement = parentElement.getParentElement();
+            if (parentElement instanceof ASTImplicitParent && parentElement.getParent()
!= null) {
+                parentElement = parentElement.getParent();
             }
             if (parentElement != te) {
                 throw new InvalidASTException("Wrong parent node."

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
index 93bef63..e5f3282 100644
--- a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
+++ b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
@@ -223,7 +223,7 @@ public class ConfigurationTest extends TestCase {
     
     public void testVersion() {
         Version v = Configuration.getVersion();
-        assertTrue(v.intValue() >= _TemplateAPI.VERSION_INT_3_0_0);
+        assertTrue(v.intValue() >= _CoreAPI.VERSION_INT_3_0_0);
         
         try {
             new Configuration(new Version(999, 1, 2));

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
index dfb5707..2c39d94 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTest.java
@@ -53,11 +53,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.freemarker.core.Configuration;
-import org.apache.freemarker.core.Template;
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.Version;
-import org.apache.freemarker.core._TemplateAPI;
+import org.apache.freemarker.core.*;
 import org.apache.freemarker.core.model.AdapterTemplateModel;
 import org.apache.freemarker.core.model.ObjectWrapper;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
@@ -106,7 +102,7 @@ public class DefaultObjectWrapperTest {
         expected.add(Configuration.VERSION_3_0_0);
 
         List<Version> actual = new ArrayList<>();
-        int i = _TemplateAPI.VERSION_INT_3_0_0;
+        int i = _CoreAPI.VERSION_INT_3_0_0;
         while (i <= Configuration.getVersion().intValue()) {
             int major = i / 1000000;
             int minor = i % 1000000 / 1000;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/test/java/org/apache/freemarker/test/util/AssertDirective.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/test/util/AssertDirective.java b/src/test/java/org/apache/freemarker/test/util/AssertDirective.java
index a2d190c..91e4fde 100644
--- a/src/test/java/org/apache/freemarker/test/util/AssertDirective.java
+++ b/src/test/java/org/apache/freemarker/test/util/AssertDirective.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.freemarker.core.Environment;
+import org.apache.freemarker.core.NestedContentNotSupportedException;
 import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core._CoreAPI;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
@@ -55,7 +56,7 @@ public class AssertDirective implements TemplateDirectiveModel {
         if (test == null) {
             throw new MissingRequiredParameterException(TEST_PARAM, env);
         }
-        _CoreAPI.checkHasNoNestedContent(body);
+        NestedContentNotSupportedException.check(body);
         
         if (!(test instanceof TemplateBooleanModel)) {
             throw new AssertationFailedInTemplateException("Assertion failed:\n"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/946a4237/src/test/java/org/apache/freemarker/test/util/AssertEqualsDirective.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/test/util/AssertEqualsDirective.java b/src/test/java/org/apache/freemarker/test/util/AssertEqualsDirective.java
index 55bc60b..8ceb529 100644
--- a/src/test/java/org/apache/freemarker/test/util/AssertEqualsDirective.java
+++ b/src/test/java/org/apache/freemarker/test/util/AssertEqualsDirective.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.freemarker.core.Environment;
+import org.apache.freemarker.core.NestedContentNotSupportedException;
 import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core._CoreAPI;
 import org.apache.freemarker.core.model.TemplateBooleanModel;
@@ -66,7 +67,7 @@ public class AssertEqualsDirective implements TemplateDirectiveModel {
         if (expected == null) {
             throw new MissingRequiredParameterException(EXPECTED_PARAM, env);
         }
-        _CoreAPI.checkHasNoNestedContent(body);
+        NestedContentNotSupportedException.check(body);
         
         if (!env.applyEqualsOperatorLenient(actual, expected)) {
             throw new AssertationFailedInTemplateException("Assertion failed:\n"


Mime
View raw message