freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [18/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:45 GMT
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateElement.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateElement.java b/src/main/java/org/apache/freemarker/core/ast/TemplateElement.java
deleted file mode 100644
index 6778fc9..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateElement.java
+++ /dev/null
@@ -1,476 +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.util.Collections;
-import java.util.Enumeration;
-
-import org.apache.freemarker.core.TemplateException;
-import org.apache.freemarker.core.model.TemplateNodeModel;
-import org.apache.freemarker.core.model.TemplateSequenceModel;
-import org.apache.freemarker.core.model.impl.SimpleSequence;
-import org.apache.freemarker.core.util._ArrayEnumeration;
-
-/**
- * <b>Internal API - subject to change:</b> Represent directive call, interpolation, text block, or other such
- * non-expression node in the parsed template. Some information that can be found here can be accessed through the
- * {@link Environment#getCurrentDirectiveCallPlace()}, which a published API, and thus promises backward compatibility.
- * 
- * @deprecated This is an internal FreeMarker API with no backward compatibility guarantees, so you shouldn't depend on
- *             it.
- */
-@Deprecated
-abstract public class TemplateElement extends TemplateObject {
-
-    private static final int INITIAL_REGULATED_CHILD_BUFFER_CAPACITY = 6;
-
-    private TemplateElement parent;
-
-    /**
-     * Contains 1 or more nested elements with optional trailing {@code null}-s, or is {@code null} exactly if there are
-     * no nested elements.
-     */
-    private TemplateElement[] childBuffer;
-
-    /**
-     * Contains the number of elements in the {@link #childBuffer}, not counting the trailing {@code null}-s. If this is
-     * 0, then and only then {@link #childBuffer} must be {@code null}.
-     */
-    private int childCount;
-
-    /**
-     * The index of the element in the parent's {@link #childBuffer} array.
-     * 
-     * @since 2.3.23
-     */
-    private int index;
-
-    /**
-     * Executes this {@link TemplateElement}. Usually should not be called directly, but through
-     * {@link Environment#visit(TemplateElement)} or a similar {@link Environment} method.
-     *
-     * @param env
-     *            The runtime environment
-     * 
-     * @return The template elements to execute (meant to be used for nested elements), or {@code null}. Can have
-     *         <em>trailing</em> {@code null}-s (unused buffer capacity). Returning the nested elements instead of
-     *         executing them inside this method is a trick used for decreasing stack usage when there's nothing to do
-     *         after the children was processed anyway.
-     */
-    abstract TemplateElement[] accept(Environment env) throws TemplateException, IOException;
-
-    /**
-     * One-line description of the element, that contain all the information that is used in {@link #getCanonicalForm()}
-     * , except the nested content (elements) of the element. The expressions inside the element (the parameters) has to
-     * be shown. Meant to be used for stack traces, also for tree views that don't go down to the expression-level.
-     * There are no backward-compatibility guarantees regarding the format used ATM, but it must be regular enough to be
-     * machine-parseable, and it must contain all information necessary for restoring an AST equivalent to the original.
-     * 
-     * This final implementation calls {@link #dump(boolean) dump(false)}.
-     * 
-     * @see #getCanonicalForm()
-     * @see #getNodeTypeSymbol()
-     */
-    public final String getDescription() {
-        return dump(false);
-    }
-
-    /**
-     * This final implementation calls {@link #dump(boolean) dump(false)}.
-     */
-    @Override
-    public final String getCanonicalForm() {
-        return dump(true);
-    }
-
-    final String getChildrenCanonicalForm() {
-        return getChildrenCanonicalForm(childBuffer);
-    }
-    
-    static String getChildrenCanonicalForm(TemplateElement[] children) {
-        if (children == null) {
-            return "";
-        }
-        StringBuilder sb = new StringBuilder();
-        for (TemplateElement child : children) {
-            if (child == null) {
-                break;
-            }
-            sb.append(child.getCanonicalForm());
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Tells if the element should show up in error stack traces. Note that this will be ignored for the top (current)
-     * element of a stack trace, as that's always shown.
-     */
-    boolean isShownInStackTrace() {
-        return false;
-    }
-
-    /**
-     * Tells if this element possibly executes its nested content for many times. This flag is useful when a template
-     * AST is modified for running time limiting (see {@link ThreadInterruptionSupportTemplatePostProcessor}). Elements
-     * that use {@link #childBuffer} should not need this, as the insertion of the timeout checks is impossible there,
-     * given their rigid nested element schema.
-     */
-    abstract boolean isNestedBlockRepeater();
-
-    /**
-     * Brings the implementation of {@link #getCanonicalForm()} and {@link #getDescription()} to a single place. Don't
-     * call those methods in method on {@code this}, because that will result in infinite recursion!
-     * 
-     * @param canonical
-     *            if {@code true}, it calculates the return value of {@link #getCanonicalForm()}, otherwise of
-     *            {@link #getDescription()}.
-     */
-    abstract protected String dump(boolean canonical);
-
-    // Methods to implement TemplateNodeModel
-
-    public TemplateNodeModel getParentNode() {
-        // return parent;
-        return null;
-    }
-
-    public String getNodeNamespace() {
-        return null;
-    }
-
-    public String getNodeType() {
-        return "element";
-    }
-
-    public TemplateSequenceModel getChildNodes() {
-        if (childBuffer != null) {
-            final SimpleSequence seq = new SimpleSequence(childCount);
-            for (int i = 0; i < childCount; i++) {
-                seq.add(childBuffer[i]);
-            }
-            return seq;
-        } else {
-            return new SimpleSequence(0);
-        }
-    }
-
-    public String getNodeName() {
-        String className = getClass().getName();
-        int shortNameOffset = className.lastIndexOf('.') + 1;
-        return className.substring(shortNameOffset);
-    }
-
-    // Methods so that we can implement the Swing TreeNode API.
-
-    public boolean isLeaf() {
-        return childCount == 0;
-    }
-
-    public int getIndex(TemplateElement node) {
-        for (int i = 0; i < childCount; i++) {
-            if (childBuffer[i].equals(node)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    public int getChildCount() {
-        return childCount;
-    }
-
-    /**
-     * Note: For element with {@code #nestedBlock}, this will hide the {@code #nestedBlock} when that's a
-     * {@link MixedContent}.
-     */
-    public Enumeration children() {
-        return childBuffer != null
-                ? new _ArrayEnumeration(childBuffer, childCount)
-                : Collections.enumeration(Collections.EMPTY_LIST);
-    }
-
-    public void setChildAt(int index, TemplateElement element) {
-        if (index < childCount && index >= 0) {
-            childBuffer[index] = element;
-            element.index = index;
-            element.parent = this;
-        } else {
-            throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + childCount);
-        }
-    }
-    
-    /**
-     * The element whose child this element is, or {@code null} if this is the root node.
-     */
-    final TemplateElement getParentElement() {
-        return parent;
-    }
-
-    final void setChildBufferCapacity(int capacity) {
-        int ln = childCount;
-        TemplateElement[] newRegulatedChildBuffer = new TemplateElement[capacity];
-        for (int i = 0; i < ln; i++) {
-            newRegulatedChildBuffer[i] = childBuffer[i];
-        }
-        childBuffer = newRegulatedChildBuffer;
-    }
-
-    /**
-     * Inserts a new nested element after the last nested element.
-     */
-    final void addChild(TemplateElement nestedElement) {
-        addChild(childCount, nestedElement);
-    }
-
-    /**
-     * Inserts a new nested element at the given index, which can also be one higher than the current highest index.
-     */
-    final void addChild(int index, TemplateElement nestedElement) {
-        final int lRegulatedChildCount = childCount;
-
-        TemplateElement[] lRegulatedChildBuffer = childBuffer;
-        if (lRegulatedChildBuffer == null) {
-            lRegulatedChildBuffer = new TemplateElement[INITIAL_REGULATED_CHILD_BUFFER_CAPACITY];
-            childBuffer = lRegulatedChildBuffer;
-        } else if (lRegulatedChildCount == lRegulatedChildBuffer.length) {
-            setChildBufferCapacity(lRegulatedChildCount != 0 ? lRegulatedChildCount * 2 : 1);
-            lRegulatedChildBuffer = childBuffer;
-        }
-        // At this point: nestedElements == this.nestedElements, and has sufficient capacity.
-
-        for (int i = lRegulatedChildCount; i > index; i--) {
-            TemplateElement movedElement = lRegulatedChildBuffer[i - 1];
-            movedElement.index = i;
-            lRegulatedChildBuffer[i] = movedElement;
-        }
-        nestedElement.index = index;
-        nestedElement.parent = this;
-        lRegulatedChildBuffer[index] = nestedElement;
-        childCount = lRegulatedChildCount + 1;
-    }
-
-    final TemplateElement getChild(int index) {
-        return childBuffer[index];
-    }
-
-    /**
-     * @return Array containing 1 or more nested elements with optional trailing {@code null}-s, or is {@code null}
-     *         exactly if there are no nested elements.
-     */
-    final TemplateElement[] getChildBuffer() {
-        return childBuffer;
-    }
-
-    /**
-     * @param buffWithCnt Maybe {@code null}
-     * 
-     * @since 2.3.24
-     */
-    final void setChildren(TemplateElements buffWithCnt) {
-        TemplateElement[] childBuffer = buffWithCnt.getBuffer();
-        int childCount = buffWithCnt.getCount();
-        for (int i = 0; i < childCount; i++) {
-            TemplateElement child = childBuffer[i];
-            child.index = i;
-            child.parent = this;
-        }
-        this.childBuffer = childBuffer;
-        this.childCount = childCount;
-    }
-
-    final int getIndex() {
-        return index;
-    }
-
-    /**
-     * This is a special case, because a root element is not contained in another element, so we couldn't set the
-     * private fields.
-     */
-    final void setFieldsForRootElement() {
-        index = 0;
-        parent = null;
-    }
-
-    /**
-     * Walk the AST subtree rooted by this element, and do simplifications where possible, also removes superfluous
-     * whitespace.
-     * 
-     * @param stripWhitespace
-     *            whether to remove superfluous whitespace
-     * 
-     * @return The element this element should be replaced with in the parent. If it's the same as this element, no
-     *         actual replacement will happen. Note that adjusting the {@link #parent} and {@link #index} of the result
-     *         is the duty of the caller, not of this method.
-     */
-    TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException {
-        int childCount = this.childCount;
-        if (childCount != 0) {
-            for (int i = 0; i < childCount; i++) {
-                TemplateElement te = childBuffer[i];
-                
-                /*
-                // Assertion:
-                if (te.getIndex() != i) {
-                    throw new BugException("Invalid index " + te.getIndex() + " (expected: "
-                            + i + ") for: " + te.dump(false));
-                }
-                if (te.getParent() != this) {
-                    throw new BugException("Invalid parent " + te.getParent() + " (expected: "
-                            + this.dump(false) + ") for: " + te.dump(false));
-                }
-                */
-                
-                te = te.postParseCleanup(stripWhitespace);
-                childBuffer[i] = te;
-                te.parent = this;
-                te.index = i;
-            }
-            for (int i = 0; i < childCount; i++) {
-                TemplateElement te = childBuffer[i];
-                if (te.isIgnorable(stripWhitespace)) {
-                    childCount--;
-                    // As later isIgnorable calls might investigates the siblings, we have to move all the items now. 
-                    for (int j = i; j < childCount; j++) {
-                        final TemplateElement te2 = childBuffer[j + 1];
-                        childBuffer[j] = te2;
-                        te2.index = j;
-                    }
-                    childBuffer[childCount] = null;
-                    this.childCount = childCount;
-                    i--;
-                }
-            }
-            if (childCount == 0) {
-                childBuffer = null;
-            } else if (childCount < childBuffer.length
-                    && childCount <= childBuffer.length * 3 / 4) {
-                TemplateElement[] trimmedChildBuffer = new TemplateElement[childCount];
-                for (int i = 0; i < childCount; i++) {
-                    trimmedChildBuffer[i] = childBuffer[i];
-                }
-                childBuffer = trimmedChildBuffer;
-            }
-        }
-        return this;
-    }
-
-    boolean isIgnorable(boolean stripWhitespace) {
-        return false;
-    }
-
-    // The following methods exist to support some fancier tree-walking
-    // and were introduced to support the whitespace cleanup feature in 2.2
-
-    TemplateElement prevTerminalNode() {
-        TemplateElement prev = previousSibling();
-        if (prev != null) {
-            return prev.getLastLeaf();
-        } else if (parent != null) {
-            return parent.prevTerminalNode();
-        }
-        return null;
-    }
-
-    TemplateElement nextTerminalNode() {
-        TemplateElement next = nextSibling();
-        if (next != null) {
-            return next.getFirstLeaf();
-        } else if (parent != null) {
-            return parent.nextTerminalNode();
-        }
-        return null;
-    }
-
-    TemplateElement previousSibling() {
-        if (parent == null) {
-            return null;
-        }
-        return index > 0 ? parent.childBuffer[index - 1] : null;
-    }
-
-    TemplateElement nextSibling() {
-        if (parent == null) {
-            return null;
-        }
-        return index + 1 < parent.childCount ? parent.childBuffer[index + 1] : null;
-    }
-
-    private TemplateElement getFirstChild() {
-        return childCount == 0 ? null : childBuffer[0];
-    }
-
-    private TemplateElement getLastChild() {
-        final int childCount = this.childCount;
-        return childCount == 0 ? null : childBuffer[childCount - 1];
-    }
-
-    private TemplateElement getFirstLeaf() {
-        TemplateElement te = this;
-        while (!te.isLeaf() && !(te instanceof Macro) && !(te instanceof BlockAssignment)) {
-            // A macro or macro invocation is treated as a leaf here for special reasons
-            te = te.getFirstChild();
-        }
-        return te;
-    }
-
-    private TemplateElement getLastLeaf() {
-        TemplateElement te = this;
-        while (!te.isLeaf() && !(te instanceof Macro) && !(te instanceof BlockAssignment)) {
-            // A macro or macro invocation is treated as a leaf here for special reasons
-            te = te.getLastChild();
-        }
-        return te;
-    }
-
-    /**
-     * Tells if executing this element has output that only depends on the template content and that has no side
-     * effects.
-     */
-    boolean isOutputCacheable() {
-        return false;
-    }
-
-    boolean isChildrenOutputCacheable() {
-        int ln = childCount;
-        for (int i = 0; i < ln; i++) {
-            if (!childBuffer[i].isOutputCacheable()) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * determines whether this element's presence on a line indicates that we should not strip opening whitespace in the
-     * post-parse whitespace gobbling step.
-     */
-    boolean heedsOpeningWhitespace() {
-        return false;
-    }
-
-    /**
-     * determines whether this element's presence on a line indicates that we should not strip trailing whitespace in
-     * the post-parse whitespace gobbling step.
-     */
-    boolean heedsTrailingWhitespace() {
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateElementArrayBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateElementArrayBuilder.java b/src/main/java/org/apache/freemarker/core/ast/TemplateElementArrayBuilder.java
deleted file mode 100644
index 14c17eb..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateElementArrayBuilder.java
+++ /dev/null
@@ -1,102 +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._CollectionUtil;
-
-/**
- * Holds an buffer (array) of {@link TemplateElement}-s with the count of the utilized items in it. The un-utilized tail
- * of the array must only contain {@code null}-s.
- * 
- * @since 2.3.24
- */
-class TemplateElements {
-    
-    static final TemplateElements EMPTY = new TemplateElements(null, 0);
-
-    private final TemplateElement[] buffer;
-    private final int count;
-
-    /**
-     * @param buffer
-     *            The buffer; {@code null} exactly if {@code count} is 0.
-     * @param count
-     *            The number of utilized buffer elements; if 0, then {@code null} must be {@code null}.
-     */
-    TemplateElements(TemplateElement[] buffer, int count) {
-        /*
-        // Assertion:
-        if (count == 0 && buffer != null) {
-            throw new IllegalArgumentException(); 
-        }
-        */
-        
-        this.buffer = buffer;
-        this.count = count;
-    }
-
-    TemplateElement[] getBuffer() {
-        return buffer;
-    }
-
-    int getCount() {
-        return count;
-    }
-
-    TemplateElement getFirst() {
-        return buffer != null ? buffer[0] : null;
-    }
-    
-    TemplateElement getLast() {
-        return buffer != null ? buffer[count - 1] : null;
-    }
-    
-    /**
-     * Used for some backward compatibility hacks.
-     */
-    TemplateElement asSingleElement() {
-        if (count == 0) {
-            return new TextBlock(_CollectionUtil.EMPTY_CHAR_ARRAY, false);
-        } else {
-            TemplateElement first = buffer[0];
-            if (count == 1) {
-                return first;
-            } else {
-                MixedContent mixedContent = new MixedContent();
-                mixedContent.setChildren(this);
-                mixedContent.setLocation(first.getTemplate(), first, getLast());
-                return mixedContent;
-            }
-        }
-    }
-    
-    /**
-     * Used for some backward compatibility hacks.
-     */
-    MixedContent asMixedContent() {
-        MixedContent mixedContent = new MixedContent();
-        if (count != 0) {
-            TemplateElement first = buffer[0];
-            mixedContent.setChildren(this);
-            mixedContent.setLocation(first.getTemplate(), first, getLast());
-        }
-        return mixedContent;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateElementsToVisit.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateElementsToVisit.java b/src/main/java/org/apache/freemarker/core/ast/TemplateElementsToVisit.java
deleted file mode 100644
index 58b22d6..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateElementsToVisit.java
+++ /dev/null
@@ -1,48 +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.Collection;
-import java.util.Collections;
-
-/**
- * Used as the return value of {@link TemplateElement#accept(Environment)} when the invoked element has nested elements
- * to invoke. It would be more natural to invoke child elements before returning from
- * {@link TemplateElement#accept(Environment)}, however, if there's nothing to do after the child elements were invoked,
- * that would mean wasting stack space.
- * 
- * @since 2.3.24
- */
-class TemplateElementsToVisit {
-
-    private final Collection<TemplateElement> templateElements;
-
-    TemplateElementsToVisit(Collection<TemplateElement> templateElements) {
-        this.templateElements = null != templateElements ? templateElements : Collections.<TemplateElement> emptyList();
-    }
-
-    TemplateElementsToVisit(TemplateElement nestedBlock) {
-        this(Collections.singleton(nestedBlock));
-    }
-
-    Collection<TemplateElement> getTemplateElements() {
-        return templateElements;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateFormatUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateFormatUtil.java b/src/main/java/org/apache/freemarker/core/ast/TemplateFormatUtil.java
deleted file mode 100644
index 6e7e90d..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateFormatUtil.java
+++ /dev/null
@@ -1,76 +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.Date;
-
-import org.apache.freemarker.core.model.ObjectWrapper;
-import org.apache.freemarker.core.model.TemplateDateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateNumberModel;
-
-/**
- * Utility classes for implementing {@link TemplateValueFormat}-s.
- * 
- * @since 2.3.24 
- */
-public final class TemplateFormatUtil {
-    
-    private TemplateFormatUtil() {
-        // Not meant to be instantiated
-    }
-
-    public static void checkHasNoParameters(String params) throws InvalidFormatParametersException
-             {
-        if (params.length() != 0) {
-            throw new InvalidFormatParametersException(
-                    "This number format doesn't support any parameters.");
-        }
-    }
-
-    /**
-     * Utility method to extract the {@link Number} from an {@link TemplateNumberModel}, and throws
-     * {@link TemplateModelException} with a standard error message if that's {@code null}. {@link TemplateNumberModel}
-     * that store {@code null} are in principle not allowed, and so are considered to be bugs in the
-     * {@link ObjectWrapper} or {@link TemplateNumberModel} implementation.
-     */
-    public static Number getNonNullNumber(TemplateNumberModel numberModel)
-            throws TemplateModelException, UnformattableValueException {
-        Number number = numberModel.getAsNumber();
-        if (number == null) {
-            throw EvalUtil.newModelHasStoredNullException(Number.class, numberModel, null);
-        }
-        return number;
-    }
-
-    /**
-     * Utility method to extract the {@link Date} from an {@link TemplateDateModel}, and throw
-     * {@link TemplateModelException} with a standard error message if that's {@code null}. {@link TemplateDateModel}
-     * that store {@code null} are in principle not allowed, and so are considered to be bugs in the
-     * {@link ObjectWrapper} or {@link TemplateNumberModel} implementation.
-     */
-    public static Date getNonNullDate(TemplateDateModel dateModel) throws TemplateModelException {
-        Date date = dateModel.getAsDate();
-        if (date == null) {
-            throw EvalUtil.newModelHasStoredNullException(Date.class, dateModel, null);
-        }
-        return date;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateHTMLOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateHTMLOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/TemplateHTMLOutputModel.java
deleted file mode 100644
index 0e5c93d..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateHTMLOutputModel.java
+++ /dev/null
@@ -1,40 +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;
-
-/**
- * Stores HTML markup to be printed; used with {@link HTMLOutputFormat}.
- * 
- * @since 2.3.24
- */
-public final class TemplateHTMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateHTMLOutputModel> {
-    
-    /**
-     * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}.
-     */
-    TemplateHTMLOutputModel(String plainTextContent, String markupContent) {
-        super(plainTextContent, markupContent);
-    }
-
-    @Override
-    public HTMLOutputFormat getOutputFormat() {
-        return HTMLOutputFormat.INSTANCE;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateMarkupOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateMarkupOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/TemplateMarkupOutputModel.java
deleted file mode 100644
index 282a358..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateMarkupOutputModel.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;
-
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateScalarModel;
-
-/**
- * "markup output" template language data-type; stores markup (some kind of "rich text" / structured format, as opposed
- * to plain text) that meant to be printed as template output. This type is related to the {@link OutputFormat}
- * mechanism. Values of this kind are exempt from {@link OutputFormat}-based automatic escaping.
- * 
- * <p>
- * Each implementation of this type has a {@link OutputFormat} subclass pair, whose singleton instance is returned by
- * {@link #getOutputFormat()}. See more about how markup output values work at {@link OutputFormat}.
- * 
- * <p>
- * Note that {@link TemplateMarkupOutputModel}-s are by design not treated like {@link TemplateScalarModel}-s, and so
- * the implementations of this interface usually shouldn't implement {@link TemplateScalarModel}. (Because, operations
- * applicable on plain strings, like converting to upper case, substringing, etc., can corrupt markup.) If the template
- * author wants to pass in the "source" of the markup as string somewhere, he should use {@code ?markup_string}.
- * 
- * @param <MO>
- *            Refers to the interface's own type, which is useful in interfaces that extend
- *            {@link TemplateMarkupOutputModel} (Java Generics trick).
- * 
- * @since 2.3.24
- */
-public interface TemplateMarkupOutputModel<MO extends TemplateMarkupOutputModel<MO>> extends TemplateModel {
-
-    /**
-     * Returns the singleton {@link OutputFormat} object that implements the operations for the "markup output" value.
-     */
-    MarkupOutputFormat<MO> getOutputFormat();
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormat.java b/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormat.java
deleted file mode 100644
index b4d4051..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormat.java
+++ /dev/null
@@ -1,90 +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.text.NumberFormat;
-
-import org.apache.freemarker.core.model.TemplateDateModel;
-import org.apache.freemarker.core.model.TemplateModelException;
-import org.apache.freemarker.core.model.TemplateNumberModel;
-
-/**
- * Represents a number format; used in templates for formatting and parsing with that format. This is similar to Java's
- * {@link NumberFormat}, but made to fit the requirements of FreeMarker. Also, it makes easier to define formats that
- * can't be represented with Java's existing {@link NumberFormat} implementations.
- * 
- * <p>
- * Implementations need not be thread-safe if the {@link TemplateNumberFormatFactory} doesn't recycle them among
- * different {@link Environment}-s. As far as FreeMarker's concerned, instances are bound to a single
- * {@link Environment}, and {@link Environment}-s are thread-local objects.
- * 
- * @since 2.3.24
- */
-public abstract class TemplateNumberFormat extends TemplateValueFormat {
-
-    /**
-     * @param numberModel
-     *            The number to format; not {@code null}. Most implementations will just work with the return value of
-     *            {@link TemplateDateModel#getAsDate()}, but some may format differently depending on the properties of
-     *            a custom {@link TemplateDateModel} implementation.
-     *            
-     * @return The number as text, with no escaping (like no HTML escaping); can't be {@code null}.
-     * 
-     * @throws TemplateValueFormatException
-     *             If any problem occurs while parsing/getting the format. Notable subclass:
-     *             {@link UnformattableValueException}.
-     * @throws TemplateModelException
-     *             Exception thrown by the {@code dateModel} object when calling its methods.
-     */
-    public abstract String formatToPlainText(TemplateNumberModel numberModel)
-            throws TemplateValueFormatException, TemplateModelException;
-
-    /**
-     * Formats the model to markup instead of to plain text if the result markup will be more than just plain text
-     * escaped, otherwise falls back to formatting to plain text. If the markup result would be just the result of
-     * {@link #formatToPlainText(TemplateNumberModel)} escaped, it must return the {@link String} that
-     * {@link #formatToPlainText(TemplateNumberModel)} does.
-     * 
-     * <p>
-     * The implementation in {@link TemplateNumberFormat} simply calls {@link #formatToPlainText(TemplateNumberModel)}.
-     * 
-     * @return A {@link String} or a {@link TemplateMarkupOutputModel}; not {@code null}.
-     */
-    public Object format(TemplateNumberModel numberModel)
-            throws TemplateValueFormatException, TemplateModelException {
-        return formatToPlainText(numberModel);
-    }
-    
-    /**
-     * Tells if this formatter should be re-created if the locale changes.
-     */
-    public abstract boolean isLocaleBound();
-
-    /**
-     * This method is reserved for future purposes; currently it always throws {@link ParsingNotSupportedException}. We
-     * don't yet support number parsing with {@link TemplateNumberFormat}-s, because currently FTL parses strings to
-     * number with the {@link ArithmeticEngine} ({@link TemplateNumberFormat} were only introduced in 2.3.24). If it
-     * will be support, it will be similar to {@link TemplateDateFormat#parse(String, int)}.
-     */
-    public final Object parse(String s) throws TemplateValueFormatException {
-        throw new ParsingNotSupportedException("Number formats currenly don't support parsing");
-    }
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormatFactory.java b/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormatFactory.java
deleted file mode 100644
index 79311bf..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateNumberFormatFactory.java
+++ /dev/null
@@ -1,64 +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.Locale;
-
-import org.apache.freemarker.core.Configuration;
-
-/**
- * Factory for a certain kind of number formatting ({@link TemplateNumberFormat}). Usually a singleton (one-per-VM or
- * one-per-{@link Configuration}), and so must be thread-safe.
- * 
- * @see Configurable#setCustomNumberFormats(java.util.Map)
- * 
- * @since 2.3.24
- */
-public abstract class TemplateNumberFormatFactory extends TemplateValueFormatFactory {
-
-    /**
-     * Returns a formatter for the given parameters.
-     * 
-     * <p>
-     * The returned formatter can be a new instance or a reused (cached) instance. Note that {@link Environment} itself
-     * caches the returned instances, though that cache is lost with the {@link Environment} (i.e., when the top-level
-     * template execution ends), also it might flushes lot of entries if the locale or time zone is changed during
-     * template execution. So caching on the factory level is still useful, unless creating the formatters is
-     * sufficiently cheap.
-     * 
-     * @param params
-     *            The string that further describes how the format should look. For example, when the
-     *            {@link Configurable#getNumberFormat() numberFormat} is {@code "@fooBar 1, 2"}, then it will be
-     *            {@code "1, 2"} (and {@code "@fooBar"} selects the factory). The format of this string is up to the
-     *            {@link TemplateNumberFormatFactory} implementation. Not {@code null}, often an empty string.
-     * @param locale
-     *            The locale to format for. Not {@code null}. The resulting format must be bound to this locale
-     *            forever (i.e. locale changes in the {@link Environment} must not be followed).
-     * @param env
-     *            The runtime environment from which the formatting was called. This is mostly meant to be used for
-     *            {@link Environment#setCustomState(Object, Object)}/{@link Environment#getCustomState(Object)}.
-     *            
-     * @throws TemplateValueFormatException
-     *             if any problem occurs while parsing/getting the format. Notable subclasses:
-     *             {@link InvalidFormatParametersException} if the {@code params} is malformed.
-     */
-    public abstract TemplateNumberFormat get(String params, Locale locale, Environment env)
-            throws TemplateValueFormatException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateObject.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateObject.java b/src/main/java/org/apache/freemarker/core/ast/TemplateObject.java
deleted file mode 100644
index bd89f4b..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateObject.java
+++ /dev/null
@@ -1,243 +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.Template;
-
-/**
- * <b>Internal API - subject to change:</b> Represent a node in the parsed template (either a {@link Expression} or a
- * {@link TemplateElement}).
- * 
- * @see TemplateElement
- * @see Expression
- * 
- * @deprecated This is an internal FreeMarker API with no backward compatibility guarantees, so you shouldn't depend on
- *             it.
- */
-@Deprecated
-public abstract class TemplateObject {
-    
-    private Template template;
-    int beginColumn, beginLine, endColumn, endLine;
-    
-    /** This is needed for an ?eval hack; the expression AST nodes will be the descendants of the template, however,
-     *  we can't give their position in the template, only in the dynamic string that's evaluated. That's signaled
-     *  by a negative line numbers, starting from this constant as line 1. */
-    static final int RUNTIME_EVAL_LINE_DISPLACEMENT = -1000000000;  
-
-    final void setLocation(Template template, Token begin, Token end) {
-        setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
-    }
-
-    final void setLocation(Template template, Token tagBegin, Token tagEnd, TemplateElements children) {
-        TemplateElement lastChild = children.getLast();
-        if (lastChild != null) {
-            // [<#if exp>children]<#else>
-            setLocation(template, tagBegin, lastChild);
-        } else {
-            // [<#if exp>]<#else>
-            setLocation(template, tagBegin, tagEnd);
-        }
-    }
-    
-    final void setLocation(Template template, Token begin, TemplateObject end) {
-        setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
-    }
-    
-    final void setLocation(Template template, TemplateObject begin, Token end) {
-        setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
-    }
-
-    final void setLocation(Template template, TemplateObject begin, TemplateObject end) {
-        setLocation(template, begin.beginColumn, begin.beginLine, end.endColumn, end.endLine);
-    }
-
-    void setLocation(Template template, int beginColumn, int beginLine, int endColumn, int endLine) {
-        this.template = template;
-        this.beginColumn = beginColumn;
-        this.beginLine = beginLine;
-        this.endColumn = endColumn;
-        this.endLine = endLine;
-    }
-    
-    public final int getBeginColumn() {
-        return beginColumn;
-    }
-
-    public final int getBeginLine() {
-        return beginLine;
-    }
-
-    public final int getEndColumn() {
-        return endColumn;
-    }
-
-    public final int getEndLine() {
-        return endLine;
-    }
-
-    /**
-     * Returns a string that indicates
-     * where in the template source, this object is.
-     */
-    public String getStartLocation() {
-        return MessageUtil.formatLocationForEvaluationError(template, beginLine, beginColumn);
-    }
-
-    /**
-     * As of 2.3.20. the same as {@link #getStartLocation}. Meant to be used where there's a risk of XSS
-     * when viewing error messages.
-     */
-    public String getStartLocationQuoted() {
-        return getStartLocation();
-    }
-
-    public String getEndLocation() {
-        return MessageUtil.formatLocationForEvaluationError(template, endLine, endColumn);
-    }
-
-    /**
-     * As of 2.3.20. the same as {@link #getEndLocation}. Meant to be used where there's a risk of XSS
-     * when viewing error messages.
-     */
-    public String getEndLocationQuoted() {
-        return getEndLocation();
-    }
-    
-    public final String getSource() {
-        String s;
-        if (template != null) {
-            s = template.getSource(beginColumn, beginLine, endColumn, endLine);
-        } else {
-            s = null;
-        }
-
-        // Can't just return null for backward-compatibility... 
-        return s != null ? s : getCanonicalForm();
-    }
-
-    @Override
-    public String toString() {
-        String s;
-    	try {
-    		s = getSource();
-    	} catch (Exception e) { // REVISIT: A bit of a hack? (JR)
-    	    s = null;
-    	}
-    	return s != null ? s : getCanonicalForm();
-    }
-
-    /**
-     * @return whether the point in the template file specified by the 
-     * column and line numbers is contained within this template object.
-     */
-    public boolean contains(int column, int line) {
-        if (line < beginLine || line > endLine) {
-            return false;
-        }
-        if (line == beginLine) {
-            if (column < beginColumn) {
-                return false;
-            }
-        }
-        if (line == endLine) {
-            if (column > endColumn) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public Template getTemplate() {
-        return template;
-    }
-    
-    TemplateObject copyLocationFrom(TemplateObject from) {
-        template = from.template;
-        beginColumn = from.beginColumn;
-        beginLine = from.beginLine;
-        endColumn = from.endColumn;
-        endLine = from.endLine;
-        return this;
-    }    
-
-    /**
-     * FTL generated from the AST of the node, which must be parseable to an AST that does the same as the original
-     * source, assuming we turn off automatic white-space removal when parsing the canonical form.
-     * 
-     * @see TemplateElement#getDescription()
-     * @see #getNodeTypeSymbol()
-     */
-    abstract public String getCanonicalForm();
-    
-    /**
-     * A very sort single-line string that describes what kind of AST node this is, without describing any 
-     * embedded expression or child element. Examples: {@code "#if"}, {@code "+"}, <tt>"${...}</tt>. These values should
-     * be suitable as tree node labels in a tree view. Yet, they should be consistent and complete enough so that an AST
-     * that is equivalent with the original could be reconstructed from the tree view. Thus, for literal values that are
-     * leaf nodes the symbols should be the canonical form of value.
-     * 
-     * Note that {@link TemplateElement#getDescription()} has similar role, only it doesn't go under the element level
-     * (i.e. down to the expression level), instead it always prints the embedded expressions itself.
-     * 
-     * @see #getCanonicalForm()
-     * @see TemplateElement#getDescription()
-     */
-    abstract String getNodeTypeSymbol();
-    
-    /**
-     * Returns highest valid parameter index + 1. So one should scan indexes with {@link #getParameterValue(int)}
-     * starting from 0 up until but excluding this. For example, for the binary "+" operator this will give 2, so the
-     * legal indexes are 0 and 1. Note that if a parameter is optional in a template-object-type and happens to be
-     * omitted in an instance, this will still return the same value and the value of that parameter will be
-     * {@code null}.
-     */
-    abstract int getParameterCount();
-    
-    /**
-     * Returns the value of the parameter identified by the index. For example, the binary "+" operator will have an
-     * LHO {@link Expression} at index 0, and and RHO {@link Expression} at index 1. Or, the binary "." operator will
-     * have an LHO {@link Expression} at index 0, and an RHO {@link String}(!) at index 1. Or, the {@code #include}
-     * directive will have a path {@link Expression} at index 0, a "parse" {@link Expression} at index 1, etc.
-     * 
-     * <p>The index value doesn't correspond to the source-code location in general. It's an arbitrary identifier
-     * that corresponds to the role of the parameter instead. This also means that when a parameter is omitted, the
-     * index of the other parameters won't shift.
-     *
-     *  @return {@code null} or any kind of {@link Object}, very often an {@link Expression}. However, if there's
-     *      a {@link TemplateObject} stored inside the returned value, it must itself be be a {@link TemplateObject}
-     *      too, otherwise the AST couldn't be (easily) fully traversed. That is, non-{@link TemplateObject} values
-     *      can only be used for leafs. 
-     *  
-     *  @throws IndexOutOfBoundsException if {@code idx} is less than 0 or not less than {@link #getParameterCount()}. 
-     */
-    abstract Object getParameterValue(int idx);
-
-    /**
-     *  Returns the role of the parameter at the given index, like {@link ParameterRole#LEFT_HAND_OPERAND}.
-     *  
-     *  As of this writing (2013-06-17), for directive parameters it will always give {@link ParameterRole#UNKNOWN},
-     *  because there was no need to be more specific so far. This should be improved as need.
-     *  
-     *  @throws IndexOutOfBoundsException if {@code idx} is less than 0 or not less than {@link #getParameterCount()}. 
-     */
-    abstract ParameterRole getParameterRole(int idx);
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessor.java b/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessor.java
deleted file mode 100644
index 09c6b36..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessor.java
+++ /dev/null
@@ -1,34 +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.Template;
-
-
-/**
- * Note yet public; will change in 2.4 (as it has to process {@code UnboundTemplate}-s).
- */
-abstract class TemplatePostProcessor {
-
-    public abstract void postProcess(Template e) throws TemplatePostProcessorException;
-    
-    // TODO: getPriority, getPhase, getMustBeBefore, getMustBeAfter
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessorException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessorException.java b/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessorException.java
deleted file mode 100644
index f8ac2b3..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplatePostProcessorException.java
+++ /dev/null
@@ -1,35 +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;
-
-/**
- * Not yet public; subject to change.
- */
-class TemplatePostProcessorException extends Exception {
-
-    public TemplatePostProcessorException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public TemplatePostProcessorException(String message) {
-        super(message);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateRTFOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateRTFOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/TemplateRTFOutputModel.java
deleted file mode 100644
index e7b102f..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateRTFOutputModel.java
+++ /dev/null
@@ -1,40 +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;
-
-/**
- * Stores RTF markup to be printed; used with {@link RTFOutputFormat}.
- * 
- * @since 2.3.24
- */
-public final class TemplateRTFOutputModel extends CommonTemplateMarkupOutputModel<TemplateRTFOutputModel> {
-    
-    /**
-     * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}.
-     */
-    TemplateRTFOutputModel(String plainTextContent, String markupContent) {
-        super(plainTextContent, markupContent);
-    }
-
-    @Override
-    public RTFOutputFormat getOutputFormat() {
-        return RTFOutputFormat.INSTANCE;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateSpecifiedEncodingHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateSpecifiedEncodingHandler.java b/src/main/java/org/apache/freemarker/core/ast/TemplateSpecifiedEncodingHandler.java
deleted file mode 100644
index 2ad0f23..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateSpecifiedEncodingHandler.java
+++ /dev/null
@@ -1,61 +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.Template;
-import org.apache.freemarker.core.Template.WrongEncodingException;
-
-/**
- * Specifies the behavior when the template specifies its own encoding (via {@code <#ftl encoding=...>}) in the template
- * content itself, and also when it doesn't do that.
- */
-public interface TemplateSpecifiedEncodingHandler {
-    
-    TemplateSpecifiedEncodingHandler DEFAULT = new TemplateSpecifiedEncodingHandler() {
-
-        @Override
-        public void handle(String templateSpecificEncoding, String constructorSpecifiedEncoding)
-                throws WrongEncodingException {
-            if (constructorSpecifiedEncoding != null && templateSpecificEncoding != null
-                    && !constructorSpecifiedEncoding.equalsIgnoreCase(templateSpecificEncoding)) {
-                throw new Template.WrongEncodingException(templateSpecificEncoding, constructorSpecifiedEncoding);
-            }
-        }
-        
-    };
-
-    /**
-     * Called once during template parsing, either when the {@code #ftl} directive is processed, or near the beginning
-     * of the template processing when there's no {@code #ftl} directive in the template.
-     * 
-     * @param templateSpecificEncoding
-     *            The encoding specified via {@code <#ftl encoding=...>}, or {@code null} if that was missing (either
-     *            the {@code encoding} parameter or the whole {@code #ftl} directive).
-     * @param constructorSpecifiedEncoding
-     *            The encoding specified to the {@link Template} constructor; also the value of
-     *            {@link Template#getEncoding()}. If there was an encoding used for decoding the template file, it
-     *            should be that, or if there was no encoding, it should be {@code null}.
-     * 
-     * @throws WrongEncodingException
-     *             If the template "file" has to be re-read and the {@link Template} re-created with the encoding
-     *             specified in the constructor of {@link WrongEncodingException}.
-     */
-    void handle(String templateSpecificEncoding, String constructorSpecifiedEncoding) throws WrongEncodingException;
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormat.java b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormat.java
deleted file mode 100644
index 2d73752..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormat.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;
-
-/**
- * Superclass of all value format objects; objects that convert values to strings, or parse strings.
- * 
- * @since 2.3.24
- */
-public abstract class TemplateValueFormat {
-
-    /**
-     * Meant to be used in error messages to tell what format the parsed string didn't fit.
-     */
-    public abstract String getDescription();
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatException.java b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatException.java
deleted file mode 100644
index 1493619..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatException.java
+++ /dev/null
@@ -1,37 +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;
-
-/**
- * Error while getting, creating or applying {@link TemplateValueFormat}-s (including its subclasses, like
- * {@link TemplateNumberFormat}).
- * 
- * @since 2.3.24
- */
-public abstract class TemplateValueFormatException extends Exception {
-
-    public TemplateValueFormatException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public TemplateValueFormatException(String message) {
-        super(message);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatFactory.java b/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatFactory.java
deleted file mode 100644
index fd9018e..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateValueFormatFactory.java
+++ /dev/null
@@ -1,28 +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;
-
-/**
- * Superclass of all format factories.
- * 
- * @since 2.3.24
- */
-public abstract class TemplateValueFormatFactory {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateXHTMLOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateXHTMLOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/TemplateXHTMLOutputModel.java
deleted file mode 100644
index 18b3c6c..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateXHTMLOutputModel.java
+++ /dev/null
@@ -1,40 +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;
-
-/**
- * Stores HTML markup to be printed; used with {@link HTMLOutputFormat}.
- * 
- * @since 2.3.24
- */
-public final class TemplateXHTMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateXHTMLOutputModel> {
-    
-    /**
-     * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}.
-     */
-    TemplateXHTMLOutputModel(String plainTextContent, String markupContent) {
-        super(plainTextContent, markupContent);
-    }
-
-    @Override
-    public XHTMLOutputFormat getOutputFormat() {
-        return XHTMLOutputFormat.INSTANCE;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TemplateXMLOutputModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TemplateXMLOutputModel.java b/src/main/java/org/apache/freemarker/core/ast/TemplateXMLOutputModel.java
deleted file mode 100644
index f29996d..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TemplateXMLOutputModel.java
+++ /dev/null
@@ -1,40 +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;
-
-/**
- * Stores XML markup to be printed; used with {@link XMLOutputFormat}.
- * 
- * @since 2.3.24
- */
-public final class TemplateXMLOutputModel extends CommonTemplateMarkupOutputModel<TemplateXMLOutputModel> {
-    
-    /**
-     * See {@link CommonTemplateMarkupOutputModel#CommonTemplateMarkupOutputModel(String, String)}.
-     */
-    TemplateXMLOutputModel(String plainTextContent, String markupContent) {
-        super(plainTextContent, markupContent);
-    }
-
-    @Override
-    public XMLOutputFormat getOutputFormat() {
-        return XMLOutputFormat.INSTANCE;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7d784b2b/src/main/java/org/apache/freemarker/core/ast/TextBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/TextBlock.java b/src/main/java/org/apache/freemarker/core/ast/TextBlock.java
deleted file mode 100644
index a0e880e..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/TextBlock.java
+++ /dev/null
@@ -1,409 +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.util._CollectionUtil;
-import org.apache.freemarker.core.util._StringUtil;
-
-/**
- * A TemplateElement representing a block of plain text.
- * 
- * @deprecated This is an internal API; don't use it.
- */
-public final class TextBlock extends TemplateElement {
-    
-    // We're using char[] instead of String for storing the text block because
-    // Writer.write(String) involves copying the String contents to a char[] 
-    // using String.getChars(), and then calling Writer.write(char[]). By
-    // using Writer.write(char[]) directly, we avoid array copying on each 
-    // write. 
-    private char[] text;
-    private final boolean unparsed;
-
-    public TextBlock(String text) {
-        this(text, false);
-    }
-
-    public TextBlock(String text, boolean unparsed) {
-        this(text.toCharArray(), unparsed);
-    }
-
-    TextBlock(char[] text, boolean unparsed) {
-        this.text = text;
-        this.unparsed = unparsed;
-    }
-    
-    void replaceText(String text) {
-        this.text = text.toCharArray();
-    }
-
-    /**
-     * Simply outputs the text.
-     * 
-     * @deprecated This is an internal API; don't call or override it.
-     */
-    @Override
-    public TemplateElement[] accept(Environment env)
-    throws IOException {
-        env.getOut().write(text);
-        return null;
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        if (canonical) {
-            String text = new String(this.text);
-            if (unparsed) {
-                return "<#noparse>" + text + "</#noparse>";
-            }
-            return text;
-        } else {
-            return "text " + _StringUtil.jQuote(new String(text));
-        }
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return "#text";
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 1;
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        if (idx != 0) throw new IndexOutOfBoundsException();
-        return new String(text);
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        if (idx != 0) throw new IndexOutOfBoundsException();
-        return ParameterRole.CONTENT;
-    }
-
-    @Override
-    TemplateElement postParseCleanup(boolean stripWhitespace) {
-        if (text.length == 0) return this;
-        int openingCharsToStrip = 0, trailingCharsToStrip = 0;
-        boolean deliberateLeftTrim = deliberateLeftTrim();
-        boolean deliberateRightTrim = deliberateRightTrim();
-        if (!stripWhitespace || text.length == 0 ) {
-            return this;
-        }
-        TemplateElement parentElement = getParentElement();
-        if (isTopLevelTextIfParentIs(parentElement) && previousSibling() == null) {
-            return this;
-        }
-        if (!deliberateLeftTrim) {
-            trailingCharsToStrip = trailingCharsToStrip();
-        }
-        if (!deliberateRightTrim) {
-            openingCharsToStrip = openingCharsToStrip();
-        }
-        if (openingCharsToStrip == 0 && trailingCharsToStrip == 0) {
-            return this;
-        }
-        text = substring(text, openingCharsToStrip, text.length - trailingCharsToStrip);
-        if (openingCharsToStrip > 0) {
-            beginLine++;
-            beginColumn = 1;
-        }
-        if (trailingCharsToStrip > 0) {
-            endColumn = 0;
-        }
-        return this;
-    }
-    
-    /**
-     * Scans forward the nodes on the same line to see whether there is a 
-     * deliberate left trim in effect. Returns true if the left trim was present.
-     */
-    private boolean deliberateLeftTrim() {
-        boolean result = false;
-        for (TemplateElement elem = nextTerminalNode();
-             elem != null && elem.beginLine == endLine;
-             elem = elem.nextTerminalNode()) {
-            if (elem instanceof TrimInstruction) {
-                TrimInstruction ti = (TrimInstruction) elem;
-                if (!ti.left && !ti.right) {
-                    result = true;
-                }
-                if (ti.left) {
-                    result = true;
-                    int lastNewLineIndex = lastNewLineIndex();
-                    if (lastNewLineIndex >= 0  || beginColumn == 1) {
-                        char[] firstPart = substring(text, 0, lastNewLineIndex + 1);
-                        char[] lastLine = substring(text, 1 + lastNewLineIndex); 
-                        if (_StringUtil.isTrimmableToEmpty(lastLine)) {
-                            text = firstPart;
-                            endColumn = 0;
-                        } else {
-                            int i = 0;
-                            while (Character.isWhitespace(lastLine[i])) {
-                                i++;
-                            }
-                            char[] printablePart = substring(lastLine, i);
-                            text = concat(firstPart, printablePart);
-                        }
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Checks for the presence of a t or rt directive on the 
-     * same line. Returns true if the right trim directive was present.
-     */
-    private boolean deliberateRightTrim() {
-        boolean result = false;
-        for (TemplateElement elem = prevTerminalNode();
-             elem != null && elem.endLine == beginLine;
-             elem = elem.prevTerminalNode()) {
-            if (elem instanceof TrimInstruction) {
-                TrimInstruction ti = (TrimInstruction) elem;
-                if (!ti.left && !ti.right) {
-                    result = true;
-                }
-                if (ti.right) {
-                    result = true;
-                    int firstLineIndex = firstNewLineIndex() + 1;
-                    if (firstLineIndex == 0) {
-                        return false;
-                    }
-                    if (text.length > firstLineIndex 
-                        && text[firstLineIndex - 1] == '\r' 
-                        && text[firstLineIndex] == '\n') {
-                        firstLineIndex++;
-                    }
-                    char[] trailingPart = substring(text, firstLineIndex);
-                    char[] openingPart = substring(text, 0, firstLineIndex);
-                    if (_StringUtil.isTrimmableToEmpty(openingPart)) {
-                        text = trailingPart;
-                        beginLine++;
-                        beginColumn = 1;
-                    } else {
-                        int lastNonWS = openingPart.length - 1;
-                        while (Character.isWhitespace(text[lastNonWS])) {
-                            lastNonWS--;
-                        }
-                        char[] printablePart = substring(text, 0, lastNonWS + 1);
-                        if (_StringUtil.isTrimmableToEmpty(trailingPart)) {
-                        // THIS BLOCK IS HEINOUS! THERE MUST BE A BETTER WAY! REVISIT (JR)
-                            boolean trimTrailingPart = true;
-                            for (TemplateElement te = nextTerminalNode();
-                                 te != null && te.beginLine == endLine;
-                                 te = te.nextTerminalNode()) {
-                                if (te.heedsOpeningWhitespace()) {
-                                    trimTrailingPart = false;
-                                }
-                                if (te instanceof TrimInstruction && ((TrimInstruction) te).left) {
-                                    trimTrailingPart = true;
-                                    break;
-                                }
-                            }
-                            if (trimTrailingPart) trailingPart = _CollectionUtil.EMPTY_CHAR_ARRAY;
-                        }
-                        text = concat(printablePart, trailingPart);
-                    }
-                }
-            }
-        }
-        return result;
-    }
-    
-    private int firstNewLineIndex() {
-        char[] text = this.text;
-        for (int i = 0; i < text.length; i++) {
-            char c = text[i];
-            if (c == '\r' || c == '\n' ) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    private int lastNewLineIndex() {
-        char[] text = this.text;
-        for (int i = text.length - 1; i >= 0; i--) {
-            char c = text[i];
-            if (c == '\r' || c == '\n' ) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * figures out how many opening whitespace characters to strip
-     * in the post-parse cleanup phase.
-     */
-    private int openingCharsToStrip() {
-        int newlineIndex = firstNewLineIndex();
-        if (newlineIndex == -1 && beginColumn != 1) {
-            return 0;
-        }
-        ++newlineIndex;
-        if (text.length > newlineIndex) {
-            if (newlineIndex > 0 && text[newlineIndex - 1] == '\r' && text[newlineIndex] == '\n') {
-                ++newlineIndex;
-            }
-        }
-        if (!_StringUtil.isTrimmableToEmpty(text, 0, newlineIndex)) {
-            return 0;
-        }
-        // We look at the preceding elements on the line to see if we should
-        // strip the opening newline and any whitespace preceding it.
-        for (TemplateElement elem = prevTerminalNode();
-             elem != null && elem.endLine == beginLine;
-             elem = elem.prevTerminalNode()) {
-            if (elem.heedsOpeningWhitespace()) {
-                return 0;
-            }
-        }
-        return newlineIndex;
-    }
-
-    /**
-     * figures out how many trailing whitespace characters to strip
-     * in the post-parse cleanup phase.
-     */
-    private int trailingCharsToStrip() {
-        int lastNewlineIndex = lastNewLineIndex();
-        if (lastNewlineIndex == -1 && beginColumn != 1) {
-            return 0;
-        }
-        if (!_StringUtil.isTrimmableToEmpty(text, lastNewlineIndex + 1)) {
-            return 0;
-        }
-        // We look at the elements afterward on the same line to see if we should
-        // strip any whitespace after the last newline
-        for (TemplateElement elem = nextTerminalNode();
-             elem != null && elem.beginLine == endLine;
-             elem = elem.nextTerminalNode()) {
-            if (elem.heedsTrailingWhitespace()) {
-                return 0;
-            }
-        }
-        return text.length - (lastNewlineIndex + 1);
-    }
-
-    @Override
-    boolean heedsTrailingWhitespace() {
-        if (isIgnorable(true)) {
-            return false;
-        }
-        for (char c : text) {
-            if (c == '\n' || c == '\r') {
-                return false;
-            }
-            if (!Character.isWhitespace(c)) {
-                return true;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    boolean heedsOpeningWhitespace() {
-        if (isIgnorable(true)) {
-            return false;
-        }
-        for (int i = text.length - 1; i >= 0; i--) {
-            char c = text[i];
-            if (c == '\n' || c == '\r') {
-                return false;
-            }
-            if (!Character.isWhitespace(c)) {
-                return true;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    boolean isIgnorable(boolean stripWhitespace) {
-        if (text == null || text.length == 0) {
-            return true;
-        }
-        if (stripWhitespace) {
-            if (!_StringUtil.isTrimmableToEmpty(text)) {
-                return false;
-            }
-            TemplateElement parentElement = getParentElement();
-            boolean atTopLevel = isTopLevelTextIfParentIs(parentElement);
-            TemplateElement prevSibling = previousSibling();
-            TemplateElement nextSibling = nextSibling();
-            return ((prevSibling == null && atTopLevel) || nonOutputtingType(prevSibling))
-                    && ((nextSibling == null && atTopLevel) || nonOutputtingType(nextSibling));
-        } else {
-            return false;
-        }
-    }
-
-    private boolean isTopLevelTextIfParentIs(TemplateElement parentElement) {
-        return parentElement == null
-                || parentElement.getParentElement() == null && parentElement instanceof MixedContent;
-    }
-    
-
-    private boolean nonOutputtingType(TemplateElement element) {
-        return (element instanceof Macro ||
-                element instanceof Assignment || 
-                element instanceof AssignmentInstruction ||
-                element instanceof PropertySetting ||
-                element instanceof LibraryLoad ||
-                element instanceof Comment);
-    }
-
-    private static char[] substring(char[] c, int from, int to) {
-        char[] c2 = new char[to - from];
-        System.arraycopy(c, from, c2, 0, c2.length);
-        return c2;
-    }
-    
-    private static char[] substring(char[] c, int from) {
-        return substring(c, from, c.length);
-    }
-    
-    private static char[] concat(char[] c1, char[] c2) {
-        char[] c = new char[c1.length + c2.length];
-        System.arraycopy(c1, 0, c, 0, c1.length);
-        System.arraycopy(c2, 0, c, c1.length, c2.length);
-        return c;
-    }
-    
-    @Override
-    boolean isOutputCacheable() {
-        return true;
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-    
-}


Mime
View raw message