[ 
https://issues.apache.org/jira/browse/GROOVY-11642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949308#comment-17949308
 ] 

ASF GitHub Bot commented on GROOVY-11642:
-----------------------------------------

Copilot commented on code in PR #2211:
URL: https://github.com/apache/groovy/pull/2211#discussion_r2072671610


##########
src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java:
##########
@@ -1581,7 +1581,7 @@ public Void visitMemberDeclaration(final 
MemberDeclarationContext ctx) {
         } else if (asBoolean(ctx.classDeclaration())) {
             ctx.classDeclaration().putNodeMetaData(TYPE_DECLARATION_MODIFIERS, 
this.visitModifiersOpt(ctx.modifiersOpt()));
             
ctx.classDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);

Review Comment:
   [nitpick] Consider adding an inline comment or updating the documentation to 
clarify why configureAST is now required in the inner class context and how it 
differs from the previous visitClassDeclaration call.
   ```suggestion
               
ctx.classDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
               // The configureAST method is used here to set the position 
metadata for the class declaration node.
               // This differs from the previous visitClassDeclaration call, 
which only visited the class declaration
               // without configuring its position in the AST. This ensures 
that the node is properly positioned
               // within the parent context.
   ```





> source offset of inner class declaration with annotation
> --------------------------------------------------------
>
>                 Key: GROOVY-11642
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11642
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr4
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class Outer {
>   @Deprecated
>   public class Inner {
>   }
> }
> {code}
> Under the old parser, the source range for {{Inner}} starts at the 
> annotation.  The new parser starts at the line and column of the {{class}} 
> keyword.  You can compare against how an outer class with an annotation gets 
> ranged.
> This line does not expand the source range using {{ctx}} as is done for an 
> outer class.  
> https://github.com/apache/groovy/blob/1eeb735e303fdb230feb03ea3b3f44f7e7750e66/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java#L1584
> It is possible that the other member options -- method, field and compact 
> constructor -- also fail to include the range of other annotations / 
> modifiers.  I have not checked, but it looks suspect.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to