You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2021/02/11 08:11:42 UTC

[GitHub] [groovy] paulk-asert opened a new pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

paulk-asert opened a new pull request #1485:
URL: https://github.com/apache/groovy/pull/1485


   …on optimisation


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on a change in pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on a change in pull request #1485:
URL: https://github.com/apache/groovy/pull/1485#discussion_r574836618



##########
File path: src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
##########
@@ -179,10 +179,12 @@ public static boolean isInvalidLocalVariableDeclaration(TokenStream ts) {
         token = ts.LT(index);
         tokenType = token.getType();
         tokenType3 = ts.LT(index + 2).getType();
+        int nextCodePoint = token.getText().codePointAt(0);
 
         return // VOID == tokenType ||
                 !(BuiltInPrimitiveType == tokenType || Arrays.binarySearch(MODIFIER_ARRAY, tokenType) >= 0)
-                        && Character.isLowerCase(token.getText().codePointAt(0))
+                        && !Character.isUpperCase(nextCodePoint)
+                        && nextCodePoint != '@'

Review comment:
       I would have thought so too but without it the following annotation on a local variable declaration failed:
   
   > > Task :compileTestGroovy FAILED
   > startup failed:
   > D:\projects\groovyCopy\src\test\gls\annotations\closures\AnnotationClosureOwnerCallTest.groovy: 45: Unexpected input: '@' @ line 45, column 9.
   >            @AnnWithClassElement(elem = { owner.answer() })
   >            ^
   > 
   > 1 error
   > 
   
   ```
           @AnnWithClassElement(elem = { owner.answer() })
           def aLocal
   ```
   Perhaps there is a better tweak to cover that case?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] danielsun1106 commented on a change in pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
danielsun1106 commented on a change in pull request #1485:
URL: https://github.com/apache/groovy/pull/1485#discussion_r575045161



##########
File path: src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
##########
@@ -179,10 +179,12 @@ public static boolean isInvalidLocalVariableDeclaration(TokenStream ts) {
         token = ts.LT(index);
         tokenType = token.getType();
         tokenType3 = ts.LT(index + 2).getType();
+        int nextCodePoint = token.getText().codePointAt(0);
 
         return // VOID == tokenType ||
                 !(BuiltInPrimitiveType == tokenType || Arrays.binarySearch(MODIFIER_ARRAY, tokenType) >= 0)
-                        && Character.isLowerCase(token.getText().codePointAt(0))
+                        && !Character.isUpperCase(nextCodePoint)
+                        && nextCodePoint != '@'

Review comment:
       Understood. Let's go ahead with the your solution, which looks good to me.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] danielsun1106 merged pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
danielsun1106 merged pull request #1485:
URL: https://github.com/apache/groovy/pull/1485


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] danielsun1106 commented on a change in pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
danielsun1106 commented on a change in pull request #1485:
URL: https://github.com/apache/groovy/pull/1485#discussion_r574486093



##########
File path: src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
##########
@@ -179,10 +179,12 @@ public static boolean isInvalidLocalVariableDeclaration(TokenStream ts) {
         token = ts.LT(index);
         tokenType = token.getType();
         tokenType3 = ts.LT(index + 2).getType();
+        int nextCodePoint = token.getText().codePointAt(0);
 
         return // VOID == tokenType ||
                 !(BuiltInPrimitiveType == tokenType || Arrays.binarySearch(MODIFIER_ARRAY, tokenType) >= 0)
-                        && Character.isLowerCase(token.getText().codePointAt(0))
+                        && !Character.isUpperCase(nextCodePoint)
+                        && nextCodePoint != '@'

Review comment:
       checking character @ seems unnecessary because @ is not allowed to appear in identifier.
   Even if we use quotes, e.g. ”@foo”, the first character of the identifier is ".
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] danielsun1106 commented on pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
danielsun1106 commented on pull request #1485:
URL: https://github.com/apache/groovy/pull/1485#issuecomment-777384113


   +1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] danielsun1106 commented on pull request #1485: GROOVY-9936: Difference between old/new parser for variable declarati…

Posted by GitBox <gi...@apache.org>.
danielsun1106 commented on pull request #1485:
URL: https://github.com/apache/groovy/pull/1485#issuecomment-778561275


   Merged.Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org