diff options
author | Aleksey Kladov <[email protected]> | 2020-12-03 15:08:27 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-12-03 15:08:27 +0000 |
commit | 3e00bfce2b1f53b14ec89ddb249364eac23f5b1e (patch) | |
tree | edcfa6a87f28731c85317bb977c526f4c0e92585 /docs | |
parent | 5a1306a43652d914035b2cf0b703f4bfd3451a33 (diff) |
Document statelessness invariant
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/README.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index abb387e8e..ca324493f 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -170,6 +170,22 @@ In general, API is centered around UI concerns -- the result of the call is what | |||
170 | The results are 100% Rust specific though. | 170 | The results are 100% Rust specific though. |
171 | Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at. | 171 | Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at. |
172 | 172 | ||
173 | ## LSP is sateless | ||
174 | |||
175 | The protocol is implemented in the mostly stateless way. | ||
176 | A good mental model is HTTP, which doesn't store per-client state, and instead relies on devices like cookies to maintain an illusion of state. | ||
177 | If some action requires multi-step protocol, each step should be self-contained. | ||
178 | |||
179 | A good example here is code action resolving process. | ||
180 | TO display the lightbulb, we compute the list of code actions without computing edits. | ||
181 | Figuring out the edit is done in a separate `codeAction/resolve` call. | ||
182 | Rather than storing some `lazy_edit: Box<dyn FnOnce() -> Edit>` somewhere, we use a string ID of action to re-compute the list of actions during the resolve process. | ||
183 | (See [this post](https://rust-analyzer.github.io/blog/2020/09/28/how-to-make-a-light-bulb.html) for more details.) | ||
184 | The benefit here is that, generally speaking, the state of the world might change between `codeAction` and `codeAction` resolve requests, so any closure we store might become invalid. | ||
185 | |||
186 | While we don't currently implement any complicated refactors with complex GUI, I imagine we'd use the same techniques for refactors. | ||
187 | After clicking each "Next" button during refactor, the client would send all the info which server needs to re-recreate the context from scratch. | ||
188 | |||
173 | ## CI | 189 | ## CI |
174 | 190 | ||
175 | CI does not test rust-analyzer, CI is a core part of rust-analyzer, and is maintained with above average standard of quality. | 191 | CI does not test rust-analyzer, CI is a core part of rust-analyzer, and is maintained with above average standard of quality. |