You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2015/12/11 07:59:06 UTC

svn commit: r1719270 - in /commons/proper/jexl/trunk: RELEASE-NOTES.txt src/main/java/org/apache/commons/jexl3/parser/Parser.jjt src/site/xdoc/changes.xml src/site/xdoc/reference/syntax.xml src/test/java/org/apache/commons/jexl3/ForEachTest.java

Author: henrib
Date: Fri Dec 11 06:59:06 2015
New Revision: 1719270

URL: http://svn.apache.org/viewvc?rev=1719270&view=rev
Log:
JEXL:
Fix JEXL-176: remove foreach...in syntax

Modified:
    commons/proper/jexl/trunk/RELEASE-NOTES.txt
    commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
    commons/proper/jexl/trunk/src/site/xdoc/changes.xml
    commons/proper/jexl/trunk/src/site/xdoc/reference/syntax.xml
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java

Modified: commons/proper/jexl/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/RELEASE-NOTES.txt?rev=1719270&r1=1719269&r2=1719270&view=diff
==============================================================================
--- commons/proper/jexl/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/jexl/trunk/RELEASE-NOTES.txt Fri Dec 11 06:59:06 2015
@@ -44,11 +44,12 @@ What's new in 3.0:
 
 New features in 3.0:
 ====================
+* JEXL-178:     'Unsolvable property' message to provide details about underlying exception
 * JEXL-177:     Unified expressions to be used in String literals in JEXL scripts
+* JEXL-176:     Synonym operator name 'in' for operator =~ // Remove 'foreach...in' syntax
 * JEXL-174:     Overloadable property access operators
 * JEXL-173:     Duck-typed java closures
 * JEXL-170:     Implement assignment operators
-* JEXL-178:     'Unsolvable property' message to provide details about underlying exception
 * JEXL-164:     public getters for high/low properties for IntegerRange and LongRange
 * JEXL-152:     Extend Range literal to support Long values
 * JEXL-149:     Set Construction as per EL 3.0 spec

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt?rev=1719270&r1=1719269&r2=1719270&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt Fri Dec 11 06:59:06 2015
@@ -118,7 +118,6 @@ TOKEN_MGR_DECLS : {
       < IF : "if" >
     | < ELSE : "else" >
     | < FOR : "for" >
-    | < FOREACH : "foreach" > : FOR_EACH_IN
     | < WHILE : "while" >
     | < NEW : "new" >
     | < VAR : "var" >
@@ -135,11 +134,6 @@ TOKEN_MGR_DECLS : {
     | < PRAGMA : "#pragma" >
 }
 
-<FOR_EACH_IN> TOKEN : /* foreach in */
-{
-    < IN : "in" > : DEFAULT
-}
-
 <*> TOKEN : { /* SEPARATORS */
       < LPAREN : "(" >
     | < RPAREN : ")" >
@@ -214,7 +208,7 @@ TOKEN_MGR_DECLS : {
   < DOT_IDENTIFIER: ( [ "0"-"9", "a"-"z", "A"-"Z", "_", "$", "@" ])+ > { popDot(); } /* Revert state to default. */
 }
 
-<DEFAULT, FOR_EACH_IN, REGISTERS> TOKEN : /* IDENTIFIERS */
+<DEFAULT, REGISTERS> TOKEN : /* IDENTIFIERS */
 {
   < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >
 |
@@ -341,8 +335,6 @@ void Break() #Break : {}
 void ForeachStatement() : {}
 {
     <FOR> <LPAREN> ForEachVar() <COLON>  Expression() <RPAREN> { loopCount += 1; } (LOOKAHEAD(1) Block() | Statement()) { loopCount -= 1; }
-|
-    <FOREACH> <LPAREN> ForEachVar() <IN>  Expression() <RPAREN>  { loopCount += 1; } (LOOKAHEAD(1) Block() | Statement()){ loopCount -= 1; }
 }
 
 void ForEachVar() #Reference : {}

Modified: commons/proper/jexl/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/site/xdoc/changes.xml?rev=1719270&r1=1719269&r2=1719270&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/jexl/trunk/src/site/xdoc/changes.xml Fri Dec 11 06:59:06 2015
@@ -41,6 +41,9 @@
             <action dev="henrib" type="add" issue="JEXL-177" due-to="Dmitri Blinov">
                 Unified expressions to be used in String literals in JEXL scripts
             </action>
+            <action dev="henrib" type="add" issue="JEXL-176" due-to="Dmitri Blinov">
+                Synonym operator name 'in' for operator =~ // Remove 'foreach...in' syntax
+            </action>
             <action dev="henrib" type="add" issue="JEXL-174" due-to="Dmitri Blinov">
                 Overloadable property access operators
             </action>

Modified: commons/proper/jexl/trunk/src/site/xdoc/reference/syntax.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/site/xdoc/reference/syntax.xml?rev=1719270&r1=1719269&r2=1719270&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/site/xdoc/reference/syntax.xml (original)
+++ commons/proper/jexl/trunk/src/site/xdoc/reference/syntax.xml Fri Dec 11 06:59:06 2015
@@ -664,7 +664,7 @@
     x = x + item;
 }</source>
             Where <code>item</code> and <code>list</code> are variables.
-            The JEXL 1.1 syntax using <code>foreach(item in list)</code> is now <strong>deprecated</strong>.
+            The JEXL 1.1 syntax using <code>foreach(item in list)</code> is now <strong>unsupported</strong>.
           </td>
         </tr>
         <tr>

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java?rev=1719270&r1=1719269&r2=1719270&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ForEachTest.java Fri Dec 11 06:59:06 2015
@@ -67,7 +67,7 @@ public class ForEachTest extends JexlTes
 
     @Test
     public void testForEachWithCollection() throws Exception {
-        JexlScript e = JEXL.createScript("for(item : list) item");
+        JexlScript e = JEXL.createScript("for(var item : list) item");
         JexlContext jc = new MapContext();
         jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}));
         Object o = e.execute(jc);
