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

Allow easier configuration of groovy.antlr4 #1310

Closed
jamesdh opened this issue Oct 26, 2021 · 3 comments
Closed

Allow easier configuration of groovy.antlr4 #1310

jamesdh opened this issue Oct 26, 2021 · 3 comments

Comments

@jamesdh
Copy link

jamesdh commented Oct 26, 2021

I'm trying to make use of Spotless code formatter (within gradle) for formatting our Java + Groovy code. Unfortunately, when setting it up today I encountered some issues with lambda syntax in Groovy 3+ code. A bit of googling lead me to groovy-eclipse, since Spotless uses it to perform its groovy parsing. Eventually I stumbled on the 4.2.0 release notes with the following:

The new antlr4-based Parrot Parser is disabled by default. To enable it, add -Dgroovy.antlr4=true to your eclipse.ini file after the -vmargs line or add a compiler config script to your project with configuration.pluginFactory = org.codehaus.groovy.control.ParserPluginFactory.antlr4()

There doesn't seem to be any way to enable antlr4 from gradle directly. I was able to get things working by passing a JVM option to gradle directly, but I was hoping to configure this in such a way that doesn't require active input from other team members.

Initially I opened an issue at diffplug/spotless#975, inquiring as to whether or not I was missing something. Ultimately, they think this would be better served by making it more configurable from within groovy-eclipse itself.

@eric-milles
Copy link
Member

eric-milles commented Oct 26, 2021

It is configurable through CompilerConfiguration as well. I don't really know what sort of interface spotless provides for you.

@jamesdh
Copy link
Author

jamesdh commented Oct 29, 2021

Since Groovy 4 is just around the corner and removes the Antlr2 based parser completely, is there any plans to just switch to the Antlr4 parser by default?

@eric-milles
Copy link
Member

Groovy 4 does indeed remove its antlr2-based parser. But it does not remove the mechanism for supplying any compatible parser to the compiler. So this project continues to supply a patched antlr2-based parser to keep code completion and other editor features working.

Plans for transition to the antlr40based parser as the default can be tracked here:
#1011
#1107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants