freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [28/54] [partial] incubator-freemarker git commit: Unifying the o.a.f.core and o.a.f.core.ast
Date Thu, 23 Feb 2017 21:35:55 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/BuiltInsForStringsRegexp.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/BuiltInsForStringsRegexp.java b/src/main/java/org/apache/freemarker/core/ast/BuiltInsForStringsRegexp.java
deleted file mode 100644
index c60af34..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/BuiltInsForStringsRegexp.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.model.TemplateBooleanModel;
-import org.apache.freemarker.core.model.TemplateCollectionModel;
-import org.apache.freemarker.core.model.TemplateMethodModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateModelIterator;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-import org.apache.freemarker.core.util._StringUtil;
-
-
-/**
- * Contains the string built-ins that correspond to basic regular expressions operations.
- */
-class BuiltInsForStringsRegexp {
-
-    static class groupsBI extends BuiltIn {
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel targetModel = target.eval(env);
-            assertNonNull(targetModel, env);
-            if (targetModel instanceof RegexMatchModel) {
-                return ((RegexMatchModel) targetModel).getGroups();
-            } else if (targetModel instanceof RegexMatchModel.MatchWithGroups) {
-                return ((RegexMatchModel.MatchWithGroups) targetModel).groupsSeq;
-            } else {
-                throw new UnexpectedTypeException(target, targetModel,
-                        "regular expression matcher",
-                        new Class[] { RegexMatchModel.class, RegexMatchModel.MatchWithGroups.class },
-                        env);
-            }
-        }
-    }
-    
-    static class matchesBI extends BuiltInForString {
-        class MatcherBuilder implements TemplateMethodModel {
-            
-            String matchString;
-            
-            MatcherBuilder(String matchString) throws TemplateModelException {
-                this.matchString = matchString;
-            }
-            
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                int argCnt = args.size();
-                checkMethodArgCount(argCnt, 1, 2);
-                
-                String patternString = (String) args.get(0);
-                long flags = argCnt > 1 ? RegexpHelper.parseFlagString((String) args.get(1)) : 0;
-                if ((flags & RegexpHelper.RE_FLAG_FIRST_ONLY) != 0) {
-                    RegexpHelper.logFlagWarning("?" + key + " doesn't support the \"f\" flag.");
-                }
-                Pattern pattern = RegexpHelper.getPattern(patternString, (int) flags);
-                return new RegexMatchModel(pattern, matchString);
-            }
-        }
-        
-        @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
-            return new MatcherBuilder(s);
-        }
-        
-    }
-    
-    static class replace_reBI extends BuiltInForString {
-        
-        class ReplaceMethod implements TemplateMethodModel {
-            private String s;
-
-            ReplaceMethod(String s) {
-                this.s = s;
-            }
-
-            @Override
-            public Object exec(List args) throws TemplateModelException {
-                int argCnt = args.size();
-                checkMethodArgCount(argCnt, 2, 3);
-                String arg1 = (String) args.get(0);
-                String arg2 = (String) args.get(1);
-                long flags = argCnt > 2 ? RegexpHelper.parseFlagString((String) args.get(2)) : 0;
-                String result;
-                if ((flags & RegexpHelper.RE_FLAG_REGEXP) == 0) {
-                    RegexpHelper.checkNonRegexpFlags("replace", flags);
-                    result = _StringUtil.replace(s, arg1, arg2,
-                            (flags & RegexpHelper.RE_FLAG_CASE_INSENSITIVE) != 0,
-                            (flags & RegexpHelper.RE_FLAG_FIRST_ONLY) != 0);
-                } else {
-                    Pattern pattern = RegexpHelper.getPattern(arg1, (int) flags);
-                    Matcher matcher = pattern.matcher(s);
-                    result = (flags & RegexpHelper.RE_FLAG_FIRST_ONLY) != 0
-                            ? matcher.replaceFirst(arg2)
-                            : matcher.replaceAll(arg2);
-                } 
-                return new SimpleScalar(result);
-            }
-
-        }
-        
-        @Override
-        TemplateModel calculateResult(String s, Environment env) throws TemplateModelException {
-            return new ReplaceMethod(s);
-        }
-        
-    }
-    
-    // Represents the match
-  
-    static class RegexMatchModel 
-    implements TemplateBooleanModel, TemplateCollectionModel, TemplateSequenceModel {
-        static class MatchWithGroups implements TemplateScalarModel {
-            final String matchedInputPart;
-            final SimpleSequence groupsSeq;
-            
-            MatchWithGroups(String input, Matcher matcher) {
-                matchedInputPart = input.substring(matcher.start(), matcher.end());
-                final int grpCount = matcher.groupCount() + 1;
-                groupsSeq = new SimpleSequence(grpCount);
-                for (int i = 0; i < grpCount; i++) {
-                    groupsSeq.add(matcher.group(i));
-                }
-            }
-            
-            @Override
-            public String getAsString() {
-                return matchedInputPart;
-            }
-        }
-        final Pattern pattern;
-        
-        final String input;
-        private Matcher firedEntireInputMatcher;
-        private Boolean entireInputMatched;
-        
-        private TemplateSequenceModel entireInputMatchGroups;
-        
-        private ArrayList matchingInputParts;
-        
-        RegexMatchModel(Pattern pattern, String input) {
-            this.pattern = pattern;
-            this.input = input;
-        }
-        
-        @Override
-        public TemplateModel get(int i) throws TemplateModelException {
-            ArrayList matchingInputParts = this.matchingInputParts;
-            if (matchingInputParts == null) {
-                matchingInputParts = getMatchingInputPartsAndStoreResults();
-            }
-            return (TemplateModel) matchingInputParts.get(i);
-        }
-        
-        @Override
-        public boolean getAsBoolean() {
-            Boolean result = entireInputMatched;
-            return result != null ? result.booleanValue() : isEntrieInputMatchesAndStoreResults();
-        }
-        
-        TemplateModel getGroups() {
-           TemplateSequenceModel entireInputMatchGroups = this.entireInputMatchGroups;
-           if (entireInputMatchGroups == null) {
-               Matcher t = firedEntireInputMatcher;
-               if (t == null) {
-                   isEntrieInputMatchesAndStoreResults();
-                   t = firedEntireInputMatcher;
-               }
-               final Matcher firedEntireInputMatcher = t;
-               
-                entireInputMatchGroups = new TemplateSequenceModel() {
-                    
-                    @Override
-                    public TemplateModel get(int i) throws TemplateModelException {
-                        try {
-                            return new SimpleScalar(firedEntireInputMatcher.group(i));
-                        } catch (Exception e) {
-                            throw new _TemplateModelException(e, "Failed to read match group");
-                        }
-                    }
-                    
-                    @Override
-                    public int size() throws TemplateModelException {
-                        try {
-                            return firedEntireInputMatcher.groupCount() + 1;
-                        } catch (Exception e) {
-                            throw new _TemplateModelException(e, "Failed to get match group count");
-                        }
-                    }
-                    
-                };
-                this.entireInputMatchGroups = entireInputMatchGroups;
-            }
-            return entireInputMatchGroups;
-        }
-        
-        private ArrayList getMatchingInputPartsAndStoreResults() throws TemplateModelException {
-            ArrayList matchingInputParts = new ArrayList();
-            
-            Matcher matcher = pattern.matcher(input);
-            while (matcher.find()) {
-                matchingInputParts.add(new MatchWithGroups(input, matcher));
-            }
-    
-            this.matchingInputParts = matchingInputParts;
-            return matchingInputParts;
-        }
-        
-        private boolean isEntrieInputMatchesAndStoreResults() {
-            Matcher matcher = pattern.matcher(input);
-            boolean matches = matcher.matches();
-            firedEntireInputMatcher = matcher;
-            entireInputMatched = Boolean.valueOf(matches);
-            return matches;
-        }
-        
-        @Override
-        public TemplateModelIterator iterator() {
-            final ArrayList matchingInputParts = this.matchingInputParts;
-            if (matchingInputParts == null) {
-                final Matcher matcher = pattern.matcher(input);
-                return new TemplateModelIterator() {
-                    
-                    private int nextIdx = 0;
-                    boolean hasFindInfo = matcher.find();
-                    
-                    @Override
-                    public boolean hasNext() {
-                        final ArrayList matchingInputParts = RegexMatchModel.this.matchingInputParts;
-                        if (matchingInputParts == null) {
-                            return hasFindInfo;
-                        } else {
-                            return nextIdx < matchingInputParts.size();
-                        }
-                    }
-                    
-                    @Override
-                    public TemplateModel next() throws TemplateModelException {
-                        final ArrayList matchingInputParts = RegexMatchModel.this.matchingInputParts;
-                        if (matchingInputParts == null) {
-                            if (!hasFindInfo) throw new _TemplateModelException("There were no more matches");
-                            MatchWithGroups result = new MatchWithGroups(input, matcher);
-                            nextIdx++;
-                            hasFindInfo = matcher.find();
-                            return result;
-                        } else {
-                            try {
-                                return (TemplateModel) matchingInputParts.get(nextIdx++);
-                            } catch (IndexOutOfBoundsException e) {
-                                throw new _TemplateModelException(e, "There were no more matches");
-                            }
-                        }
-                    }
-                    
-                };
-            } else {
-                return new TemplateModelIterator() {
-                    
-                    private int nextIdx = 0;
-                    
-                    @Override
-                    public boolean hasNext() {
-                        return nextIdx < matchingInputParts.size();
-                    }
-                    
-                    @Override
-                    public TemplateModel next() throws TemplateModelException {
-                        try {
-                            return (TemplateModel) matchingInputParts.get(nextIdx++);
-                        } catch (IndexOutOfBoundsException e) {
-                            throw new _TemplateModelException(e, "There were no more matches");
-                        }
-                    }
-                };
-            }
-        }
-        
-        @Override
-        public int size() throws TemplateModelException {
-            ArrayList matchingInputParts = this.matchingInputParts;
-            if (matchingInputParts == null) {
-                matchingInputParts = getMatchingInputPartsAndStoreResults();
-            }
-            return matchingInputParts.size();
-        }
-    }
-
-    // Can't be instantiated
-    private BuiltInsForStringsRegexp() { }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/BuiltInsWithParseTimeParameters.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/BuiltInsWithParseTimeParameters.java b/src/main/java/org/apache/freemarker/core/ast/BuiltInsWithParseTimeParameters.java
deleted file mode 100644
index 0906c46..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/BuiltInsWithParseTimeParameters.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core.ast;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.ast.Token;
-import org.apache.freemarker.core.model.TemplateModel;
-
-
-final class BuiltInsWithParseTimeParameters {
-    
-    /**
-     * Behaves similarly to the ternary operator of Java.
-     */
-    static class then_BI extends BuiltInWithParseTimeParameters {
-        
-        private Expression whenTrueExp;
-        private Expression whenFalseExp;
-
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            boolean lho = target.evalToBoolean(env);
-            return (lho ? whenTrueExp : whenFalseExp).evalToNonMissing(env);
-        }
-
-        @Override
-        void bindToParameters(List parameters, Token openParen, Token closeParen) throws ParseException {
-            if (parameters.size() != 2) {
-                throw newArgumentCountException("requires exactly 2", openParen, closeParen);
-            }
-            whenTrueExp = (Expression) parameters.get(0);
-            whenFalseExp = (Expression) parameters.get(1);
-        }
-        
-        @Override
-        protected Expression getArgumentParameterValue(final int argIdx) {
-            switch (argIdx) {
-            case 0: return whenTrueExp;
-            case 1: return whenFalseExp;
-            default: throw new IndexOutOfBoundsException();
-            }
-        }
-
-        @Override
-        protected int getArgumentsCount() {
-            return 2;
-        }
-        
-        @Override
-        protected List getArgumentsAsList() {
-            ArrayList args = new ArrayList(2);
-            args.add(whenTrueExp);
-            args.add(whenFalseExp);
-            return args;
-        }
-        
-        @Override
-        protected void cloneArguments(Expression cloneExp, String replacedIdentifier,
-                Expression replacement, ReplacemenetState replacementState) {
-            then_BI clone = (then_BI) cloneExp;
-            clone.whenTrueExp = whenTrueExp.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState);
-            clone.whenFalseExp = whenFalseExp.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState);
-        }
-        
-    }
-    
-    private BuiltInsWithParseTimeParameters() {
-        // Not to be instantiated
-    }
-
-    static class switch_BI extends BuiltInWithParseTimeParameters {
-        
-        private List/*<Expression>*/ parameters;
-
-        @Override
-        void bindToParameters(List parameters, Token openParen, Token closeParen) throws ParseException {
-            if (parameters.size() < 2) {
-                throw newArgumentCountException("must have at least 2", openParen, closeParen);
-            }
-            this.parameters = parameters;
-        }
-
-        @Override
-        protected List getArgumentsAsList() {
-            return parameters;
-        }
-
-        @Override
-        protected int getArgumentsCount() {
-            return parameters.size();
-        }
-
-        @Override
-        protected Expression getArgumentParameterValue(int argIdx) {
-            return (Expression) parameters.get(argIdx);
-        }
-
-        @Override
-        protected void cloneArguments(Expression clone, String replacedIdentifier, Expression replacement,
-                ReplacemenetState replacementState) {
-            ArrayList parametersClone = new ArrayList(parameters.size());
-            for (int i = 0; i < parameters.size(); i++) {
-                parametersClone.add(((Expression) parameters.get(i))
-                        .deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState));
-            }
-            ((switch_BI) clone).parameters = parametersClone;
-        }
-
-        @Override
-        TemplateModel _eval(Environment env) throws TemplateException {
-            TemplateModel targetValue = target.evalToNonMissing(env);
-            
-            List parameters = this.parameters;
-            int paramCnt = parameters.size();
-            for (int i = 0; i + 1 < paramCnt; i += 2) {
-                Expression caseExp = (Expression) parameters.get(i);
-                TemplateModel caseValue = caseExp.evalToNonMissing(env);
-                if (EvalUtil.compare(
-                        targetValue, target,
-                        EvalUtil.CMP_OP_EQUALS, "==",
-                        caseValue, caseExp,
-                        this, true,
-                        false, false, false,
-                        env)) {
-                    return ((Expression) parameters.get(i + 1)).evalToNonMissing(env);
-                }
-            }
-            
-            if (paramCnt % 2 == 0) {
-                throw new _MiscTemplateException(target,
-                        "The value before ?", key, "(case1, value1, case2, value2, ...) didn't match any of the "
-                        + "case parameters, and there was no default value parameter (an additional last parameter) "
-                        + "eithter. ");
-            }
-            return ((Expression) parameters.get(paramCnt - 1)).evalToNonMissing(env);
-        }
-        
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/BuiltinVariable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/BuiltinVariable.java b/src/main/java/org/apache/freemarker/core/ast/BuiltinVariable.java
deleted file mode 100644
index bfa4c15..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/BuiltinVariable.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import java.util.Arrays;
-import java.util.Date;
-
-import org.apache.freemarker.core.Configuration;
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.model.TemplateDateModel;
-import org.apache.freemarker.core.model.TemplateHashModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.impl.SimpleDate;
-import org.apache.freemarker.core.model.impl.SimpleScalar;
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * A reference to a built-in identifier, such as .root
- */
-final class BuiltinVariable extends Expression {
-
-    static final String TEMPLATE_NAME_CC = "templateName";
-    static final String TEMPLATE_NAME = "template_name";
-    static final String MAIN_TEMPLATE_NAME_CC = "mainTemplateName";
-    static final String MAIN_TEMPLATE_NAME = "main_template_name";
-    static final String CURRENT_TEMPLATE_NAME_CC = "currentTemplateName";
-    static final String CURRENT_TEMPLATE_NAME = "current_template_name";
-    static final String NAMESPACE = "namespace";
-    static final String MAIN = "main";
-    static final String GLOBALS = "globals";
-    static final String LOCALS = "locals";
-    static final String DATA_MODEL_CC = "dataModel";
-    static final String DATA_MODEL = "data_model";
-    static final String LANG = "lang";
-    static final String LOCALE = "locale";
-    static final String LOCALE_OBJECT_CC = "localeObject";
-    static final String LOCALE_OBJECT = "locale_object";
-    static final String CURRENT_NODE_CC = "currentNode";
-    static final String CURRENT_NODE = "current_node";
-    static final String NODE = "node";
-    static final String PASS = "pass";
-    static final String VARS = "vars";
-    static final String VERSION = "version";
-    static final String INCOMPATIBLE_IMPROVEMENTS_CC = "incompatibleImprovements";
-    static final String INCOMPATIBLE_IMPROVEMENTS = "incompatible_improvements";
-    static final String ERROR = "error";
-    static final String OUTPUT_ENCODING_CC = "outputEncoding";
-    static final String OUTPUT_ENCODING = "output_encoding";
-    static final String OUTPUT_FORMAT_CC = "outputFormat";
-    static final String OUTPUT_FORMAT = "output_format";
-    static final String AUTO_ESC_CC = "autoEsc";
-    static final String AUTO_ESC = "auto_esc";
-    static final String URL_ESCAPING_CHARSET_CC = "urlEscapingCharset";
-    static final String URL_ESCAPING_CHARSET = "url_escaping_charset";
-    static final String NOW = "now";
-    
-    static final String[] SPEC_VAR_NAMES = new String[] {
-        AUTO_ESC_CC,
-        AUTO_ESC,
-        CURRENT_NODE_CC,
-        CURRENT_TEMPLATE_NAME_CC,
-        CURRENT_NODE,
-        CURRENT_TEMPLATE_NAME,
-        DATA_MODEL_CC,
-        DATA_MODEL,
-        ERROR,
-        GLOBALS,
-        INCOMPATIBLE_IMPROVEMENTS_CC,
-        INCOMPATIBLE_IMPROVEMENTS,
-        LANG,
-        LOCALE,
-        LOCALE_OBJECT_CC,
-        LOCALE_OBJECT,
-        LOCALS,
-        MAIN,
-        MAIN_TEMPLATE_NAME_CC,
-        MAIN_TEMPLATE_NAME,
-        NAMESPACE,
-        NODE,
-        NOW,
-        OUTPUT_ENCODING_CC,
-        OUTPUT_FORMAT_CC,
-        OUTPUT_ENCODING,
-        OUTPUT_FORMAT,
-        PASS,
-        TEMPLATE_NAME_CC,
-        TEMPLATE_NAME,
-        URL_ESCAPING_CHARSET_CC,
-        URL_ESCAPING_CHARSET,
-        VARS,
-        VERSION
-    };
-
-    private final String name;
-    private final TemplateModel parseTimeValue;
-
-    BuiltinVariable(Token nameTk, FMParserTokenManager tokenManager, TemplateModel parseTimeValue)
-            throws ParseException {
-        String name = nameTk.image;
-        this.parseTimeValue = parseTimeValue;
-        if (Arrays.binarySearch(SPEC_VAR_NAMES, name) < 0) {
-            StringBuilder sb = new StringBuilder();
-            sb.append("Unknown special variable name: ");
-            sb.append(_StringUtil.jQuote(name)).append(".");
-            
-            int shownNamingConvention;
-            {
-                int namingConvention = tokenManager.namingConvention;
-                shownNamingConvention = namingConvention != Configuration.AUTO_DETECT_NAMING_CONVENTION
-                        ? namingConvention : Configuration.LEGACY_NAMING_CONVENTION /* [2.4] CAMEL_CASE */; 
-            }
-            
-            {
-                String correctName;
-                if (name.equals("auto_escape") || name.equals("auto_escaping") || name.equals("autoesc")) {
-                    correctName = "auto_esc";
-                } else if (name.equals("autoEscape") || name.equals("autoEscaping")) {
-                    correctName = "autoEsc";
-                } else {
-                    correctName = null;
-                }
-                if (correctName != null) {
-                    sb.append(" You may meant: ");
-                    sb.append(_StringUtil.jQuote(correctName)).append(".");
-                }
-            }
-            
-            sb.append("\nThe allowed special variable names are: ");
-            boolean first = true;
-            for (final String correctName : SPEC_VAR_NAMES) {
-                int correctNameNamingConvention = _StringUtil.getIdentifierNamingConvention(correctName);
-                if (shownNamingConvention == Configuration.CAMEL_CASE_NAMING_CONVENTION
-                        ? correctNameNamingConvention != Configuration.LEGACY_NAMING_CONVENTION
-                        : correctNameNamingConvention != Configuration.CAMEL_CASE_NAMING_CONVENTION) {
-                    if (first) {
-                        first = false;
-                    } else {
-                        sb.append(", ");
-                    }
-                    sb.append(correctName);
-                }
-            }
-            throw new ParseException(sb.toString(), null, nameTk);
-        }
-        
-        this.name = name.intern();
-    }
-
-    @Override
-    TemplateModel _eval(Environment env) throws TemplateException {
-        if (parseTimeValue != null) {
-            return parseTimeValue;
-        }
-        if (name == NAMESPACE) {
-            return env.getCurrentNamespace();
-        }
-        if (name == MAIN) {
-            return env.getMainNamespace();
-        }
-        if (name == GLOBALS) {
-            return env.getGlobalVariables();
-        }
-        if (name == LOCALS) {
-            Macro.Context ctx = env.getCurrentMacroContext();
-            return ctx == null ? null : ctx.getLocals();
-        }
-        if (name == DATA_MODEL || name == DATA_MODEL_CC) {
-            return env.getDataModel();
-        }
-        if (name == VARS) {
-            return new VarsHash(env);
-        }
-        if (name == LOCALE) {
-            return new SimpleScalar(env.getLocale().toString());
-        }
-        if (name == LOCALE_OBJECT || name == LOCALE_OBJECT_CC) {
-            return env.getObjectWrapper().wrap(env.getLocale());
-        }
-        if (name == LANG) {
-            return new SimpleScalar(env.getLocale().getLanguage());
-        }
-        if (name == CURRENT_NODE || name == NODE || name == CURRENT_NODE_CC) {
-            return env.getCurrentVisitorNode();
-        }
-        if (name == MAIN_TEMPLATE_NAME || name == MAIN_TEMPLATE_NAME_CC) {
-            return SimpleScalar.newInstanceOrNull(env.getMainTemplate().getName());
-        }
-        // [FM3] Some of these two should be removed.
-        if (name == CURRENT_TEMPLATE_NAME || name == CURRENT_TEMPLATE_NAME_CC
-                || name == TEMPLATE_NAME || name == TEMPLATE_NAME_CC) {
-            return SimpleScalar.newInstanceOrNull(env.getCurrentTemplate().getName());
-        }
-        if (name == PASS) {
-            return Macro.DO_NOTHING_MACRO;
-        }
-        if (name == OUTPUT_ENCODING || name == OUTPUT_ENCODING_CC) {
-            String s = env.getOutputEncoding();
-            return SimpleScalar.newInstanceOrNull(s);
-        }
-        if (name == URL_ESCAPING_CHARSET || name == URL_ESCAPING_CHARSET_CC) {
-            String s = env.getURLEscapingCharset();
-            return SimpleScalar.newInstanceOrNull(s);
-        }
-        if (name == ERROR) {
-            return new SimpleScalar(env.getCurrentRecoveredErrorMessage());
-        }
-        if (name == NOW) {
-            return new SimpleDate(new Date(), TemplateDateModel.DATETIME);
-        }
-        if (name == VERSION) {
-            return new SimpleScalar(Configuration.getVersion().toString());
-        }
-        if (name == INCOMPATIBLE_IMPROVEMENTS || name == INCOMPATIBLE_IMPROVEMENTS_CC) {
-            return new SimpleScalar(env.getConfiguration().getIncompatibleImprovements().toString());
-        }
-        
-        throw new _MiscTemplateException(this,
-                "Invalid special variable: ", name);
-    }
-
-    @Override
-    public String toString() {
-        return "." + name;
-    }
-
-    @Override
-    public String getCanonicalForm() {
-        return "." + name;
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return getCanonicalForm();
-    }
-
-    @Override
-    boolean isLiteral() {
-        return false;
-    }
-
-    @Override
-    protected Expression deepCloneWithIdentifierReplaced_inner(
-            String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) {
-        return this;
-    }
-
-    static class VarsHash implements TemplateHashModel {
-        
-        Environment env;
-        
-        VarsHash(Environment env) {
-            this.env = env;
-        }
-        
-        @Override
-        public TemplateModel get(String key) throws TemplateModelException {
-            return env.getVariable(key);
-        }
-        
-        @Override
-        public boolean isEmpty() {
-            return false;
-        }
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 0;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CSSOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CSSOutputFormat.java b/src/main/java/org/apache/freemarker/core/ast/CSSOutputFormat.java
deleted file mode 100644
index 2307e01..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CSSOutputFormat.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core.ast;
-
-/**
- * Represents the CSS output format (MIME type "text/css", name "CSS"). This format doesn't support escaping.
- * 
- * @since 2.3.24
- */
-public class CSSOutputFormat extends OutputFormat {
-
-    /**
-     * The only instance (singleton) of this {@link OutputFormat}.
-     */
-    public static final CSSOutputFormat INSTANCE = new CSSOutputFormat();
-    
-    private CSSOutputFormat() {
-        // Only to decrease visibility
-    }
-    
-    @Override
-    public String getName() {
-        return "CSS";
-    }
-
-    @Override
-    public String getMimeType() {
-        return "text/css";
-    }
-
-    @Override
-    public boolean isOutputFormatMixingAllowed() {
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CallPlaceCustomDataInitializationException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CallPlaceCustomDataInitializationException.java b/src/main/java/org/apache/freemarker/core/ast/CallPlaceCustomDataInitializationException.java
deleted file mode 100644
index 51eba8c..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CallPlaceCustomDataInitializationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-/**
- * Thrown by {@link DirectiveCallPlace#getOrCreateCustomData(Object, org.apache.freemarker.core.util.ObjectFactory)}
- * 
- * @since 2.3.22
- */
-public class CallPlaceCustomDataInitializationException extends Exception {
-
-    public CallPlaceCustomDataInitializationException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/Case.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/Case.java b/src/main/java/org/apache/freemarker/core/ast/Case.java
deleted file mode 100644
index 165d7ba..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/Case.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-/**
- * Represents a case in a switch statement.
- */
-final class Case extends TemplateElement {
-
-    final int TYPE_CASE = 0;
-    final int TYPE_DEFAULT = 1;
-    
-    Expression condition;
-
-    Case(Expression matchingValue, TemplateElements children) {
-        condition = matchingValue;
-        setChildren(children);
-    }
-
-    @Override
-    TemplateElement[] accept(Environment env) {
-        return getChildBuffer();
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        StringBuilder sb = new StringBuilder();
-        if (canonical) sb.append('<');
-        sb.append(getNodeTypeSymbol());
-        if (condition != null) {
-            sb.append(' ');
-            sb.append(condition.getCanonicalForm());
-        }
-        if (canonical) {
-            sb.append('>');
-            sb.append(getChildrenCanonicalForm());
-        }
-        return sb.toString();
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return condition != null ? "#case" : "#default";
-    }
-
-    @Override
-    int getParameterCount() {
-        return 2;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        switch (idx) {
-        case 0: return condition;
-        case 1: return Integer.valueOf(condition != null ? TYPE_CASE : TYPE_DEFAULT);
-        default: throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        switch (idx) {
-        case 0: return ParameterRole.CONDITION;
-        case 1: return ParameterRole.AST_NODE_SUBTYPE;
-        default: throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-        
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CollectionAndSequence.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CollectionAndSequence.java b/src/main/java/org/apache/freemarker/core/ast/CollectionAndSequence.java
deleted file mode 100644
index a0b9988..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CollectionAndSequence.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-import org.apache.freemarker.core.model.TemplateCollectionModel;
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateModelIterator;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-
-/**
- * Add sequence capabilities to an existing collection, or
- * vice versa. Used by ?keys and ?values built-ins.
- */
-final public class CollectionAndSequence
-implements TemplateCollectionModel, TemplateSequenceModel, Serializable {
-    private TemplateCollectionModel collection;
-    private TemplateSequenceModel sequence;
-    private ArrayList data;
-
-    public CollectionAndSequence(TemplateCollectionModel collection) {
-        this.collection = collection;
-    }
-
-    public CollectionAndSequence(TemplateSequenceModel sequence) {
-        this.sequence = sequence;
-    }
-
-    @Override
-    public TemplateModelIterator iterator() throws TemplateModelException {
-        if (collection != null) {
-            return collection.iterator();
-        } else {
-            return new SequenceIterator(sequence);
-        }
-    }
-
-    @Override
-    public TemplateModel get(int i) throws TemplateModelException {
-        if (sequence != null) {
-            return sequence.get(i);
-        } else {
-            initSequence();
-            return (TemplateModel) data.get(i);
-        }
-    }
-
-    @Override
-    public int size() throws TemplateModelException {
-        if (sequence != null) {
-            return sequence.size();
-        } else {
-            initSequence();
-            return data.size();
-        }
-    }
-
-    private void initSequence() throws TemplateModelException {
-        if (data == null) {
-            data = new ArrayList();
-            TemplateModelIterator it = collection.iterator();
-            while (it.hasNext()) {
-                data.add(it.next());
-            }
-        }
-    }
-
-    private static class SequenceIterator
-    implements TemplateModelIterator {
-        private final TemplateSequenceModel sequence;
-        private final int size;
-        private int index = 0;
-
-        SequenceIterator(TemplateSequenceModel sequence) throws TemplateModelException {
-            this.sequence = sequence;
-            size = sequence.size();
-            
-        }
-        @Override
-        public TemplateModel next() throws TemplateModelException {
-            return sequence.get(index++);
-        }
-
-        @Override
-        public boolean hasNext() {
-            return index < size;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CombinedMarkupOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CombinedMarkupOutputFormat.java b/src/main/java/org/apache/freemarker/core/ast/CombinedMarkupOutputFormat.java
deleted file mode 100644
index fad75d2..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CombinedMarkupOutputFormat.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core.ast;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.freemarker.core.model.TemplateModelException;
-
-/**
- * Represents two markup formats nested into each other. For example, markdown nested into HTML.
- * 
- * @since 2.3.24
- */
-public final class CombinedMarkupOutputFormat extends CommonMarkupOutputFormat<TemplateCombinedMarkupOutputModel> {
-
-    private final String name;
-    
-    private final MarkupOutputFormat outer;
-    private final MarkupOutputFormat inner;
-
-    /**
-     * Same as {@link #CombinedMarkupOutputFormat(String, MarkupOutputFormat, MarkupOutputFormat)} with {@code null} as
-     * the {@code name} parameter.
-     */
-    public CombinedMarkupOutputFormat(MarkupOutputFormat outer, MarkupOutputFormat inner) {
-        this(null, outer, inner);
-    }
-    
-    /**
-     * @param name
-     *            Maybe {@code null}, in which case it defaults to
-     *            <code>outer.getName() + "{" + inner.getName() + "}"</code>.
-     */
-    public CombinedMarkupOutputFormat(String name, MarkupOutputFormat outer, MarkupOutputFormat inner) {
-        this.name = name != null ? null : outer.getName() + "{" + inner.getName() + "}";
-        this.outer = outer;
-        this.inner = inner;
-    }
-    
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    @Override
-    public String getMimeType() {
-        return outer.getMimeType();
-    }
-
-    @Override
-    public void output(String textToEsc, Writer out) throws IOException, TemplateModelException {
-        outer.output(inner.escapePlainText(textToEsc), out);
-    }
-
-    @Override
-    public String escapePlainText(String plainTextContent) throws TemplateModelException {
-        return outer.escapePlainText(inner.escapePlainText(plainTextContent));
-    }
-
-    @Override
-    public boolean isLegacyBuiltInBypassed(String builtInName) throws TemplateModelException {
-        return outer.isLegacyBuiltInBypassed(builtInName);
-    }
-
-    @Override
-    public boolean isAutoEscapedByDefault() {
-        return outer.isAutoEscapedByDefault();
-    }
-    
-    @Override
-    public boolean isOutputFormatMixingAllowed() {
-        return outer.isOutputFormatMixingAllowed();
-    }
-
-    public MarkupOutputFormat getOuterOutputFormat() {
-        return outer;
-    }
-
-    public MarkupOutputFormat getInnerOutputFormat() {
-        return inner;
-    }
-
-    @Override
-    protected TemplateCombinedMarkupOutputModel newTemplateMarkupOutputModel(
-            String plainTextContent, String markupContent) {
-        return new TemplateCombinedMarkupOutputModel(plainTextContent, markupContent, this);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/Comment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/Comment.java b/src/main/java/org/apache/freemarker/core/ast/Comment.java
deleted file mode 100644
index fc13f54..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/Comment.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * A template element where the content is ignored, a Comment.
- */
-final class Comment extends TemplateElement {
-
-    private final String text;
-
-    Comment(String text) {
-        this.text = text;
-    }
-
-    @Override
-    TemplateElement[] accept(Environment env) {
-        // do nothing, skip the body
-        return null;
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        if (canonical) {
-            return "<#--" + text + "-->";
-        } else {
-            return "comment " + _StringUtil.jQuote(text.trim());
-        }
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return "#--...--";
-    }
-    
-
-    @Override
-    int getParameterCount() {
-        return 1;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        if (idx != 0) throw new IndexOutOfBoundsException();
-        return text;
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        if (idx != 0) throw new IndexOutOfBoundsException();
-        return ParameterRole.CONTENT;
-    }
-
-    public String getText() {
-        return text;
-    }
-
-    @Override
-    boolean isOutputCacheable() {
-        return true;
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CommonMarkupOutputFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CommonMarkupOutputFormat.java b/src/main/java/org/apache/freemarker/core/ast/CommonMarkupOutputFormat.java
deleted file mode 100644
index b3cde16..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CommonMarkupOutputFormat.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core.ast;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.apache.freemarker.core.model.TemplateModelException;
-
-/**
- * Common superclass for implementing {@link MarkupOutputFormat}-s that use a {@link CommonTemplateMarkupOutputModel}
- * subclass.
- * 
- * @since 2.3.24
- */
-public abstract class CommonMarkupOutputFormat<MO extends CommonTemplateMarkupOutputModel>
-        extends MarkupOutputFormat<MO> {
-
-    protected CommonMarkupOutputFormat() {
-        // Only to decrease visibility
-    }
-    
-    @Override
-    public final MO fromPlainTextByEscaping(String textToEsc) throws TemplateModelException {
-        return newTemplateMarkupOutputModel(textToEsc, null);
-    }
-
-    @Override
-    public final MO fromMarkup(String markupText) throws TemplateModelException {
-        return newTemplateMarkupOutputModel(null, markupText);
-    }
-
-    @Override
-    public final void output(MO mo, Writer out) throws IOException, TemplateModelException {
-        String mc = mo.getMarkupContent();
-        if (mc != null) {
-            out.write(mc);
-        } else {
-            output(mo.getPlainTextContent(), out);
-        }
-    }
-
-    @Override
-    public abstract void output(String textToEsc, Writer out) throws IOException, TemplateModelException;
-    
-    @Override
-    public final String getSourcePlainText(MO mo) throws TemplateModelException {
-        return mo.getPlainTextContent();
-    }
-
-    @Override
-    public final String getMarkupString(MO mo) throws TemplateModelException {
-        String mc = mo.getMarkupContent();
-        if (mc != null) {
-            return mc;
-        }
-        
-        mc = escapePlainText(mo.getPlainTextContent());
-        mo.setMarkupContent(mc);
-        return mc;
-    }
-    
-    @Override
-    public final MO concat(MO mo1, MO mo2) throws TemplateModelException {
-        String pc1 = mo1.getPlainTextContent();
-        String mc1 = mo1.getMarkupContent();
-        String pc2 = mo2.getPlainTextContent();
-        String mc2 = mo2.getMarkupContent();
-        
-        String pc3 = pc1 != null && pc2 != null ? pc1 + pc2 : null;
-        String mc3 = mc1 != null && mc2 != null ? mc1 + mc2 : null;
-        if (pc3 != null || mc3 != null) {
-            return newTemplateMarkupOutputModel(pc3, mc3);
-        }
-        
-        if (pc1 != null) {
-            return newTemplateMarkupOutputModel(null, getMarkupString(mo1) + mc2);
-        } else {
-            return newTemplateMarkupOutputModel(null, mc1 + getMarkupString(mo2));
-        }
-    }
-    
-    @Override
-    public boolean isEmpty(MO mo) throws TemplateModelException {
-        String s = mo.getPlainTextContent();
-        if (s != null) {
-            return s.length() == 0;
-        }
-        return mo.getMarkupContent().length() == 0;
-    }
-    
-    @Override
-    public boolean isOutputFormatMixingAllowed() {
-        return false;
-    }
-    
-    @Override
-    public boolean isAutoEscapedByDefault() {
-        return true;
-    }
-
-    /**
-     * Creates a new {@link CommonTemplateMarkupOutputModel} that's bound to this {@link OutputFormat} instance.
-     */
-    protected abstract MO newTemplateMarkupOutputModel(String plainTextContent, String markupContent)
-            throws TemplateModelException;
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CommonTemplateMarkupOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CommonTemplateMarkupOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/CommonTemplateMarkupOutputModel.java
deleted file mode 100644
index f7c5db5..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CommonTemplateMarkupOutputModel.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.freemarker.core.ast;
-
-/**
- * Common superclass for implementing {@link TemplateMarkupOutputModel}-s that belong to a
- * {@link CommonMarkupOutputFormat} subclass format.
- * 
- * <p>
- * Thread-safe after proper publishing. Calculated fields (typically, the markup calculated from plain text) might will
- * be re-calculated for multiple times if accessed from multiple threads (this only affects performance, not
- * functionality).
- * 
- * @since 2.3.24
- */
-public abstract class CommonTemplateMarkupOutputModel<MO extends CommonTemplateMarkupOutputModel<MO>>
-        implements TemplateMarkupOutputModel<MO> {
-
-    private final String plainTextContent;
-    private String markupContent;
-
-    /**
-     * A least one of the parameters must be non-{@code null}!
-     */
-    protected CommonTemplateMarkupOutputModel(String plainTextContent, String markupContent) {
-        this.plainTextContent = plainTextContent;
-        this.markupContent = markupContent;
-    }
-
-    @Override
-    public abstract CommonMarkupOutputFormat<MO> getOutputFormat();
-
-    /** Maybe {@code null}, but then {@link #getMarkupContent()} isn't {@code null}. */
-    final String getPlainTextContent() {
-        return plainTextContent;
-    }
-
-    /** Maybe {@code null}, but then {@link #getPlainTextContent()} isn't {@code null}. */
-    final String getMarkupContent() {
-        return markupContent;
-    }
-
-    /**
-     * Use only to set the value calculated from {@link #getPlainTextContent()}, when {@link #getMarkupContent()} was
-     * still {@code null}!
-     */
-    final void setMarkupContent(String markupContent) {
-        this.markupContent = markupContent;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/ComparisonExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/ComparisonExpression.java b/src/main/java/org/apache/freemarker/core/ast/ComparisonExpression.java
deleted file mode 100644
index a5b5356..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/ComparisonExpression.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import org.apache.freemarker.core.TemplateException;
-
-/**
- * A class that handles comparisons.
- */
-final class ComparisonExpression extends BooleanExpression {
-
-    private final Expression left;
-    private final Expression right;
-    private final int operation;
-    private final String opString;
-
-    ComparisonExpression(Expression left, Expression right, String opString) {
-        this.left = left;
-        this.right = right;
-        opString = opString.intern();
-        this.opString = opString;
-        if (opString == "==" || opString == "=") {
-            operation = EvalUtil.CMP_OP_EQUALS;
-        } else if (opString == "!=") {
-            operation = EvalUtil.CMP_OP_NOT_EQUALS;
-        } else if (opString == "gt" || opString == "\\gt" || opString == ">" || opString == "&gt;") {
-            operation = EvalUtil.CMP_OP_GREATER_THAN;
-        } else if (opString == "gte" || opString == "\\gte" || opString == ">=" || opString == "&gt;=") {
-            operation = EvalUtil.CMP_OP_GREATER_THAN_EQUALS;
-        } else if (opString == "lt" || opString == "\\lt" || opString == "<" || opString == "&lt;") {
-            operation = EvalUtil.CMP_OP_LESS_THAN;
-        } else if (opString == "lte" || opString == "\\lte" || opString == "<=" || opString == "&lt;=") {
-            operation = EvalUtil.CMP_OP_LESS_THAN_EQUALS;
-        } else {
-            throw new BugException("Unknown comparison operator " + opString);
-        }
-    }
-
-    /*
-     * WARNING! This algorithm is duplicated in SequenceBuiltins.modelsEqual.
-     * Thus, if you update this method, then you have to update that too!
-     */
-    @Override
-    boolean evalToBoolean(Environment env) throws TemplateException {
-        return EvalUtil.compare(left, operation, opString, right, this, env);
-    }
-
-    @Override
-    public String getCanonicalForm() {
-        return left.getCanonicalForm() + ' ' + opString + ' ' + right.getCanonicalForm();
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return opString;
-    }
-
-    @Override
-    boolean isLiteral() {
-        return constantValue != null || (left.isLiteral() && right.isLiteral());
-    }
-
-    @Override
-    protected Expression deepCloneWithIdentifierReplaced_inner(
-            String replacedIdentifier, Expression replacement, ReplacemenetState replacementState) {
-    	return new ComparisonExpression(
-    	        left.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState),
-    	        right.deepCloneWithIdentifierReplaced(replacedIdentifier, replacement, replacementState),
-    	        opString);
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 2;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        return idx == 0 ? left : right;
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        return ParameterRole.forBinaryOperatorOperand(idx);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/CompressedBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/CompressedBlock.java b/src/main/java/org/apache/freemarker/core/ast/CompressedBlock.java
deleted file mode 100644
index 8c7dd19..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/CompressedBlock.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import java.io.IOException;
-
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.util.StandardCompress;
-
-/**
- * An instruction that reduces all sequences of whitespace to a single
- * space or newline. In addition, leading and trailing whitespace is removed.
- * @see org.apache.freemarker.core.util.StandardCompress
- */
-final class CompressedBlock extends TemplateElement {
-
-    CompressedBlock(TemplateElements children) { 
-        setChildren(children);
-    }
-
-    @Override
-    TemplateElement[] accept(Environment env) throws TemplateException, IOException {
-        TemplateElement[] childBuffer = getChildBuffer();
-        if (childBuffer != null) {
-            env.visitAndTransform(childBuffer, StandardCompress.INSTANCE, null);
-        }
-        return null;
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        if (canonical) {
-            return "<" + getNodeTypeSymbol() + ">" + getChildrenCanonicalForm() + "</" + getNodeTypeSymbol() + ">";
-        } else {
-            return getNodeTypeSymbol();
-        }
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return "#compress";
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 0;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        throw new IndexOutOfBoundsException();
-    }
-
-    @Override
-    boolean isIgnorable(boolean stripWhitespace) {
-        return getChildCount() == 0 && getParameterCount() == 0;
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/ConditionalBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/ConditionalBlock.java b/src/main/java/org/apache/freemarker/core/ast/ConditionalBlock.java
deleted file mode 100644
index 782ecb2..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/ConditionalBlock.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.ast;
-
-import java.io.IOException;
-
-import org.apache.freemarker.core.TemplateException;
-
-/**
- * An element that represents a conditionally executed block: #if, #elseif or #elseif. Note that when an #if has
- * related #elseif-s or #else, an {@link IfBlock} parent must be used. For a lonely #if, no such parent is needed. 
- */
-
-final class ConditionalBlock extends TemplateElement {
-
-    static final int TYPE_IF = 0;
-    static final int TYPE_ELSE = 1;
-    static final int TYPE_ELSE_IF = 2;
-    
-    final Expression condition;
-    private final int type;
-
-    ConditionalBlock(Expression condition, TemplateElements children, int type) {
-        this.condition = condition;
-        setChildren(children);
-        this.type = type;
-    }
-
-    @Override
-    TemplateElement[] accept(Environment env) throws TemplateException, IOException {
-        if (condition == null || condition.evalToBoolean(env)) {
-            return getChildBuffer();
-        }
-        return null;
-    }
-    
-    @Override
-    protected String dump(boolean canonical) {
-        StringBuilder buf = new StringBuilder();
-        if (canonical) buf.append('<');
-        buf.append(getNodeTypeSymbol());
-        if (condition != null) {
-            buf.append(' ');
-            buf.append(condition.getCanonicalForm());
-        }
-        if (canonical) {
-            buf.append(">");
-            buf.append(getChildrenCanonicalForm());
-            if (!(getParentElement() instanceof IfBlock)) {
-                buf.append("</#if>");
-            }
-        }
-        return buf.toString();
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        if (type == TYPE_ELSE) {
-            return "#else";
-        } else if (type == TYPE_IF) {
-            return "#if";
-        } else if (type == TYPE_ELSE_IF) {
-            return "#elseif";
-        } else {
-            throw new BugException("Unknown type");
-        }
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 2;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        switch (idx) {
-        case 0: return condition;
-        case 1: return Integer.valueOf(type);
-        default: throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        switch (idx) {
-        case 0: return ParameterRole.CONDITION;
-        case 1: return ParameterRole.AST_NODE_SUBTYPE;
-        default: throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-    
-}


Mime
View raw message