-
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
CHE-8557: No Dto available for FormattingOptions #8784
Conversation
@svor Can you review/test please? |
Can one of the admins verify this patch? |
2 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@jonahkichwacoders |
@svor Can you provide me some instructions to test? I don't seem to have any failing tests at the moment and I can't get the error message you are getting. Which language server is it? Thanks! |
Hi, @jonahkichwacoders Could you please dispel my concerns about something that I see in this line: https://github.com/eclipse/che/blob/master/ide/che-core-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorBuilder.java#L36 If I understand correctly, we use @svor please correct me if my concerns are in vain. Thanks. |
@jonahkichwacoders {
"options": {
"insertSpaces": true,
"tabSize": 4
},
"textDocument": {
"uri": "/console-java-simple/src/main/java/org/eclipse/che/examples/A.java"
}
} I've created a test to see the error. This is the patch: Index: wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java (revision 2b9c7413a3e8555b627399b547a5bb1df02fecbf)
+++ wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java (revision )
@@ -10,6 +10,8 @@
*/
package org.eclipse.che.api.languageserver.dto;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -25,7 +27,9 @@
import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.WorkspaceEditDto;
import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionItem;
import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionList;
+import org.eclipse.che.dto.server.DtoFactory;
import org.eclipse.lsp4j.CompletionItem;
+import org.eclipse.lsp4j.DocumentFormattingParams;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.MarkedString;
import org.eclipse.lsp4j.ParameterInformation;
@@ -83,6 +87,20 @@
Assert.assertTrue(reflectionEquals(originalDto, convertedDto));
}
+ @Test
+ public void testDocumentFormattingParamsDeserializer() throws Exception {
+ JsonObject json =
+ (JsonObject)
+ new JsonParser()
+ .parse(
+ "{\"options\": {\"insertSpaces\": true,\"tabSize\": 4},\"textDocument\": {\"uri\": \"/console-java-simple/src/main/java/org/eclipse/che/examples/A.java\"}}");
+
+ DocumentFormattingParams params =
+ DtoFactory.getInstance().createDtoFromJson(json.toString(), DocumentFormattingParams.class);
+
+ Assert.assertTrue(params.getOptions().isInsertSpaces());
+ }
+
@Test
public void testEitherConversion() {
Either<String, MarkedString> either1 = Either.forLeft("foobar"); |
@jonahkichwacoders I see, thank you for the quick response. By a mistake (and I am ashamed for that) I must have missed that for #8318 - I see that there is a bunch of a new functionality, but I don't see the way we can appropriately test it. That is why I'm eager to know how we can ensure consistency and quality here. Could you please comment if you have any unit or integration tests for that purpose, or perhaps you can advise another way how we can make sure that solutions presented in actual pull request and in #8318 work well? |
@dkuleshov I too am sorry. I didn't realize this change was not covered by existing tests. The Debug's need for newer LSP4J did not really need other parts of Che updated, but with a single classloader there was no option. (I have been spoiled by years of Eclipse IDE development where independent changes can be truly independent thanks to OSGi.) So, how to test? I don't know, I guess we are talking about retrofitting tests at the moment. |
@svor A few things all going wrong together here.
That means this test works (but see problem 2):
but this one does not:
The fix for this is to configure the Gson object to understand LSP4J serializing/deserializing (by registering the appropriate type adapters, see
For problem 1 I am not sure of the general solution, but in this one use case I can provide a fix. For 2 and 3 I'll provide an update soon. |
Actually take that back. I can provide fix for 2 and 3. The other alternative is to roll back #8318 as that exposed these problems. Once you need the extra functionality you can reapply and fix the inconsistent json handling around lsp4j. |
Please don't push this! The last commit will cause compiler errors (as opposed to runtime exceptions). @svor I am not around tomorrow (Friday 16/Feb) so I won't be able to look at this again for a few days. Feel free to revert #8318 (and eclipse-che/che-dependencies#93) until a correct fix for upgrading LSP4J can be obtained. |
@jonahkichwacoders Understood, thanks. I guess we can't do a lot for current problem, but I thing we eventually will have to develop more convenient and transparent testing workflows to avoid unnecessary problems in the future. However that is obviously out of the scope of this pull request. |
@jonahkichwacoders Any news |
The Dto isn't needed for FormattingOptions as it is really a specialized Map and the types that contain a FormattingOptions field handle the field as a Map during JSON serialize/deserialize Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
The is necessary to ensure handling types which are of type Map are still instantiated in their real type. Consider DocumentFormattingParams.setOptions() which takes a FormattingOptions class. Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This is effectively a follow up CHE-3103 which uses Gson directly to serialize/deserialize Json. To support LSP4J's Either types, the either type adapter factory is needed. Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
01d6006
to
007a354
Compare
@tolusha Thanks for the ping. Rebased and pushed my set of fixes. This does not fix all LSP4J dto issues, but fixes all the formatting ones. The issues with hover that was there is still there. I recommend reviewing the use of casts in the dto generated code as the casts are converting compile time errors to runtime ones still. But AFAICT those parts of LSP are not yet in use (e.g. org.eclipse.lsp4j.TextDocumentRegistrationOptions) |
@jonahkichwacoders @dkuleshov |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/4485/ |
@tolusha @svor @vparfonov as discussed I can propose to do something like this
wdyt? |
+1 |
i agree |
@skabashnyuk Are you going to merge your changes to master branch? |
No. I hope authors of this pr will test it. it was just a prototype. |
@jonahkichwacoders |
@svor Sure, I can have a look. |
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Hello @jonahkichwacoders |
Load EitherTypeAdapterFactory for registration
Hi @svor, It looks fine to me, I won't have time to run it up today though. |
Thanks @jonahkichwacoders |
ci-test |
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.
lgtm
ci-test build report: |
@musienko-maxim Can you help to analyse test report please? |
The selenium session did not find new bugs |
@jonahkichwacoders so we are ready to merge. Maybe you want to add something? |
I'm good. Thanks. |
The Dto isn't needed for FormattingOptions as it is really a specialized
Map and the types that contain a FormattingOptions field handle
the field as a Map during JSON serialize/deserialize
Signed-off-by: Jonah Graham jonah@kichwacoders.com
What does this PR do?
Fixes formatting when using Language server
What issues does this PR fix or reference?
#8557
Release Notes
Docs PR