rust-lang / rls

Repository for the Rust Language Server (aka RLS)
Other
3.51k stars 257 forks source link

RLS responds code deletions when formatting with Unexpected Operator Error #1710

Open domibay-hugo opened 3 years ago

domibay-hugo commented 3 years ago

Using the Eclipse Corrosion Plugin with rls I found that I get wrong error reports when formatting the code. How to reproduce?

The Log File org.eclipse.corrosion.rls.log reports:

[t=1610534599878] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 28636

[t=1610534599878] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///path/to/my_project/src/my-project-1.rs"},"text":"\[...\]"}}
[t=1610535058631] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 291

[t=1610535058631] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":27,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":415,"character":0},"end":{"line":415,"character":6}},"rangeLength":6,"text":""}]}}
[t=1610535060371] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 291

[t=1610535060371] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":28,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":416,"character":0},"end":{"line":416,"character":6}},"rangeLength":6,"text":""}]}}
[t=1610535060769] org.eclipse.corrosion.rls to LSP4E:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"","message":"expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `vlocs`\n\nexpected one of 8 possible tokens","range":{"end":{"character":7,"line":416},"start":{"character":2,"line":416}},"severity":1,"source":"rustc"}],"uri":"file:///path/to/my_project/src/my-project-1.rs"}}
[t=1610535061666] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 291

[t=1610535061666] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":29,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":417,"character":0},"end":{"line":417,"character":6}},"rangeLength":6,"text":""}]}}

[t=1610535065149] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 291

[t=1610535065150] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":30,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":418,"character":0},"end":{"line":418,"character":6}},"rangeLength":6,"text":""}]}}
[t=1610535065336] org.eclipse.corrosion.rls to LSP4E:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"","message":"expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `vlocs`\n\nexpected one of 8 possible tokens","range":{"end":{"character":7,"line":416},"start":{"character":2,"line":416}},"severity":1,"source":"rustc"}],"uri":"file:///path/to/my_project/src/my-project-1.rs"}}

Although the source code file was resubmitted recently the submitted deletions lead to a corrupted Index of the File in rls accusing of an error where there isn't any.

domibay-hugo commented 3 years ago

On the affected line I deleted the Semicolon ; and reinserted it and saved the document but the accused error never is notified as corrected.

[t=1610537117415] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 293

[t=1610537117415] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":55,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":416,"character":51},"end":{"line":416,"character":52}},"rangeLength":1,"text":""}]}}
[t=1610537129256] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 293

[t=1610537129257] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"version":2,"uri":"file:///path/to/my_project/src/my-project-1.rs"},"contentChanges":[{"range":{"start":{"line":416,"character":51},"end":{"line":416,"character":51}},"rangeLength":0,"text":";"}]}}
[t=1610537134176] LSP4E to org.eclipse.corrosion.rls:
Content-Length: 28616

[t=1610537134176] LSP4E to org.eclipse.corrosion.rls:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///path/to/my_project/src/my-project-1.rs"},"text":"\[..\]"}}

What should be the correct Procedure and LSP Communication to get the Correction Notification ?