-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Dto Generation is broken for Formatter Options #8557
Comments
The problem is the LSP4J changed FormattingOptions to be a Map. Therefore first problem is that org.eclipse.che.api.languageserver.generator.DtoGenerator.generate(File, String, String, String[], String[]) excludes FormattingOptions because its class hierarchy contains LinkedHashMap which is not in one of the listed packages. You can work around the first problem by doing: diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
index e97c25e998..682302578f 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
@@ -222,6 +222,9 @@
<package>org.eclipse.che.api.languageserver.shared.event</package>
<package>org.eclipse.che.api.languageserver.shared.model</package>
</dtoPackages>
+ <classes>
+ <class>org.eclipse.lsp4j.FormattingOptions</class>
+ </classes>
<outputDirectory>${dto-generator-out-directory}</outputDirectory>
<genClassName>org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls</genClassName>
<impl>client</impl> which forces the Dto generation to happen and I suppose is there for this kind of situation. But then you hit the second problem. The second problem is possibly just cosmetic, I am not sure. But the to/from JSON in the generated FormattingOptions does not look like it will work because it will try to create a JSON object from an Either3 directly. This means updating the generator to support this new LSP4J use case. The simpler option The alternative solution is to simply not use a Dto for FormattingOptions at all. As FormattingOptions is never used as a LS parameter directly and always used as a field in other types (e.g. DocumentOnTypeFormattingParams.setOptions) then you could just do this because the to/fromJSon of the containing types don't delegate to FormattingOptions and rather handle the FormattingOptions as a Map. diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
index fe0c8f92e6..1ae5904947 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
@@ -188,7 +188,7 @@ public class LanguageServerFormatter implements ContentFormatter {
}
private FormattingOptions getFormattingOptions() {
- FormattingOptions options = dtoFactory.createDto(FormattingOptions.class);
+ FormattingOptions options = new FormattingOptions();
options.setInsertSpaces(Boolean.parseBoolean(getEditorProperty(EditorProperties.EXPAND_TAB)));
options.setTabSize(Integer.parseInt(getEditorProperty(EditorProperties.TAB_SIZE)));
return options; I'll submit a PR with the second solution. |
After applying code format (Edit -> Format or Alt+Shift+L) have an error
The text was updated successfully, but these errors were encountered: