-
Notifications
You must be signed in to change notification settings - Fork 137
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
Enable option to format edited code in SWT examples, snippets and tests #1238
Enable option to format edited code in SWT examples, snippets and tests #1238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is not a good idea. We had discussions in the past. Mixing old/new code styles wouldn't be helpful.
How about running the formatter once for every project and activate this in the future? I mean so the code styles look all "new"? |
I believe it would be OK for SWT test/example projects except SWT main code itself, which is very "special" and where re-formatting would cause only troubles. |
What kind of problems could be caused by reformatting the code? You mean like actually breaking it (failed tests/new bugs)? |
No, the git blame will be unusable, and that is the main issue, a blocker. Beside this, yes, no one will be able to review tons of reformatted production code, so an occasional formatter bug may introduce some bug too. Less likely, but possible. |
0a779e8
to
3ebe328
Compare
3ebe328
to
503b3c1
Compare
@iloveeclipse I made some changes and adapted the commit text, the description of this PR and its title. Only the tests and examples have the preferences (all projects). Would you please review again? |
I have two questions/remarks on this:
|
Good point. I suggest using the "Eclipse [built-in]" profile. Agreed @HeikoKlare / @HannesWell ?
@HeikoKlare which ones do you mean and in which file(s)? |
That's the one we use in the Platform repos, so yes, that's probably reasonable. But it would be good to check whether the projects to which you apply it are in any way conforming to those settings.
I meant every file with further changes to cleanup preferences than only the formatter thing, but it now actually just shows that I misunderstood this PR. I expected the changes to be applied to auto-save actions, but it's actually about cleanup.
In general, I see a mismatch between the project that should be affected by this PR (according to the commit message) and the actually modified projects. |
503b3c1
to
21d9e8d
Compare
👍
It is actually about the save actions. I originally changed the 2 preferences (
The name of the configuration looks confusing because of the prefix
I changed the description of this PR to clarify these points.
I'm not interested in any other
I changed the commit text |
7d50e06
to
a0c0d85
Compare
Thanks for clarification. I mixed up the properties names. Having the commit message adapted according is good.
My comment was based on the assumption that this affects clean-up operations rather than save actions. Still, the PR is not limited to enabling auto-formatting edited code. It also enables a bunch of other save actions in some of the projects, like |
Change these 2 preferences from false to true in several projects to achieve this: - sp_cleanup.format_source_code - sp_cleanup.format_source_code_changes_only Set the formatter "Eclipse [built-in]" explicitly in the projects.
a0c0d85
to
433bb2f
Compare
I changed the newly added JDT UI preferences so they only set the necessary configurations, i.e. they went from this: ... to this: |
@iloveeclipse have I addressed your comments? |
Yes, thanks. Where are the new |
They were automatically created when I enabled the project-specific settings for the formatter and selected the "Eclipse [built-in]" profile, i.e. they do not come from a single source but "from the UI (preferences dialog)" |
Having unified code formatting and a code that has it applied is something that I think is good in general. Since this PR adds many new lines of preferences, have you considered to link the jdt preference files from a common location e.g. from the |
I really like that idea. @Bananeweizen explained in a platform PR that they copy preferences files once in a while from a central place to have them consistent across all projects (eclipse-platform/eclipse.platform#1282 (comment)). Linking them instead sounds like an even better solution. You just have to be aware that whenever you change something in the according preferences, all projects (using that same linked file) will be affected, but I think that's acceptable as they will not be changed often and should then be reviewed anyway.
Thank you for that pointer. I was not aware of that idea. It sounds really useful. |
@HannesWell I like the idea but it has a big drawback: only the whole I propose we leave that for the future since we would need to agree on what are some sinful shared settings for all examples and tests. |
You can also link files, like done for .classpath files in the SWT fragments, e.g.:
And even for the .api_filters within the .settings folder (just like it would be for the preferences file):
|
Thank you for the hint @HeikoKlare , I was doing it wrong (I was creating links from the Windows Explorer), that's why it didn't work. I replaced the newly created configurations with links and stored the contents under Some points to consider:
|
They were all newly created anyway so now they reside in one single place and are shared across some projects
18b6363
to
ef79ed6
Compare
Could this then be done in advance (in another PR if you prefer)? This now adds even more lines than before.
That would is fine for me. Or maybe |
I had a short look into this and unless you want to provide a PR for that, I could do it this evening. At least unifying the jdt.core preferences should be doable in advance. |
Please see #1253. |
@HannesWell thank you! I just reviewed it, it looks very good :-) . I will then leave this PR on hold (as a draft) until #1253 is merged and rebase my changes in order to avoid duplication/inconsistencies. |
There are a number of conflicts here. Do you plan to finish this one or it should be abandoned? |
I'll take a look at it next week (I'm in Mainz for the OCX this week) and I will fix it/abandon it accordingly. I can always create a new PR if I come back to it in the future. |
What it does
The purpose of this PR is to set the Save Actions of the Test/Example projects in SWT to:
sp_cleanup.format_source_code
andsp_cleanup.format_source_code_changes_only
(Right click ->) Source -> Format
--> Achieved by enabling theformatter_profile
and theformatter_settings_version
in the JDT UI preferences by adding lots of changes to the JDT Core preferences (Note: those changes are automatically added when one enables the specific project configuration and sets the "Eclipse [built-in]" as the formatter (see Enable option to format edited code in SWT examples, snippets and tests #1238 (comment))What it doesn't do
(Right Click ->) Source -> Clean Up