Also read JDT UI project prefs to configure cleanups#2870
Also read JDT UI project prefs to configure cleanups#2870rgrunber merged 1 commit intoeclipse-jdtls:masterfrom
Conversation
ec89bf8 to
e41b299
Compare
rgrunber
left a comment
There was a problem hiding this comment.
Wouldn't it have been easier to create a mapping like :
Map.of(
CleanUpConstants.STRINGCONCAT_TO_TEXTBLOCK, "stringConcatToTextBlock",
CleanUpConstants.VARIABLE_DECLARATIONS_USE_FINAL, "addFinalModifier",
...
...
)
and then read the jdt.ui preference node for each supported+enabled cleanup and send them over in the java.cleanup.actionsOnSave after going through the mapping (client-side) ? Or did you not like the idea of having to independently track the IDs JDT-LS assigns ?
This will probably work as well, but it's just code that JDT-LS shouldn't have to know about when there's already a mechanism to configure the cleanups.
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/SaveActionHandler.java
Outdated
Show resolved
Hide resolved
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/SaveActionHandler.java
Outdated
Show resolved
Hide resolved
e41b299 to
660557f
Compare
Yes. However I was unsure here: if some 3rd party contributors may provide some cleanups, then it's easier to make it also possible for those to declare some secondary ids. Or even if we add cleanups into JDT-LS directly, it still seems easier to maintain secondary ids directly in the class, so that it doesn't have to be added in a separate and easily forgotten place.
A secondary goal is also to add support for project-specific formatting in JDT-LS directly, making it possible to process eclipse .settings/ file when existent, even in VSCode.
The current mechanism doesn't allow project-specific configuration. So IMO, it's better to have the mapping in JDT-LS directly and make JDT-LS capable of understanding some settings of JDT-UI that may be configured in the project. But if you think that approach is problematic, I can change it. |
eceff02 to
e7aaf87
Compare
I don't think there's interest in
I think there's a case where a change was introduced into JDT Core that had settings per compilation unit, and in JDT-LS we set options like that in some instances. workspace/configuration, which takes a URI parameter.
@testforstephen do you know why something like sending a |
|
OK, I agree eclipse prefs files are hard to manually edit and may not be as comfortable as editorconfig or other settings files (although I'm not much convinced json is better without advanced editor capability to guide user in creating the right settings). This particular topic has been long discussed in Eclipse Platform, but nothing was attempted to improve preferences formatting so far, and I doubt it will be addressed soon. |
|
Let's just leave the change for now and we can merge for 1.24.0. The approach is a bit cleaner and the entrypoints, The concern I have is that we're basically sending data between eclipseide-jdtls and JDT-LS by using the Eclipse platform API (preference nodes) as opposed to the LSP connection for something the LSP connection could handle. Of course we've added plenty of |
I see it more as a project configuration file, kind of similar to pom.xml or build.gradle or .classpath or other .prefs file (like m2e's or jdt.core's ones) that describe what to do with the project and allow to modify the behavior of the LS without really being part of the LS spec either. In that context,
I don't fully understand it. Can you please explicit what it means for the current change? ie is there something I should modify? |
No changes needed here. |
| public String getIdentifier() { | ||
| return "qualifyMembers"; | ||
| public Collection<String> getIdentifiers() { | ||
| return List.of("qualifyMembers"); |
There was a problem hiding this comment.
No interest in enabling this & qualifyStaticMembers ?
There was a problem hiding this comment.
Those cleanups don't map to a single JDT-UI cleanup id. JDT-UI has a single cleanup id for "style" which delegates to other configurations. The grain is different in JDT-LS to easily map those cleanups to a JDT-UI id
rgrunber
left a comment
There was a problem hiding this comment.
Overall looks good. Just a question regarding why you didn't add anything for the 2 cleanups that qualify, and a quick fix for an existing issue we can address here.
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/cleanup/CleanUpRegistry.java
Outdated
Show resolved
Hide resolved
Also logs unknown cleanups
e7aaf87 to
4d41228
Compare
@rgrunber Since VS Code supports file-level indentation, which has a significant impact on formatting, we make an additional request to synchronize it with the language server. However, didChangeConfiguration is not supported at the file level. VS Code only supports settings at the user, workspace, and root folder levels. |
No description provided.