[groovy] branch GROOVY_3_0_X updated (892bac8 -> bb0009d)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch GROOVY_3_0_X updated (892bac8 -> bb0009d)

Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 892bac8  GROOVY-9399: Annotations on annotation methods are missing in the AST
     new b414f5a  Minor refactoring: Remove redundant rule `classifiedModifiers`
     new bb0009d  GROOVY-9403: Bump javaparser to 3.15.12

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build.gradle                                       |  2 +-
 src/antlr/GroovyParser.g4                          | 23 +++-------------------
 .../apache/groovy/parser/antlr4/AstBuilder.java    | 22 ++++++---------------
 3 files changed, 10 insertions(+), 37 deletions(-)

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 01/02: Minor refactoring: Remove redundant rule `classifiedModifiers`

Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit b414f5a680630d4d22c0fddfd5114b296e6d1ede
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Feb 16 17:57:34 2020 +0800

    Minor refactoring: Remove redundant rule `classifiedModifiers`
   
    (cherry picked from commit 620f04bc1c19c149fb2f59b8fa8248575a36affb)
---
 src/antlr/GroovyParser.g4                          | 23 +++-------------------
 .../apache/groovy/parser/antlr4/AstBuilder.java    | 22 ++++++---------------
 2 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 65655ff..f075237 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -586,15 +586,11 @@ localVariableDeclaration
         variableDeclaration[0]
     ;
 
-classifiedModifiers[int t]
-    :   modifiers nls
-    ;
-
 /**
  *  t   0: local variable declaration; 1: field declaration
  */
 variableDeclaration[int t]
-    :   classifiedModifiers[$t]
+    :   modifiers nls
         (   type? variableDeclarators
         |   typeNamePairs nls ASSIGN nls variableInitializer
         )
@@ -657,20 +653,14 @@ statement
     :   block                                                                                               #blockStmtAlt
     |   conditionalStatement                                                                                #conditionalStmtAlt
     |   loopStatement                                                                                       #loopStmtAlt
-
     |   tryCatchStatement                                                                                   #tryCatchStmtAlt
-
     |   SYNCHRONIZED expressionInPar nls block                                                              #synchronizedStmtAlt
     |   RETURN expression?                                                                                  #returnStmtAlt
     |   THROW expression                                                                                    #throwStmtAlt
-
     |   breakStatement                                                                                      #breakStmtAlt
     |   continueStatement                                                                                   #continueStmtAlt
-
     |   identifier COLON nls statement                                                                      #labeledStmtAlt
-
     |   assertStatement                                                                                     #assertStmtAlt
-
     |   localVariableDeclaration                                                                            #localVariableDeclarationStmtAlt
 
     // validate the method in the AstBuilder#visitMethodDeclaration, e.g. method without method body is not allowed
@@ -678,7 +668,6 @@ statement
         methodDeclaration[3, 9]                                                                             #methodDeclarationStmtAlt
 
     |   statementExpression                                                                                 #expressionStmtAlt
-
     |   SEMI                                                                                                #emptyStmtAlt
     ;
 
@@ -879,20 +868,14 @@ castOperandExpression
 options { baseContext = expression; }
     :   castParExpression castOperandExpression                                             #castExprAlt
     |   postfixExpression                                                                   #postfixExprAlt
+
     // ~(BNOT)/!(LNOT) (level 1)
     |   (BITNOT | NOT) nls castOperandExpression                                            #unaryNotExprAlt
+
     // ++(prefix)/--(prefix)/+(unary)/-(unary) (level 3)
     |   op=(INC | DEC | ADD | SUB) castOperandExpression                                    #unaryAddExprAlt
     ;
 
-
-/*
-enhancedExpression
-    :   expression
-    |   standardLambdaExpression
-    ;
-*/
-
 commandExpression
     :   expression
         (
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index b4ae68b..9b2780e 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -177,7 +177,6 @@ import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClassOrInterfaceM
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClassOrInterfaceModifiersOptContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClassOrInterfaceTypeContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClassicalForControlContext;
-import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClassifiedModifiersContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClosureContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ClosureOrLambdaExpressionContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.CommandArgumentContext;
@@ -1594,7 +1593,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
                 && methodName.equals(className)) { // constructor declaration
 
             methodNode = createConstructorNodeForClass(methodName, parameters, exceptions, code, classNode, modifiers);
-        } else { // class memeber method declaration
+        } else { // class member method declaration
             if (!hasReturnType && hasMethodBody && (0 == modifierManager.getModifierCount())) {
                 throw createParsingFailedException("Invalid method declaration: " + methodName, ctx);
             }
@@ -1697,10 +1696,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
         return configureAST(this.visitVariableDeclaration(ctx.variableDeclaration()), ctx);
     }
 
-    private ModifierManager createModifierManager(VariableDeclarationContext ctx) {
-        return new ModifierManager(this, this.visitClassifiedModifiers(ctx.classifiedModifiers()));
-    }
-
     private DeclarationListStatement createMultiAssignmentDeclarationListStatement(VariableDeclarationContext ctx, ModifierManager modifierManager) {
         /*
         if (!modifierManager.contains(DEF)) {
@@ -1730,17 +1725,12 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> {
     }
 
     @Override
-    public List<ModifierNode> visitClassifiedModifiers(ClassifiedModifiersContext ctx) {
-        if (!asBoolean(ctx)) {
-            return Collections.emptyList();
-        }
-
-        return this.visitModifiers(ctx.modifiers());
-    }
-
-    @Override
     public DeclarationListStatement visitVariableDeclaration(VariableDeclarationContext ctx) {
-        ModifierManager modifierManager = this.createModifierManager(ctx);
+        ModifierManager modifierManager =
+                new ModifierManager(
+                        this,
+                        asBoolean(ctx.modifiers()) ? this.visitModifiers(ctx.modifiers()) : Collections.emptyList()
+                );
 
         if (asBoolean(ctx.typeNamePairs())) { // e.g. def (int a, int b) = [1, 2]
             return this.createMultiAssignmentDeclarationListStatement(ctx, modifierManager);

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 02/02: GROOVY-9403: Bump javaparser to 3.15.12

Daniel.Sun
In reply to this post by Daniel.Sun
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit bb0009d89be6e8e43ccaaac306ba6b176ea40ad8
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Feb 16 17:29:06 2020 +0800

    GROOVY-9403: Bump javaparser to 3.15.12
   
    (cherry picked from commit fa70a068cc8d74fd081162a4dffe4736e2f087d3)
---
 build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index 50782a4..98ce6f4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -139,7 +139,7 @@ ext {
     ivyVersion = '2.5.0'
     jansiVersion = '1.18'
     jarjarVersion = '1.7.2'
-    javaParserVersion = '3.15.11'
+    javaParserVersion = '3.15.12'
     jlineVersion = '2.14.6'
     jmockVersion = '1.2.0'
     logbackVersion = '1.1.7'

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun