freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Removed long deprecated <#transform ...>...</#transform> directive.
Date Fri, 03 Mar 2017 20:53:04 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 b67faaa7f -> 9047d13b9


Removed long deprecated <#transform ...>...</#transform> directive.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/9047d13b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/9047d13b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/9047d13b

Branch: refs/heads/3
Commit: 9047d13b95b89cee481aa8e4e61bb4cdcf9f1c57
Parents: b67faaa
Author: ddekany <ddekany@apache.org>
Authored: Fri Mar 3 21:52:55 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Fri Mar 3 21:52:55 2017 +0100

----------------------------------------------------------------------
 .../apache/freemarker/core/ASTDirTransform.java | 162 -------------------
 .../apache/freemarker/core/ASTDirective.java    |   1 -
 .../apache/freemarker/core/ParseException.java  |   3 -
 src/main/javacc/FTL.jj                          |  42 -----
 src/manual/en_US/FM3-CHANGE-LOG.txt             |   5 +-
 .../test/templatesuite/templates/interpret.ftl  |   6 +-
 .../test/templatesuite/templates/newlines2.ftl  |   4 +-
 .../templates/string-builtins1.ftl              |   2 +-
 8 files changed, 9 insertions(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/main/java/org/apache/freemarker/core/ASTDirTransform.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ASTDirTransform.java b/src/main/java/org/apache/freemarker/core/ASTDirTransform.java
deleted file mode 100644
index 2789ae4..0000000
--- a/src/main/java/org/apache/freemarker/core/ASTDirTransform.java
+++ /dev/null
@@ -1,162 +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;
-
-import java.io.IOException;
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.freemarker.core.model.TemplateModel;
-import org.apache.freemarker.core.model.TemplateTransformModel;
-
-/**
- * AST directive node: {@code #transform}.
- */
-final class ASTDirTransform extends ASTDirective {
-
-    private ASTExpression transformExpression;
-    Map namedArgs;
-    private transient volatile SoftReference/*List<Map.Entry<String,ASTExpression>>*/
sortedNamedArgsCache;
-
-    ASTDirTransform(ASTExpression transformExpression,
-                   Map namedArgs,
-                   TemplateElements children) {
-        this.transformExpression = transformExpression;
-        this.namedArgs = namedArgs;
-        setChildren(children);
-    }
-
-    @Override
-    ASTElement[] accept(Environment env)
-    throws TemplateException, IOException {
-        TemplateTransformModel ttm = env.getTransform(transformExpression);
-        if (ttm != null) {
-            Map args;
-            if (namedArgs != null && !namedArgs.isEmpty()) {
-                args = new HashMap();
-                for (Iterator it = namedArgs.entrySet().iterator(); it.hasNext(); ) {
-                    Map.Entry entry = (Map.Entry) it.next();
-                    String key = (String) entry.getKey();
-                    ASTExpression valueExp = (ASTExpression) entry.getValue();
-                    TemplateModel value = valueExp.eval(env);
-                    args.put(key, value);
-                }
-            } else {
-                args = Collections.emptyMap();
-            }
-            env.visitAndTransform(getChildBuffer(), ttm, args);
-        } else {
-            TemplateModel tm = transformExpression.eval(env);
-            throw new UnexpectedTypeException(
-                    transformExpression, tm,
-                    "transform", new Class[] { TemplateTransformModel.class }, env);
-        }
-        return null;
-    }
-
-    @Override
-    protected String dump(boolean canonical) {
-        StringBuilder sb = new StringBuilder();
-        if (canonical) sb.append('<');
-        sb.append(getNodeTypeSymbol());
-        sb.append(' ');
-        sb.append(transformExpression);
-        if (namedArgs != null) {
-            for (Iterator it = getSortedNamedArgs().iterator(); it.hasNext(); ) {
-                Map.Entry entry = (Map.Entry) it.next();
-                sb.append(' ');
-                sb.append(entry.getKey());
-                sb.append('=');
-                MessageUtil.appendExpressionAsUntearable(sb, (ASTExpression) entry.getValue());
-            }
-        }
-        if (canonical) {
-            sb.append(">");
-            sb.append(getChildrenCanonicalForm());
-            sb.append("</").append(getNodeTypeSymbol()).append('>');
-        }
-        return sb.toString();
-    }
-    
-    @Override
-    String getNodeTypeSymbol() {
-        return "#transform";
-    }
-    
-    @Override
-    int getParameterCount() {
-        return 1/*nameExp*/ + (namedArgs != null ? namedArgs.size() * 2 : 0);
-    }
-
-    @Override
-    Object getParameterValue(int idx) {
-        if (idx == 0) {
-            return transformExpression;
-        } else if (namedArgs != null && idx - 1 < namedArgs.size() * 2) {
-            Map.Entry namedArg = (Map.Entry) getSortedNamedArgs().get((idx - 1) / 2);
-            return (idx - 1) % 2 == 0 ? namedArg.getKey() : namedArg.getValue();
-        } else {
-            throw new IndexOutOfBoundsException();
-        }
-    }
-
-    @Override
-    ParameterRole getParameterRole(int idx) {
-        if (idx == 0) {
-            return ParameterRole.CALLEE;
-        } else if (idx - 1 < namedArgs.size() * 2) {
-                return (idx - 1) % 2 == 0 ? ParameterRole.ARGUMENT_NAME : ParameterRole.ARGUMENT_VALUE;
-        } else {
-            throw new IndexOutOfBoundsException();
-        }
-    }
-
-    /**
-     * Returns the named args by source-code order; it's not meant to be used during template
execution, too slow for
-     * that!
-     */
-    private List/*<Map.Entry<String, ASTExpression>>*/ getSortedNamedArgs() {
-        Reference ref = sortedNamedArgsCache;
-        if (ref != null) {
-            List res = (List) ref.get();
-            if (res != null) return res;
-        }
-        
-        List res = MiscUtil.sortMapOfExpressions(namedArgs);
-        sortedNamedArgsCache = new SoftReference(res);
-        return res;
-    }
-
-    @Override
-    boolean isNestedBlockRepeater() {
-        return false;
-    }
-
-    @Override
-    boolean isShownInStackTrace() {
-        return true;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/main/java/org/apache/freemarker/core/ASTDirective.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ASTDirective.java b/src/main/java/org/apache/freemarker/core/ASTDirective.java
index c1bf03f..3506036 100644
--- a/src/main/java/org/apache/freemarker/core/ASTDirective.java
+++ b/src/main/java/org/apache/freemarker/core/ASTDirective.java
@@ -89,7 +89,6 @@ abstract class ASTDirective extends ASTElement {
         addName(allNames, lcNames, ccNames, "stop");
         addName(allNames, lcNames, ccNames, "switch");
         addName(allNames, lcNames, ccNames, "t");
-        addName(allNames, lcNames, ccNames, "transform");
         addName(allNames, lcNames, ccNames, "visit");
 
         ALL_BUILT_IN_DIRECTIVE_NAMES = Collections.unmodifiableSet(allNames);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/main/java/org/apache/freemarker/core/ParseException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ParseException.java b/src/main/java/org/apache/freemarker/core/ParseException.java
index 94304d9..dcb0f46 100644
--- a/src/main/java/org/apache/freemarker/core/ParseException.java
+++ b/src/main/java/org/apache/freemarker/core/ParseException.java
@@ -397,9 +397,6 @@ public class ParseException extends IOException implements FMParserConstants
{
                         case END_FUNCTION:
                             endNames.add("#function");
                             break;
-                        case END_TRANSFORM:
-                            endNames.add("#transform");
-                            break;
                         case END_ESCAPE:
                             endNames.add("#escape");
                             break;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 1b419fe..cce8d18 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -788,8 +788,6 @@ TOKEN:
     |
     <MACRO : <START_TAG> "macro" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken,
FM_EXPRESSION); }
     |
-    <TRANSFORM : <START_TAG> "transform" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken,
FM_EXPRESSION); }
-    |
     <VISIT : <START_TAG> "visit" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken,
FM_EXPRESSION); }
     |
     <STOP : <START_TAG> "stop" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken,
