You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Dmitry (Jira)" <ji...@apache.org> on 2023/01/03 18:36:00 UTC

[jira] [Commented] (GROOVY-10886) Error in Groovy enums parsing using GroovyRecognizer

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

Dmitry commented on GROOVY-10886:
---------------------------------

[~paulk] Yes, 'ExampleEnum' will be correct instead of 'TaggableClasses'. Could you try to start [https://github.com/KeyrisXdSnow/GradleReproducer.git] ?

> 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: Major
>
> 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)