@@ -76,7 +76,7 @@ public class ForEachTest extends JexlTes
 
     @Test
     public void testForEachWithEnumeration() throws Exception {
-        JexlScript e = JEXL.createScript("for(item : list) item");
+        JexlScript e = JEXL.createScript("for(var item : list) item");
         JexlContext jc = new MapContext();
         jc.set("list", new StringTokenizer("Hello,World", ","));
         Object o = e.execute(jc);
@@ -85,7 +85,7 @@ public class ForEachTest extends JexlTes
 
     @Test
     public void testForEachWithIterator() throws Exception {
-        JexlScript e = JEXL.createScript("for(item : list) item");
+        JexlScript e = JEXL.createScript("for(var item : list) item");
         JexlContext jc = new MapContext();
         jc.set("list", Arrays.asList(new Object[]{"Hello", "World"}).iterator());
         Object o = e.execute(jc);
@@ -106,17 +106,13 @@ public class ForEachTest extends JexlTes
     @Test
     public void testForEachWithBlock() throws Exception {
         JexlScript exs0 = JEXL.createScript("for(var in : list) { x = x + in; }");
-        JexlScript exs1 = JEXL.createScript("foreach(item in list) { x = x + item; }");
-        JexlScript[] exs = {exs0, exs1};
         JexlContext jc = new MapContext();
         jc.set("list", new Object[]{2, 3});
-        for (int ex = 0; ex < exs.length; ++ex) {
             jc.set("x", new Integer(1));
-            Object o = exs[ex].execute(jc);
+        Object o = exs0.execute(jc);
             Assert.assertEquals("Result is wrong", new Integer(6), o);
             Assert.assertEquals("x is wrong", new Integer(6), jc.get("x"));
         }
-    }
 
     @Test
     public void testForEachWithListExpression() throws Exception {