FM_EXPRESSION); }
@@ -860,8 +858,6 @@ TOKEN:
     |
     <END_COMPRESS : <END_TAG> "compress" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken,
DEFAULT); }
     |
-    <END_TRANSFORM : <END_TAG> "transform" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken,
DEFAULT); }
-    |
     <END_SWITCH : <END_TAG> "switch" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken,
DEFAULT); }
     |
     <ELSE : <START_TAG> "else" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken,
DEFAULT); }
@@ -3346,42 +3342,6 @@ ASTStaticText NoParse() :
     }
 }
 
-ASTDirTransform Transform() :
-{
-    Token start, end, argName;
-    ASTExpression exp, argExp;
-    TemplateElements children = null;
-    HashMap args = null;
-}
-{
-    start = <TRANSFORM>
-    exp = ASTExpression()
-    [<SEMICOLON>]
-    (
-        argName = <ID>
-        <EQUALS>
-        argExp = ASTExpression()
-        {
-            if (args == null) args = new HashMap();
-            args.put(argName.image, argExp);
-        }
-    )*
-    (
-        end = <EMPTY_DIRECTIVE_END>
-        |
-        (
-            <DIRECTIVE_END>
-            children = MixedContentElements()
-            end = <END_TRANSFORM>
-        )
-    )
-    {
-        ASTDirTransform result = new ASTDirTransform(exp, args, children);
-        result.setLocation(template, start, end);
-        return result;
-    }
-}
-
 ASTDirSwitch Switch() :
 {
     ASTDirSwitch switchBlock;
@@ -3716,8 +3676,6 @@ ASTElement FreemarkerDirective() :
         |
         tp = NoParse()
         |
-        tp = Transform()
-        |
         tp = Switch()
         |
         tp = Setting()

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/manual/en_US/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt
index b69cb04..e2814ab 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -140,5 +140,6 @@ the FreeMarer 3 changelog here:
     required when calling JSP custom tags/functions, and in FreeMarker 2 this was worked
around with using the
     global static default DefaultObjectWrapper when the ObjectWrapper wasn't an ObjectWrapperAndUnwrapper.
 - Removed some long deprecated template language directives:
-  - <#call ...>
-  - <#comment>...</#comment>
\ No newline at end of file
+  - <#call ...> (deprecated by <@... />)
+  - <#comment>...</#comment> (deprecated by <#-- ... -->)
+  - <#transform ...>...</#transform> (deprecated by <@...>...</@...>)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl
b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl
index c41b492..393058e 100644
--- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl
+++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl
@@ -18,8 +18,8 @@
 -->
 <#global x=["a", "b", "c"]>
 <#global templateSource = r"<#foreach y in x>${y}</#foreach>">
-<#transform templateSource?interpret>def</#transform>
-<#transform [templateSource]?interpret>def</#transform>
-<#transform [templateSource,"id"]?interpret>def</#transform>
+<@templateSource?interpret>def</@>
+<@[templateSource]?interpret>def</@>
+<@[templateSource,"id"]?interpret>def</@>
 
 <#assign t = '<#macro m>M</#macro>'?interpret><@t /><@m/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/newlines2.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/newlines2.ftl
b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/newlines2.ftl
index e86684c..ac8337c 100644
--- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/newlines2.ftl
+++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/newlines2.ftl
@@ -18,7 +18,7 @@
 -->
 <#assign message="Hello, world!\n">
 <#assign normalizeNewlines = "org.apache.freemarker.core.util.NormalizeNewlines"?new()>
-<#transform normalizeNewlines>
+<@normalizeNewlines>
 <html>
 <head>
 <title>FreeMarker: Newlines the Second Test</title>
@@ -30,4 +30,4 @@
 
 </body>
 </html>
-</#transform>
\ No newline at end of file
+</@normalizeNewlines>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9047d13b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl
b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl
index 29c585d..02237b0 100644
--- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl
+++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl
@@ -61,7 +61,7 @@ word_list:
 </#foreach>
 
 <#global canufeelitbabe = x?interpret>
-interpret: <#transform canufeelitbabe></#transform>
+interpret: <@canufeelitbabe></@>
 <#setting locale="es_ES">number: ${"-123.45"?number + 1.1}
 ${"1.5e3"?number?c}
 ${"0005"?number?c}


Mime
View raw message