-
Notifications
You must be signed in to change notification settings - Fork 148
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
Incorrect return type for textDocument/documentSymbol
#252
Comments
I think it is a bug in the protocol. In the initial implementation done in #217, the type was declared as you are suggesting. I later changed that to the more relaxed type because
|
This all makes sense, but I think the difference between the textDocument.documentSymbol.hierarchicalDocumentSymbolSupport = true then you get an array of For the So it makes sense to mix the
I think this is not the best analogy. Let's consider we would like to do a const params: CodeActionParams = { /* initialize */ };
params.context.only = ['quickfix', 'refactor']; We are not checking and throwing a runtime exception if any of the How should we proceed with this? Does this worth a follow-up question (as a GH issue) in the |
Returning a mixed list of symbol informations and document symbols won't work properly in VS Code, clients are expecting to have either one or another:
If it is hard to parse on our side, I think we should ask on the LSP repo, maybe they will be willing to change it and adopt in VS Code as well. In order to parse we can check each element if it is a document symbol or a symbol information, and if one is, then assume that others as well. |
@spoenemann it may be easier to implement in lsp4j, but handling the result is actually easier if you get a |
It should not matter what is easier to implement or to consume, but what is defined in the specification. As @akosyakov pointed out, if we offer the current LSP4J API to clients as is, their LS implementation could break at runtime. Although this comment clearly states the desired return type of the |
The specification is clearly designed for TypeScript. Implementing it 100% correctly in Java is not possible because of the heavy usage of the TypeScript type system. But since the underlying message format is just JSON, it doesn't matter so much how close the Java type definitions are to the TypeScript types as long as we can produce compatible JSON data. |
Otherwise, I'm fine with changing the response type to the original one as requested, but we should think about whether breaking the API again is really worth it. |
Otherwise, it can break at runtime, that's my concern. |
I agree with @spoenemann, it might be more correct and constraining to change it as suggested, but it will break existing clients. Nobody would return a heterogenous list here anyway. A middle ground would be to add that constraint to the JavaDoc instead of changing the signature. |
No, the decision to only allow DocumentSymbol[] | SymbolInformation[] was on purpose. And as pointed out correctly We decided that way since the first one allows for a hierarchical display and the values can be used in an outline view. The first one is basically a flat list. If we mix them it is not clear how we would display them. |
Thanks for the clarification, @dbaeumer.
@svenefftinge, are we good with this approach? I adapt this GH issue and take care of the JavaDoc updates. |
@kittaakos so we will keep the current api? |
Yes, that's the plan. I still need to update the JavaDoc for the |
no i just want to verify we need no action in Xtext for that |
…ocumentSymbol`. Closes eclipse-lsp4j#252. Signed-off-by: Akos Kitta <[email protected]>
GH-252: Updated the documentation of the `textDocument/documentSymbol`.
…ocumentSymbol`. Closes eclipse-lsp4j#252. Signed-off-by: Akos Kitta <[email protected]>
Fixes eclipse-lsp4j#252 Signed-off-by: azerr <[email protected]>
According to the LSP specification the return type of the
textDocument/documentSymbol
should be the type ofDocumentSymbol[] | SymbolInformation[] | null
.The current Java API has
List<Either<SymbolInformation, DocumentSymbol>>
return type which is equivalent to(DocumentSymbol | SymbolInformation)[] | null
.It should be
Either<List<DocumentSymbol>, List<SymbolInformation>>
instead to comply with the protocol.I think this is a bug.
The text was updated successfully, but these errors were encountered: