Skip to content

Groovy Enum is throwing "Failed to parse" "UnsupportedOperationException: enum fields are not implemented." #4252

Open
@gtiwari333

Description

What version of OpenRewrite are you using?

I am using https://github.com/gtiwari333/openrewrite-groovy-bug/blob/main/init.gradle

  • org.openrewrite.recipe:rewrite-recipe-bom - 2.1.20
  • org.openrewrite:rewrite-gradle-plugin - latest.release
  • groovy 4.0.21
  • jdk 17/21
  • gradle 8.8

How are you running OpenRewrite?

%./gradlew clean rewriteRun --init-script init.gradle --info

What is the smallest, simplest way to reproduce the problem?

Checkout the following project and run ./gradlew clean rewriteRun --init-script init.gradle --info

Im seeing similar behavior with both jdk17 and jdk21

https://github.com/gtiwari333/openrewrite-groovy-bug/blob/main/README.md

What did you expect to see?

No failures. AutoFormat recipe should run on the code.

What did you see instead?

org.openrewrite.groovy.GroovyParsingException: Failed to parse src/main/groovy/com/example/demo/Status.groovy at cursor position 39. The next 10 characters in the original source are ` //enum al`
       at org.openrewrite.groovy.GroovyParserVisitor.visit(GroovyParserVisitor.java:175)
....
 Caused by: java.lang.UnsupportedOperationException: enum fields are not implemented.
       at org.openrewrite.groovy.GroovyParserVisitor$RewriteGroovyClassVisitor.visitEnumField(GroovyParserVisitor.java:357)
       at org.openrewrite.groovy.GroovyParserVisitor$RewriteGroovyClassVisitor.visitField(GroovyParserVisitor.java:348)
       at org.openrewrite.groovy.GroovyParserVisitor$RewriteGroovyClassVisitor.lambda$visitClassBlock$3(GroovyParserVisitor.java:332)
       at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
       at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)

What is the full stack trace of any errors you encountered?

Run the ./gradlew clean rewriteRun --init-script init.gradle --info command to get full stacktrace. I've provided relevant bits above.

Are you interested in contributing a fix to OpenRewrite?

Not too familiar how AST works. But i can try.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparser-groovytest providedAlready replicated with a unit test, using JUnit pioneer's ExpectedToFail

    Type

    No type

    Projects

    • Status

      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions