-
Notifications
You must be signed in to change notification settings - Fork 193
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
spock data-table formatted incorrectly #822
Comments
I will take a quick look at it. The formatter has not received much attention in the past few years. I'm certainly open to helping someone get a workspace set up so they can make regular contributions in that space. What is the desired outcome of formatting the data table example? |
I would settle for either smushing it all into one line:
Or maybe:
As long as there's no lines starting with |
Odd! I can gather all the versions of the stuff I have for more info. That formatting looks exactly like what I want! Maybe i just don't have the right formatter... |
I'm curious why the parser (or the Spock transform) thinks that "[...]\n | true" is not a bitwise-or expression. I'm aware of "'string'\n + ' more'" and "1\n + 2" not parsing as we would expect. But "|" is not a unary operator. But that's a side question... |
Any versions I can snag to compare formatters? (not sure why yours formats that way but mine doesnt) |
To the Groovy parser, there is no awareness of Spock. Spock smarts are applied well after parsing and conversion. "a | b" alone on a line should produce an expression statement with an embedded binary expression that has the operator "|" which is bitwise-or. Not sure how Spock implements data tables, but in terms of the formatter, that is immaterial. |
You mentioned above that spotless is how you are formatting. How does that tool work? What versions of Groovy and Groovy-Eclipse are used? |
You can follow and upvote the root cause of your compiler errors here: https://issues.apache.org/jira/browse/GROOVY-9004 |
Spotless calls the groovy eclipse formatter + some custom steps: The version used is 3.0.0 (at the moment): https://github.com/diffplug/spotless/blob/master/lib-extra/src/main/resources/com/diffplug/spotless/extra/groovy_eclipse_formatter/v4.8.1.lockfile One of the maintainers tried with the latest release and the formatting still looked dodgy. Eclipse plugins on my end: Version + Build:
Groovy/Gradle:
|
These seem like odd choices:
And is it using the patched Groovy runtime, which has many parser patches. |
For reference, here are the parser patches for the antlr2 groovy parser (search for GRECLIPSE comments): https://github.com/groovy/groovy-eclipse/blob/master/base/org.codehaus.groovy24/src/org/codehaus/groovy/antlr/groovy.g Core groovy actually has line and column set incorrectly for binary expressions and a number of other expressions. It only needed to be accurate enough for error messaging (aka compiler errors); the formatter requires a much greater degree of accuracy when trying to reposition tokens. |
Might be related to the way data-tables are dealt with #812
Given this test:
The formatter will mangle the second part of the data-table into a new line:
This causes things to not compile. I landed here from a bug I raised with spotless: diffplug/spotless#357
I've gotten around this by writing a
custom
formatter for spotless that basically re-stitches the lines back together (if a line starts with "|" after seeing awhere
clause)The text was updated successfully, but these errors were encountered: