-
Notifications
You must be signed in to change notification settings - Fork 408
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
workspaceEdit textDocument version is always 0 #1695
Comments
Any inputs on this? Do you consider this a bug in eclipse.jdt.ls or do you think that clients should accept/ignore version 0? |
In VSCode, it looks like the text document starts at version 1 from the initial didOpen(..) and various code actions do specify a version of 0 without issue. However, I can't see where it says this is required, or that 0 is special ( https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier ). In fact, it looks like the version should always be increasing so I think you're right that this likely needs to become null if we don't have access to the actual version. @testforstephen any specific reason 0 is used as opposed to null (vscode-specific implementation?), and is it likely safe to switch over ? |
Yes, "null" is better. On JDT language server side, we don't actually maintain version information for the files, so it's impossible to specify a correct version number in the workspace edit response. Having said that, it is more appropriate to give it "null". However, the current LSP4j model only accepts "VersionedTextDocumentIdentifier" in TextDocumentEdit, which does not support null values. According to the LSP, it should be "OptionalVersionedTextDocumentIdentifier". This is a bug in LSP4j and we have to fix it in LSP4j first. |
@testforstephen , when I look at https://github.com/eclipse/lsp4j/blob/593cdb65217fd406267812ee5394342617e32f71/org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/adapters/VersionedTextDocumentIdentifierTypeAdapter.xtend#L26 , shouldn't this support a 'null' value even if the "OptionalVersionedTextDocumentIdentifier" isn't actually being used as a class ? I tried replacing "0" with null and it seems to be working as expected. |
We figured out that the type got changed in 3.16 of the protocol to OptionalVersionedTextDocumentIdentifier and before that the version wasn't allowed to be null. So neovim now also treats 0 the same as null. Might still make sense to change it but I wouldn't consider this as bug anymore. |
Ok, it uses the JSON Adapter to deal with null, not straightforward, but should work. |
…ull. - A TextDocumentEdit's 'textDocument' field is an OptionalVersionedTextDocumentIdentifier whose version can be null to indicate that the version is not known - Fixes eclipse-jdtls#1695 Signed-off-by: Roland Grunberg <[email protected]>
…ull. - A TextDocumentEdit's 'textDocument' field is an OptionalVersionedTextDocumentIdentifier whose version can be null to indicate that the version is not known - Fixes #1695 Signed-off-by: Roland Grunberg <[email protected]>
In the neovim lsp client we recently added
resourceOperations
support and that changed theworkspaceEdit
result from eclipse.jdt.ls to includedocumentChanges
with a versioned textDocument where theversion
is always 0.For example, if I open a file and type something like
int x = 10 + 20
and then trigger a extract variable refactoring on20
, previously there was the following message flow:Now this changed to:
Neovim outputs an error if the
version
is present and if it is lower than the expected buffer version.If I'm not mistaken the version is fixed to
0
in eclipse.jdt.lshttps://github.com/eclipse/eclipse.jdt.ls/blob/8028f3ffc04e7f4695ffa08d058912e2003a0116/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ChangeUtil.java#L280
Based on my interpretation of the spec, that neovim rejects the workspace edit as outdated is legitimate and eclipse.jdt.ls is not supposed to hardcode it to 0
I think given that
textDocument
is aOptionalVersionedTextDocumentIdentifier
, eclipse.jdtls could sendnull
as version instead of 0 if the version information is not available internallySee https://microsoft.github.io/language-server-protocol/specification#textDocumentEdit
The text was updated successfully, but these errors were encountered: