Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy script: annotations on script-level variable declarations do not parse correctly #4853

Open
crankydillo opened this issue Jan 6, 2025 · 2 comments
Labels
bug Something isn't working parser-groovy

Comments

@crankydillo
Copy link
Contributor

crankydillo commented Jan 6, 2025

This test added to rewrite-groovy/../AnnotationsTest.java will fail, but AFAIK should successfully parse.

    @Test
    void annotatedVariables() {
        rewriteRun(
          groovy(
            """
              @Foo abc=123
              """
          )
        );
    }

Debugging points a finger at GroovyParserVisitor#RewriteGroovyVisitor#visitDeclarationExpression.

What version of OpenRewrite are you using?

Currently running the test above on your main branch, but we are using 8.40.2.

Are you interested in contributing a fix to OpenRewrite?

I'm always interested, but hard to find time. I may give this a go, but hoping it's easy for your parser gurus.. If I can do something quickly, I'll do it!

@crankydillo crankydillo added the bug Something isn't working label Jan 6, 2025
@timtebeek
Copy link
Contributor

Perhaps @jevanlingen can provide some guidance here; his solved quite a few Groovy parser issues lately, and this seems like a case of implied parenthesis in an annotation, although it could be ambiguous.

@crankydillo
Copy link
Contributor Author

Based on glancing at #4832, there is no doubt @jevanlingen is better qualified than me:) But I think the issue is not with parens, it just doesn't do anything with annotations in the case I'm describing (annotations on top/script-level declarations).

@timtebeek timtebeek moved this to Backlog in OpenRewrite Jan 10, 2025
@crankydillo crankydillo changed the title Groovy script: annotations on script-level variable declarations does not parse correctly Groovy script: annotations on script-level variable declarations do not parse correctly Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-groovy
Projects
Status: Backlog
Development

No branches or pull requests

2 participants