aboutsummaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/README.md27
-rw-r--r--docs/dev/architecture.md3
-rw-r--r--docs/dev/lsp-extensions.md35
-rw-r--r--docs/dev/syntax.md4
4 files changed, 47 insertions, 22 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 6b6824ded..417352c9d 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -177,6 +177,9 @@ There are many benefits to this:
177* less stuff printed during printf-debugging 177* less stuff printed during printf-debugging
178* less time to run test 178* less time to run test
179 179
180It also makes sense to format snippets more compactly (for example, by placing enum defitions like `enum E { Foo, Bar }` on a single line),
181as long as they are still readable.
182
180## Order of Imports 183## Order of Imports
181 184
182We separate import groups with blank lines 185We separate import groups with blank lines
@@ -311,7 +314,7 @@ We don't have specific rules around git history hygiene.
311Maintaining clean git history is encouraged, but not enforced. 314Maintaining clean git history is encouraged, but not enforced.
312We use rebase workflow, it's OK to rewrite history during PR review process. 315We use rebase workflow, it's OK to rewrite history during PR review process.
313 316
314Avoid @mentioning people in commit messages, as such messages create a lot of duplicate notification traffic during rebases. 317Avoid @mentioning people in commit messages and pull request descriptions (they are added to commit message by bors), as such messages create a lot of duplicate notification traffic during rebases.
315 318
316# Architecture Invariants 319# Architecture Invariants
317 320
@@ -358,14 +361,24 @@ There are two kinds of tests:
358The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for. 361The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for.
359If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test. 362If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test.
360 363
361To update test data, run with `UPDATE_EXPECTATIONS` variable: 364To update test data, run with `UPDATE_EXPECT` variable:
362 365
363```bash 366```bash
364env UPDATE_EXPECTATIONS=1 cargo qt 367env UPDATE_EXPECT=1 cargo qt
365``` 368```
366 369
367After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above. 370After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above.
368 371
372## TypeScript Tests
373
374If you change files under `editors/code` and would like to run the tests and linter, install npm and run:
375
376```bash
377cd editors/code
378npm ci
379npm run lint
380```
381
369# Logging 382# Logging
370 383
371Logging is done by both rust-analyzer and VS Code, so it might be tricky to 384Logging is done by both rust-analyzer and VS Code, so it might be tricky to
@@ -394,13 +407,7 @@ To log all communication between the server and the client, there are two choice
394 407
395There are also two VS Code commands which might be of interest: 408There are also two VS Code commands which might be of interest:
396 409
397* `Rust Analyzer: Status` shows some memory-usage statistics. To take full 410* `Rust Analyzer: Status` shows some memory-usage statistics.
398 advantage of it, you need to compile rust-analyzer with jemalloc support:
399 ```
400 $ cargo install --path crates/rust-analyzer --force --features jemalloc
401 ```
402
403 There's an alias for this: `cargo xtask install --server --jemalloc`.
404 411
405* `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection. 412* `Rust Analyzer: Syntax Tree` shows syntax tree of the current file/selection.
406 413
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md
index cee916c09..d0c6eea61 100644
--- a/docs/dev/architecture.md
+++ b/docs/dev/architecture.md
@@ -170,8 +170,7 @@ The innermost and most elaborate boundary is `hir`. It has a much richer
170vocabulary of types than `ide`, but the basic testing setup is the same: we 170vocabulary of types than `ide`, but the basic testing setup is the same: we
171create a database, run some queries, assert result. 171create a database, run some queries, assert result.
172 172
173For comparisons, we use [insta](https://github.com/mitsuhiko/insta/) library for 173For comparisons, we use the `expect` crate for snapshot testing.
174snapshot testing.
175 174
176To test various analysis corner cases and avoid forgetting about old tests, we 175To test various analysis corner cases and avoid forgetting about old tests, we
177use so-called marks. See the `marks` module in the `test_utils` crate for more. 176use so-called marks. See the `marks` module in the `test_utils` crate for more.
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index a0847dad3..1be01fd88 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -11,11 +11,13 @@ If you want to be notified about the changes to this document, subscribe to [#46
11 11
12## `initializationOptions` 12## `initializationOptions`
13 13
14As `initializationOptions`, `rust-analyzer` expects `"rust-analyzer"` section of the configuration. 14For `initializationOptions`, `rust-analyzer` expects `"rust-analyzer"` section of the configuration.
15That is, `rust-analyzer` usually sends `"workspace/configuration"` request with `{ "items": ["rust-analyzer"] }` payload. 15That is, `rust-analyzer` usually sends `"workspace/configuration"` request with `{ "items": ["rust-analyzer"] }` payload.
16`initializationOptions` should contain the same data that would be in the first item of the result. 16`initializationOptions` should contain the same data that would be in the first item of the result.
17It's OK to not send anything, then all the settings would take their default values. 17If a language client does not know about `rust-analyzer`'s configuration options it can get sensible defaults by doing any of the following:
18However, some settings can not be changed after startup at the moment. 18 * Not sending `initializationOptions`
19 * Send `"initializationOptions": null`
20 * Send `"initializationOptions": {}`
19 21
20## Snippet `TextEdit` 22## Snippet `TextEdit`
21 23
@@ -272,6 +274,11 @@ interface SsrParams {
272 query: string, 274 query: string,
273 /// If true, only check the syntax of the query and don't compute the actual edit. 275 /// If true, only check the syntax of the query and don't compute the actual edit.
274 parseOnly: bool, 276 parseOnly: bool,
277 /// The current text document. This and `position` will be used to determine in what scope
278 /// paths in `query` should be resolved.
279 textDocument: lc.TextDocumentIdentifier;
280 /// Position where SSR was invoked.
281 position: lc.Position;
275} 282}
276``` 283```
277 284
@@ -283,7 +290,7 @@ WorkspaceEdit
283 290
284### Example 291### Example
285 292
286SSR with query `foo($a:expr, $b:expr) ==>> ($a).foo($b)` will transform, eg `foo(y + 5, z)` into `(y + 5).foo(z)`. 293SSR with query `foo($a, $b) ==>> ($a).foo($b)` will transform, eg `foo(y + 5, z)` into `(y + 5).foo(z)`.
287 294
288### Unresolved Question 295### Unresolved Question
289 296
@@ -389,15 +396,27 @@ rust-analyzer supports only one `kind`, `"cargo"`. The `args` for `"cargo"` look
389 396
390Returns internal status message, mostly for debugging purposes. 397Returns internal status message, mostly for debugging purposes.
391 398
392## Collect Garbage 399## Reload Workspace
393 400
394**Method:** `rust-analyzer/collectGarbage` 401**Method:** `rust-analyzer/reloadWorkspace`
395 402
396**Request:** `null` 403**Request:** `null`
397 404
398**Response:** `null` 405**Response:** `null`
399 406
400Frees some caches. For internal use, and is mostly broken at the moment. 407Reloads project information (that is, re-executes `cargo metadata`).
408
409## Status Notification
410
411**Client Capability:** `{ "statusNotification": boolean }`
412
413**Method:** `rust-analyzer/status`
414
415**Notification:** `"loading" | "ready" | "invalid" | "needsReload"`
416
417This notification is sent from server to client.
418The client can use it to display persistent status to the user (in modline).
419For `needsReload` state, the client can provide a context-menu action to run `rust-analyzer/reloadWorkspace` request.
401 420
402## Syntax Tree 421## Syntax Tree
403 422
@@ -504,4 +523,4 @@ Such actions on the client side are appended to a hover bottom as command links:
504 | TITLE _Action1_ | _Action2_ | <- second group 523 | TITLE _Action1_ | _Action2_ | <- second group
505 +-----------------------------+ 524 +-----------------------------+
506 ... 525 ...
507``` \ No newline at end of file 526```
diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md
index c2864bbbc..d4bc4b07c 100644
--- a/docs/dev/syntax.md
+++ b/docs/dev/syntax.md
@@ -82,7 +82,7 @@ Points of note:
82An input like `fn f() { 90 + 2 }` might be parsed as 82An input like `fn f() { 90 + 2 }` might be parsed as
83 83
84``` 84```
85FN_DEF@0..17 85[email protected]
86 [email protected] "fn" 86 [email protected] "fn"
87 [email protected] " " 87 [email protected] " "
88 [email protected] 88 [email protected]
@@ -342,7 +342,7 @@ pub struct FnDef {
342impl AstNode for FnDef { 342impl AstNode for FnDef {
343 fn cast(syntax: SyntaxNode) -> Option<Self> { 343 fn cast(syntax: SyntaxNode) -> Option<Self> {
344 match kind { 344 match kind {
345 FN_DEF => Some(FnDef { syntax }), 345 FN => Some(FnDef { syntax }),
346 _ => None, 346 _ => None,
347 } 347 }
348 } 348 }