Closed
Description
I have a custom importOrder
for groovy
and when I do a gradle spotlessApply
it fixes that but it also adds semicolons to all import statements which it should not do.
P.S. I see now that actually this could be configured using Eclipse's Groovy plugin - however I don't see how to export Grvooy's formatter settings - rather, I see only how to do so for Java's.
P.S. 2 - I found some link with an example file so I'll be closing this issue. The link to greclipse.properties
in the README is broken, you might want to fix that.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
fvgh commentedon Apr 27, 2018
@boris-petrov What was the reason to close the issue?
Just a quick guess on the subject:
The importOrder does not know about the eclipse-groovy settings, an honestly I do not think that it should.
Whether to remove semicolons is configurable for the
greclipse
(groovy.formatter.remove.unnecessary.semicolons
).At the moment it should help to run the
greclipse
after theimportOrder
.Does that help for the moment?
But you are right, semicolons should only be used in groovy where necessary.
I will anyhow work on the
importOrder
in the future to make parts of it reusable for other languages (but this is quite low on my priorities...). This would be a good opportunity to change this behaviour.boris-petrov commentedon Apr 27, 2018
@fvgh - I added another edit to my original post in which I explain why I closed the issue, sorry.
I did try adding a call to
greclipse()
afterimportOrder
and giving it a config file that I wanted however it blows up with an exception:And I was about to try to figure it out myself before writing here again. :)
fvgh commentedon Apr 27, 2018
Ok, the trace is not very helpful. Coincidentally I just opened #236 yesterday.
If you can figure out what the problem is, that would be great.
Otherwise it would help if you can provide a very small test case (input and config) which reproduces the problem.
boris-petrov commentedon Apr 27, 2018
I'll try to create a reproduction, I think I'll be able to. I'll comment in the next few days.
boris-petrov commentedon Apr 27, 2018
@fvgh - actually here's some code that triggers that exception for me:
Tell me if it doesn't do that for you.
P.S. the config is simple enough:
fvgh commentedon Apr 27, 2018
Yes, it does.
Just a quick guess, I have to call it a day...
Seems that I have to update the underlying Groovy-Eclipse version...
Your error is here!
fvgh commentedon Apr 29, 2018
The current grEclipse version (better to say the underlying groovy-eclipse) has problems with bounded wildcards. It raises an exception when trying to create the AST.
Maybe the issue has been fixed.
The current grEclipse is based on a groovy-eclipse V2.9.1 patch, whereas the original version had been released in 2014.
Beginning of this year v2.9.2 has been released which provides quite some refactoring including the offending code (see previous comment).
I'll provide an upgrade of grEclipse.
fvgh commentedon May 5, 2018
@boris-petrov
Sorry, it seems to me that version 2.9.2 still has the same bug.
Do you use groove-eclipse in your Eclipse IDE?
You should find the following warning in the Eclipse logs:
Can you have a look?
For Spotless I provided with #244 a possibility to ignore compiler problems, but this of course can lead to incorrect formatting.
boris-petrov commentedon May 11, 2018
@fvgh - sorry for the delayed answer. I'm not sure where to check the Eclipse logs but yes, whenever I try formatting a file which contains the code above, it doesn't do anything. If I remove that code, it formats it. So I guess it is the same problem.
Do you have any ideas how to workaround that? Perhaps that PR is a good start.
fvgh commentedon May 12, 2018
Work around for bounded wild-cards
The PR will basically only skip the file processing. I made some major refactoring on how Spotless integrates Eclipse plugins and I am afraid I still need some more time. But you have the same effect, by just excluding the file manually. You can use the Gradle [file tree](https://docs.gradle.org/current/userguide/working_with_files.html#sec:file_trees) and use it as Spotless target. Untested example:Solution for bounded wild-cards
The plugin error message should be in "eclipse-workspace"/.metatdata/.log. I would appreciate if you can report the issue (with the Eclipse logs) to the [groovy-eclipse](https://github.com/groovy/groovy-eclipse) team. For a long period there was not much progress on the project, but it seems that they have for a couple of month now a team back together which is continuing the development. Please let me know as soon as a **groovy-eclipse** release is available which solves problem. I will integrated it to Spotless. I leave this issue open as a reminder to enhance `importOrder`for Groovy.boris-petrov commentedon Aug 18, 2018
@fvgh - groovy-eclipse has a
3.0.0
version as of a couple of weeks ago. I'm not sure whether you have to do something special (like release a new version of Spotless) for it to become available to us?Removed erroneous entry from plugin-maven CHANGES.md.