-
Notifications
You must be signed in to change notification settings - Fork 192
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
Inconsistent code formatting of closures (with input parameters) assigned to instance fields #293
Comments
I read your comment at #328 (comment), but please... could you at least try to figure out how to fix this so that the "bouncing" is avoided? It's really the most annoying problem of Greclipse right now for us... |
Hi Eric, However, the bouncing effect remains. I would really appreciate some kind of action from you on this. Even if it's not 100% correct with respect to formatting rules, having Greclipse always putting closure parameters on the first line or on the next line in a consistent way would really improve the situation. |
Yes indeed, the dirty buffer upon save was really bugging me; it just took a deep dive to find out why it was happening.
As for the source formatter, that's really a can of worms I don't want to get into. As you can see from Content Assist, for every bug solved, there are two more that get noticed along the way.
Do you have format as a save action? Is that why it keeps making edits? I have found the formatter to be so in need of help that I do not use it to format my Groovy ever.
|
Yes, I do have save actions, I make extensive use of it for my projects and I can't simply disable it for Groovy code. |
I can take a look. Could you do me a favor and submit all your known Content Assist issues in one go? I get the feeling you have a bit of a backlog; I'm chasing a bit of a moving target here...
|
Sorry for opening so many issues, I thought it was better for you to separate each issue in different reports. If you prefer I can make an only report with the old issues, and maybe group all issues I find during a week of work in some sort of weekly report? |
I do prefer the issues to be separated as you have been submitting them. I would prefer to have them all up front instead of in small batches.
|
Let me add something, though: you talk about chasing a moving target and I perfectly understand what you're saying. I discussed a lot with previous Pivotal committers about the state of Greclipse and its endless problems... and I suspect it was abandoned by Pivotal in part due its immaturity. |
Ok, so I will keep up posting separate issues. As for the "batch" approach, apologies... I try to do my best to keep some sort of "constant" pace, but there are some periods in which I really don't have enough time to verify, test, prepare test cases and open issues. I'll try to do my best. |
Thanks. It helps to see the bigger picture, because several issues may be related to the same thing under the covers. Ex: issues around delegate type within closure.
|
Sounds good. I appreciate the feedback. Just be aware I'm making fixes in my spare time here, so I am mostly focused on stuff that has a direct impact to my day job.
|
Yes, I perfectly understand this. Thank you very much for your commitment and patience! |
One of the forms comes from within public TextEdit getBeautifiEdits() throws MalformedTreeException, BadLocationException {
MultiTextEdit edits = new MultiTextEdit();
combineClosures(edits);
formatLists(edits);
correctBraces(edits);
removeUnnecessarySemicolons(edits);
formatter.getTokens().dispose();
return edits;
} |
Okay, so |
Hi Eric, I tested this with 2.9.2.xx-201711060326-e46 and it seems to work fine, no more bouncing here!!!! Thank you so much, really! :-) |
This was the old GRECLIPSE-1787
Consider the following code:
Hit Ctrl+Shift+F to format this code. Now press Ctrl+Shift+F again. Then once again... and so on.
As you can see, the closure input parameters bounce up and down.
Although this might seem a "cosmetic" problem, it's indeed one of the most annoying problems I encounter in my daily work with Greclipse. In fact, I have some projects using the action to format source code upon saving (this is to ease collaboration). In this scenario, when there is some code like the above one, whenever you save with Ctrl+S the editor stays dirty, because the "format code" action changes the code after the editor has been saved, causing it to be dirty again. If you press Ctrl+S again, the same happens, because of the bouncing effect described above. And so on. The only way to get a saved and clean editor, is to hit Ctrl+S folloed by Ctrl+Z (which undoes the last format action), which is not so intuitive...
This also causes useless diffs in the SCM, for code that changes on each file save even if its semantics have not changed.
IMHO, the formatter should place the closure input parameters on the first line, if the maximum line length is respected, unless some other option in the Java/Groovy code style imposes a new line after the closure opening bracket.
The text was updated successfully, but these errors were encountered: