rust-lang / rust-lang/rust-analyzer
LSP: Validate responses against client capabilities
Open
Nobody has claimed this yet.
A-lsp
S-actionable
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
There are a number of places where responses from the LSP should be altered based on client and server support. Responses for things like textDocument/rename that return a WorkspaceEdit are a good example of this:
export interface WorkspaceEdit {
/**
* Holds changes to existing resources.
*/
changes?: { [uri: string]: TextEdit[]; };
/**
* Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
* are either an array of `TextDocumentEdit`s to express changes to n different text documents
* where each text document edit addresses a specific version of a text document. Or it can contain
* above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
*
* Whether a client supports versioned document edits is expressed via
* `workspace.workspaceEdit.documentChanges` client capability.
*
* If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
* only plain `TextEdit`s using the `changes` property are supported.
*/
documentChanges?: (TextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the LSP response handling for textDocument/rename and WorkspaceEdit, then inspect how client capabilities are represented. Map the other response types that need capability-based adaptation; done means unsupported WorkspaceEdit features are converted or omitted according to the client's capabilities.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100