-
Notifications
You must be signed in to change notification settings - Fork 814
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
Compatibility with statically typed languages #39
Comments
I would support this breaking change, to make things more consistent. |
Point well taken. Would a return type of the form {
items: CompletionItem[];
list: CompletionList
} Work for you ? |
In this case, just return a |
@dbaeumer What about MarkedString, how will it be modeled? |
As discussed in microsoft/language-server-protocol#39 statically typed languages like Java do not support mixed return types, which in the case of Completion Request is `CompletionItem[] | CompletionList`. Thus Typefox - the Java client of the language server protocol - accepts only `CompletionList`, which contains `CompletionItem[]`. In order to work with Eclipse Che and other IDEs using the Typefox client, the Completion Request handler in the PHP language server should return `CompletionList` instead of `CompletionItems[]`.
I would vote for dropping the simple
|
@spoenemann |
Actually |
I support @spoenemann here on the idea of dropping the direct string in a newer version of the protocol. It makes parsers more complex without adding much value. |
@mickaelistria You can't use a |
@spoenemann noticed that my Java skills got a little rusty. Would this be a solution for C# as well ? |
Probably yes, provided you can customize the JSON input / output. For Java we use the Gson library and we implemented a type adapter for Either. |
Given were we are with the protocol I think we can't break this right now. I try to make things not worse for statically types languages, but the priority right now is to now break existing clients. I will close this issue since I don't see us acting (by breaking) on this in the next 6 - 12 months. Please ping if you think otherwise. |
Some parts of the protocol cannot be implemented properly in statically typed languages such as Java. Examples:
CompletionItem[] | CompletionList
type MarkedString = string | { language: string; value: string };
Of course this can be handled during the conversion between JSON and the specific Java data structures. But wouldn't it be better to drop some flexibility in favor of more explicit typing, so this kind of conversion would not be necessary? For example, with a JSON library such as Gson most of the protocol parsing and serialization can be done with the generic capabilities of the library, but ambiguities such as those mentioned above require to implement special cases for the respective types.
The text was updated successfully, but these errors were encountered: