-
Notifications
You must be signed in to change notification settings - Fork 126
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 "organize imports on save" #2579
Comments
Yes, it makes sense to organize imports on save. |
I also thinks this makes sense. I would also be in favor of reorganizing the imports in a mass change. |
There is one small issue, why I'm not 100% happy with automatic organize import: it doesn't respect existing wildcard imports. I know that many people are actively opposed to wildcard imports, so here is my reason for liking them: I actually look at imports once in a while to get an idea of what a class depends on. When organize imports expands a nice As a workaround I hope we can agree on a threshold for automatic wildcard imports. I'd propose a value of 10. |
I agree. Doing this incrementally would mean a lot of trouble with experimental changes, which trigger organize imports, to the effect that reverting the experimental change will not put the file back into a clean state. A mass change on imports is acceptable, because import lists are not the typical subject of research into the git history :) The typical caveat remains: we need to be 100% sure that the mass change does not introduce any unrelated changes, and it must happen in the same PR that enables automatic organize imports on save, to avoid any drift. And a second caveat: it would create one more reason why changes must be prepared in the original Eclipse project context, to avoid any drift later on. For comparison: remove-trailing whitespace was globally enabled some years ago, and still once in a blue moon I see unrelated changes on save, because some commit succeeded to sneak in unwanted trailing white space :) |
this raises the question: how to coordinate this with BETA_JAVA23?
|
when would that be next time and how long will be the duration? |
when: soon after Java 23 GA (2024/09) duration: this can probably be negotiated |
Organize imports, which was accidentally enabled in o.e.j.core.tests.model, just created a flood of new warnings, all of the style:
I'll manually revert the "disorganize" :) to get a green build. |
With project specific .settings\org.eclipse.jdt.ui.prefs: org.eclipse.jdt.ui.importorder= sp_cleanup.organize_imports=true org.eclipse.jdt.ui.ondemandthreshold=10 org.eclipse.jdt.ui.staticondemandthreshold=10 eclipse-jdt#2579
automated cleanup eclipse-jdt#2579
automated cleanup eclipse-jdt#2579
With project specific .settings\org.eclipse.jdt.ui.prefs: org.eclipse.jdt.ui.importorder= sp_cleanup.organize_imports=true org.eclipse.jdt.ui.ondemandthreshold=10 org.eclipse.jdt.ui.staticondemandthreshold=10 eclipse-jdt#2579
automated cleanup eclipse-jdt#2579
automated cleanup eclipse-jdt#2579
With project specific .settings\org.eclipse.jdt.ui.prefs: org.eclipse.jdt.ui.importorder= sp_cleanup.organize_imports=true org.eclipse.jdt.ui.ondemandthreshold=10 org.eclipse.jdt.ui.staticondemandthreshold=10 #2579
I would like to enable organize imports on save and would like to get feedback from jdt.core commiters.
Known benefit: i don't have to manually remove no longer used imports.
Known downslde: The first commit on each file will have a longer - unrelated - patch size.
optional workaround: reorganize all imports once for all files.
history: at some point of time the sort order for imports was changed.
If you start a discussion and mention me, I will add more details there. Hint: if the change of strategy is done well, I'm not strictly against it.
Originally posted by @stephan-herrmann in #1700 (comment)
The text was updated successfully, but these errors were encountered: