[ https://issues.apache.org/jira/browse/GROOVY-10886?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-10886: ------------------------------- Description: We recently upgraded to gradle version 7.4.1 and ran into problem with parsing groovy enums. Environment: * Java SDK 11 * Gradle 7.4.1 * Groovy 2.5.15 ( This is version of our project, but parser and all the required entities are imported from gradle -> groovy 3.0.9) We try parse groovy enums using GroovyRecognizer. Groovy code: {code:java} SourceBuffer sourceBuffer = new SourceBuffer() UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new StringReader(‘ExampleEnum.groovy'), sourceBuffer) GroovyLexer lexer = new GroovyLexer(unicodeReader) unicodeReader.setLexer(lexer) parser = GroovyRecognizer.make(lexer) parser.setSourceBuffer(sourceBuffer) parser.compilationUnit() {code} Enum example: {code:java} @API public enum ExampleEnum implements Serializable { @API ITEM1(1), @API ITEM2(2), @API ITEM3(3); private Integer value; public TaggableClasses(Integer value) { this.value = value; } public Integer getValue() { return this.value; } {code} {{.compilationUnit()}} method throws an exception "Parsing failed for 'ExampleEnum.groovy' due to: unexpected token: 2" Token is value of ITEM2. Groovy class and interfaces parsing work correctly. My colleague created a test project that reproduces the issue. [https://github.com/KeyrisXdSnow/GradleReproducer.git] We discussed the issue with gradle team, they said it is not on their (gradle) side. https://github.com/gradle/gradle/issues/20244 Could you please advise how we can solve this problem? Thanks. was: We recently upgraded to gradle version 7.4.1 and ran into problem with parsing groovy enums. Environment: * Java SDK 11 * Gradle 7.4.1 * Groovy 2.5.15 ( This is version of our project, but parser and all the required entities are imported from gradle -> groovy 3.0.9) We try parse groovy enums using GroovyRecognizer. Groovy code: {{}} {code:java} SourceBuffer sourceBuffer = new SourceBuffer() UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new StringReader(‘ExampleEnum.groovy'), sourceBuffer) GroovyLexer lexer = new GroovyLexer(unicodeReader) unicodeReader.setLexer(lexer) parser = GroovyRecognizer.make(lexer) parser.setSourceBuffer(sourceBuffer) parser.compilationUnit(){code} {{}} Enum example: {code:java} @API public enum ExampleEnum implements Serializable { @API ITEM1(1), @API ITEM2(2), @API ITEM3(3); private Integer value; public TaggableClasses(Integer value) { this.value = value; } public Integer getValue() { return this.value; } {code} .compilationUnit() method throws an exception "Parsing failed for 'ExampleEnum.groovy' due to: unexpected token: 2" Token is value of ITEM2. Groovy class and interfaces parsing work correctly. My colleague created a test project that reproduces the issue. [https://github.com/KeyrisXdSnow/GradleReproducer.git] We discussed the issue with gradle team, they said it is not on their (gradle) side. https://github.com/gradle/gradle/issues/20244 Could you please advise how we can solve this problem? Thanks. > Error in Groovy enums parsing using GroovyRecognizer > ---------------------------------------------------- > > Key: GROOVY-10886 > URL: https://issues.apache.org/jira/browse/GROOVY-10886 > Project: Groovy > Issue Type: Bug > Components: Compiler, parser > Affects Versions: 2.5.15, 3.0.9 > Environment: Java SDK 11 > Gradle 7.4.1 > Groovy 2.5.15 ( This is version of our project, but parser and all the > required entities are imported from gradle -> groovy 3.0.9) > Reporter: Dmitry > Priority: Blocker > > We recently upgraded to gradle version 7.4.1 and ran into problem with > parsing groovy enums. > Environment: > * Java SDK 11 > * Gradle 7.4.1 > * Groovy 2.5.15 ( This is version of our project, but parser and all the > required entities are imported from gradle -> groovy 3.0.9) > We try parse groovy enums using GroovyRecognizer. Groovy code: > {code:java} > SourceBuffer sourceBuffer = new SourceBuffer() > UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(new > StringReader(‘ExampleEnum.groovy'), sourceBuffer) > GroovyLexer lexer = new GroovyLexer(unicodeReader) > unicodeReader.setLexer(lexer) > parser = GroovyRecognizer.make(lexer) > parser.setSourceBuffer(sourceBuffer) > parser.compilationUnit() > {code} > Enum example: > {code:java} > @API > public enum ExampleEnum implements Serializable { > @API > ITEM1(1), > @API > ITEM2(2), > @API > ITEM3(3); > > private Integer value; > public TaggableClasses(Integer value) { > this.value = value; > } > public Integer getValue() { > return this.value; > } > {code} > {{.compilationUnit()}} method throws an exception "Parsing failed for > 'ExampleEnum.groovy' due to: unexpected token: 2" > Token is value of ITEM2. > Groovy class and interfaces parsing work correctly. > My colleague created a test project that reproduces the issue. > [https://github.com/KeyrisXdSnow/GradleReproducer.git] > We discussed the issue with gradle team, they said it is not on their > (gradle) side. https://github.com/gradle/gradle/issues/20244 > Could you please advise how we can solve this problem? > Thanks. -- This message was sent by Atlassian Jira (v8.20.10#820010)