You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/04/11 01:38:17 UTC

[41/50] groovy git commit: GROOVY-8131: Statement continued onto next line is flagged when first character is "="

GROOVY-8131: Statement continued onto next line is flagged when first character is "="


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

Branch: refs/heads/master
Commit: c9b4ee7be39b7e68dcad56685f4186706dd10198
Parents: 9a0aa60
Author: sunlan <su...@apache.org>
Authored: Sun Apr 2 02:07:37 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sun Apr 2 02:07:37 2017 +0800

----------------------------------------------------------------------
 .../apache/groovy/parser/antlr4/GroovyParser.g4 | 14 +++---
 .../parser/antlr4/GroovyParserTest.groovy       |  1 +
 .../test/resources/core/Expression_23x.groovy   | 45 ++++++++++++++++++++
 3 files changed, 53 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c9b4ee7b/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4 b/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
index 71b7f0e..501938b 100644
--- a/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
+++ b/subprojects/groovy-parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
@@ -346,7 +346,7 @@ variableDeclarators
     ;
 
 variableDeclarator
-    :   variableDeclaratorId (ASSIGN nls variableInitializer)?
+    :   variableDeclaratorId (nls ASSIGN nls variableInitializer)?
     ;
 
 variableDeclaratorId
@@ -416,11 +416,11 @@ formalParameterList
     ;
 
 formalParameter
-    :   variableModifiersOpt type?          variableDeclaratorId (ASSIGN nls expression)?
+    :   variableModifiersOpt type?          variableDeclaratorId (nls ASSIGN nls expression)?
     ;
 
 lastFormalParameter
-    :   variableModifiersOpt type? ELLIPSIS variableDeclaratorId (ASSIGN nls expression)?
+    :   variableModifiersOpt type? ELLIPSIS variableDeclaratorId (nls ASSIGN nls expression)?
     ;
 
 methodBody
@@ -542,7 +542,7 @@ elementValuePairs
     ;
 
 elementValuePair
-    :   elementValuePairName ASSIGN elementValue
+    :   elementValuePairName nls ASSIGN nls elementValue
     ;
 
 elementValuePairName
@@ -594,7 +594,7 @@ variableDeclaration[int t]
         (   { 0 == $t }? variableModifiers
         |   { 1 == $t }? modifiers
         )
-        typeNamePairs ASSIGN nls variableInitializer
+        typeNamePairs nls ASSIGN nls variableInitializer
     ;
 
 typeNamePairs
@@ -883,8 +883,8 @@ expression
 
     // assignment expression (level 15)
     // "(a) = [1]" is a special case of multipleAssignmentExprAlt, it will be handle by assignmentExprAlt
-    |   <assoc=right> left=variableNames op=ASSIGN nls right=statementExpression            #multipleAssignmentExprAlt
-    |   <assoc=right> left=expression
+    |   <assoc=right> left=variableNames nls op=ASSIGN nls right=statementExpression            #multipleAssignmentExprAlt
+    |   <assoc=right> left=expression nls
                         op=(   ASSIGN
                            |   ADD_ASSIGN
                            |   SUB_ASSIGN

http://git-wip-us.apache.org/repos/asf/groovy/blob/c9b4ee7b/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index 65a9099..14b67f2 100644
--- a/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -188,6 +188,7 @@ class GroovyParserTest extends GroovyTestCase {
         doRunAndTest('core/Expression_21x.groovy');
         doTest('core/Expression_22x.groovy');
         doRunAndTest('core/Expression_22x.groovy');
+        doRunAndTest('core/Expression_23x.groovy');
     }
 
     void "test groovy core - IdenticalOp"() {

http://git-wip-us.apache.org/repos/asf/groovy/blob/c9b4ee7b/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy b/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
new file mode 100644
index 0000000..8962219
--- /dev/null
+++ b/subprojects/groovy-parser-antlr4/src/test/resources/core/Expression_23x.groovy
@@ -0,0 +1,45 @@
+def a
+    =
+        1 + 2
+assert 3 == a
+
+a
+    +=
+        2
+assert 5 == a
+
+int b
+    =
+        1,
+    c
+        =
+            2
+assert 1 == b
+assert 2 == c
+
+def (int x, int y)
+    =
+        [1, 2]
+assert 1 == x
+assert 2 == y
+(x)
+    =
+        [3]
+assert 3 == x
+
+@SuppressWarnings(value
+        =
+        "all")
+def m(p1
+        =
+            1,
+      p2
+        =
+            2,
+      int... p3
+                =
+                    [3]) {
+    return p1 + p2 + p3[0]
+}
+assert 6 == m()
+