You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/03/03 21:19:48 UTC

[1/5] incubator-freemarker git commit: Manual: Document ?groups in more detail

Repository: incubator-freemarker
Updated Branches:
  refs/heads/2.3-gae 83eac154e -> b13a8763d


Manual: Document ?groups in more detail


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

Branch: refs/heads/2.3-gae
Commit: 779e74a844364820a4fefb5531218469ccd6e44b
Parents: 83eac15
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 3 11:33:55 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 3 11:33:55 2017 +0100

----------------------------------------------------------------------
 src/manual/en_US/book.xml | 49 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/779e74a8/src/manual/en_US/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index c3e683a..48b754e 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -7,9 +7,9 @@
   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
@@ -13848,9 +13848,48 @@ Matching sub-strings:
   - "aa/rx;" is "a" per "a/rx"
   - " ab/r;" is " " per "ab/r"</programlisting>
 
-          <para>Note above that <literal>groups</literal> has worked both with
-          substring matches and with the result of entire string
-          matching.</para>
+          <para>Notes regarding the behavior of the <literal>groups</literal>
+          built-in:</para>
+
+          <itemizedlist>
+            <listitem>
+              <para>It works both with substring matches and with the result
+              of entire string matching (as it was shown in the above
+              example)</para>
+            </listitem>
+
+            <listitem>
+              <para>The first item in the sequence that
+              <literal>groups</literal> returns is the whole substring matched
+              by the regular expression. Hence, the index of the first
+              explicit regular expression group (with other words, of the
+              first <literal>(<replaceable>...</replaceable>)</literal> in the
+              regular expression) is 1, and not 0. Also, because of this, the
+              size of the sequence is one more than the number of explicit
+              regular expression groups.</para>
+            </listitem>
+
+            <listitem>
+              <para>The size of the sequence returned by
+              <literal>groups</literal> only depends on the number of explicit
+              groups in the regular expression, and so it will be the same
+              (non-0) even if there was no match found for the regular
+              expression. Attempting to access an item of the sequence (as in
+              <literal>res?groups[1]</literal>) when there was match will
+              cause an error. Thus, before accessing the groups, you should
+              always check if there was any match (as in <literal>&lt;#if
+              res&gt;<replaceable>access the groups
+              here</replaceable>&lt;/#if&gt;</literal>).</para>
+            </listitem>
+
+            <listitem>
+              <para>When there's a match for the regular expression, but not
+              for a certain explicit group inside the regular expression, then
+              for that group the sequence will contain a 0 length string. So
+              accessing a group that matches nothing is safe, as far as the
+              containing regular expression has matched something.</para>
+            </listitem>
+          </itemizedlist>
 
           <para><literal>matches</literal> accepts an optional 2nd parameter,
           the <link linkend="ref_builtin_string_flags">flags</link>. Note that


[3/5] incubator-freemarker git commit: Removed an unnecessary sync in SimpleCollection

Posted by dd...@apache.org.
Removed an unnecessary sync in SimpleCollection


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

Branch: refs/heads/2.3-gae
Commit: 9f1fea3ed7671c3d6f71ffd8d4ac1365764a7caf
Parents: b4035ce
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 3 11:34:42 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 3 11:34:42 2017 +0100

----------------------------------------------------------------------
 src/main/java/freemarker/template/SimpleCollection.java | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f1fea3e/src/main/java/freemarker/template/SimpleCollection.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/SimpleCollection.java b/src/main/java/freemarker/template/SimpleCollection.java
index ebcd679..aa67ef1 100644
--- a/src/main/java/freemarker/template/SimpleCollection.java
+++ b/src/main/java/freemarker/template/SimpleCollection.java
@@ -85,13 +85,9 @@ implements TemplateCollectionModel, Serializable {
      * can't return the first element anymore.
      */
     public TemplateModelIterator iterator() {
-        if (iterator != null) {
-            return new SimpleTemplateModelIterator(iterator, false);
-        } else {
-            synchronized (collection) {
-                return new SimpleTemplateModelIterator(collection.iterator(), true);
-            }
-        }
+        return iterator != null
+                ? new SimpleTemplateModelIterator(iterator, false)
+                : new SimpleTemplateModelIterator(collection.iterator(), true);
     }
     
     /**


[4/5] incubator-freemarker git commit: (Minor code cleanup)

Posted by dd...@apache.org.
(Minor code cleanup)


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

Branch: refs/heads/2.3-gae
Commit: df03e037cb6780a3c6919d08203c390f3f1a1817
Parents: 9f1fea3
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 3 11:35:33 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 3 11:35:33 2017 +0100

----------------------------------------------------------------------
 src/main/java/freemarker/ext/dom/NodeListModel.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/df03e037/src/main/java/freemarker/ext/dom/NodeListModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/ext/dom/NodeListModel.java b/src/main/java/freemarker/ext/dom/NodeListModel.java
index a18b4bc..a6a7534 100644
--- a/src/main/java/freemarker/ext/dom/NodeListModel.java
+++ b/src/main/java/freemarker/ext/dom/NodeListModel.java
@@ -57,7 +57,7 @@ class NodeListModel extends SimpleSequence implements TemplateHashModel, _Unexpe
     NodeModel contextNode;
     XPathSupport xpathSupport;
     
-    private static ObjectWrapper nodeWrapper = new ObjectWrapper() {
+    private static final ObjectWrapper NODE_WRAPPER = new ObjectWrapper() {
         public TemplateModel wrap(Object obj) {
             if (obj instanceof NodeModel) {
                 return (NodeModel) obj;
@@ -71,12 +71,12 @@ class NodeListModel extends SimpleSequence implements TemplateHashModel, _Unexpe
     }
     
     NodeListModel(NodeModel contextNode) {
-        super(nodeWrapper);
+        super(NODE_WRAPPER);
         this.contextNode = contextNode;
     }
     
     NodeListModel(NodeList nodeList, NodeModel contextNode) {
-        super(nodeWrapper);
+        super(NODE_WRAPPER);
         for (int i = 0; i < nodeList.getLength(); i++) {
             list.add(nodeList.item(i));
         }
@@ -84,7 +84,7 @@ class NodeListModel extends SimpleSequence implements TemplateHashModel, _Unexpe
     }
     
     NodeListModel(NamedNodeMap nodeList, NodeModel contextNode) {
-        super(nodeWrapper);
+        super(NODE_WRAPPER);
         for (int i = 0; i < nodeList.getLength(); i++) {
             list.add(nodeList.item(i));
         }
@@ -92,7 +92,7 @@ class NodeListModel extends SimpleSequence implements TemplateHashModel, _Unexpe
     }
     
     NodeListModel(List list, NodeModel contextNode) {
-        super(list, nodeWrapper);
+        super(list, NODE_WRAPPER);
         this.contextNode = contextNode;
     }
     


[2/5] incubator-freemarker git commit: (JavaDoc typo)

Posted by dd...@apache.org.
(JavaDoc typo)


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

Branch: refs/heads/2.3-gae
Commit: b4035cef611b60aafab0fd7a3714ad433a83feb3
Parents: 779e74a
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 3 11:34:11 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 3 11:34:11 2017 +0100

----------------------------------------------------------------------
 .../java/freemarker/template/DefaultNonListCollectionAdapter.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/b4035cef/src/main/java/freemarker/template/DefaultNonListCollectionAdapter.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/DefaultNonListCollectionAdapter.java b/src/main/java/freemarker/template/DefaultNonListCollectionAdapter.java
index b6a157b..2ee9ca2 100644
--- a/src/main/java/freemarker/template/DefaultNonListCollectionAdapter.java
+++ b/src/main/java/freemarker/template/DefaultNonListCollectionAdapter.java
@@ -57,7 +57,7 @@ public class DefaultNonListCollectionAdapter extends WrappingTemplateModel imple
      * @param collection
      *            The collection to adapt; can't be {@code null}.
      * @param wrapper
-     *            The {@link ObjectWrapper} used to wrap the items in the array. Has to be
+     *            The {@link ObjectWrapper} used to wrap the items in the collection. Has to be
      *            {@link ObjectWrapperAndUnwrapper} because of planned future features.
      */
     public static DefaultNonListCollectionAdapter adapt(Collection collection, ObjectWrapperWithAPISupport wrapper) {


[5/5] incubator-freemarker git commit: (Removed unused variable)

Posted by dd...@apache.org.
(Removed unused variable)


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

Branch: refs/heads/2.3-gae
Commit: b13a8763dbc5b4952ff46c479b535522cf1ca207
Parents: df03e03
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 3 22:19:35 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 3 22:19:35 2017 +0100

----------------------------------------------------------------------
 src/main/javacc/FTL.jj | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/b13a8763/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 46e565a..c6a9d8b 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -85,11 +85,6 @@ public class FMParser {
      */
     private int breakableDirectiveNesting;
     
-    /**
-     * Keeps track of the flags of the innermost parent #list or #foreach directive.
-     */
-    private int parentListAndForeachFlags;
-    
     private boolean inMacro, inFunction;
     private LinkedList escapes = new LinkedList();
     private int mixedContentNesting; // for stripText