Open manuEbg opened 3 years ago
Two quick questions:
-Xlint:unchecked
suggested by the note?As a general hint: This sounds like an incorrect usage of Java generics. Maybe you forgot the diamond operator (<>
) or some concrete name for a generic type parameter somewhere in your code?
The first google result for "uses unchecked or unsafe operations" explains this quite nicely.
After having a quick peek into the code, I can find at least one major issue with generics in the completion method:
CompletableFuture<?> completion = server.getTextDocumentService().completion(params);
You never want to use <?>
in generics, because this is essentially the equivalent of throwing your hands in the air and yelling "the fuck do I care what type this is!".
At this point, the correct return type that you get is CompletableFuture<Either<List<CompletionItem>, CompletionList>>
. I admit that this is a little unwieldy, but since Java 10 you can use the type inference keyword var
for this. You can think of this as the safe variant of <?>
, which does not throw away the generic type information, but rather tells the compiler to determine the most fitting type for you.
So the above line should probably be changed to...
var completion = server.getTextDocumentService().completion(params);
After that, you can unpack the value properly by first checking whether you got a Java list or a CompletionList
and then proceeding accordingly.
I am not sure what I have done, but today I noticed the following notes during Compilation of the MopeLspServer.
I cant remember if i saw them earlier... but I think they are connected to my Changes in the feature/Diagnostics Branche
Has anyone an Idea what this means?
After reading through some StackOverflow Questions i think this has something to do with unsafe Typehandling... But I am not sure where i did this in MopeModelicaService.java