diff options
Diffstat (limited to 'docs/dev')
-rw-r--r-- | docs/dev/README.md | 27 | ||||
-rw-r--r-- | docs/dev/architecture.md | 3 | ||||
-rw-r--r-- | docs/dev/lsp-extensions.md | 35 | ||||
-rw-r--r-- | docs/dev/syntax.md | 4 |
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 | ||
180 | It also makes sense to format snippets more compactly (for example, by placing enum defitions like `enum E { Foo, Bar }` on a single line), | ||
181 | as long as they are still readable. | ||
182 | |||
180 | ## Order of Imports | 183 | ## Order of Imports |
181 | 184 | ||
182 | We separate import groups with blank lines | 185 | We separate import groups with blank lines |
@@ -311,7 +314,7 @@ We don't have specific rules around git history hygiene. | |||
311 | Maintaining clean git history is encouraged, but not enforced. | 314 | Maintaining clean git history is encouraged, but not enforced. |
312 | We use rebase workflow, it's OK to rewrite history during PR review process. | 315 | We use rebase workflow, it's OK to rewrite history during PR review process. |
313 | 316 | ||
314 | Avoid @mentioning people in commit messages, as such messages create a lot of duplicate notification traffic during rebases. | 317 | Avoid @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: | |||
358 | The 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. | 361 | The 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. |
359 | If 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. | 362 | If 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 | ||
361 | To update test data, run with `UPDATE_EXPECTATIONS` variable: | 364 | To update test data, run with `UPDATE_EXPECT` variable: |
362 | 365 | ||
363 | ```bash | 366 | ```bash |
364 | env UPDATE_EXPECTATIONS=1 cargo qt | 367 | env UPDATE_EXPECT=1 cargo qt |
365 | ``` | 368 | ``` |
366 | 369 | ||
367 | After adding a new inline test you need to run `cargo xtest codegen` and also update the test data as described above. | 370 | After 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 | |||
374 | If you change files under `editors/code` and would like to run the tests and linter, install npm and run: | ||
375 | |||
376 | ```bash | ||
377 | cd editors/code | ||
378 | npm ci | ||
379 | npm run lint | ||
380 | ``` | ||
381 | |||
369 | # Logging | 382 | # Logging |
370 | 383 | ||
371 | Logging is done by both rust-analyzer and VS Code, so it might be tricky to | 384 | Logging 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 | ||
395 | There are also two VS Code commands which might be of interest: | 408 | There 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 | |||
170 | vocabulary of types than `ide`, but the basic testing setup is the same: we | 170 | vocabulary of types than `ide`, but the basic testing setup is the same: we |
171 | create a database, run some queries, assert result. | 171 | create a database, run some queries, assert result. |
172 | 172 | ||
173 | For comparisons, we use [insta](https://github.com/mitsuhiko/insta/) library for | 173 | For comparisons, we use the `expect` crate for snapshot testing. |
174 | snapshot testing. | ||
175 | 174 | ||
176 | To test various analysis corner cases and avoid forgetting about old tests, we | 175 | To test various analysis corner cases and avoid forgetting about old tests, we |
177 | use so-called marks. See the `marks` module in the `test_utils` crate for more. | 176 | use 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 | ||
14 | As `initializationOptions`, `rust-analyzer` expects `"rust-analyzer"` section of the configuration. | 14 | For `initializationOptions`, `rust-analyzer` expects `"rust-analyzer"` section of the configuration. |
15 | That is, `rust-analyzer` usually sends `"workspace/configuration"` request with `{ "items": ["rust-analyzer"] }` payload. | 15 | That 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. |
17 | It's OK to not send anything, then all the settings would take their default values. | 17 | If a language client does not know about `rust-analyzer`'s configuration options it can get sensible defaults by doing any of the following: |
18 | However, 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 | ||
286 | SSR with query `foo($a:expr, $b:expr) ==>> ($a).foo($b)` will transform, eg `foo(y + 5, z)` into `(y + 5).foo(z)`. | 293 | SSR 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 | ||
390 | Returns internal status message, mostly for debugging purposes. | 397 | Returns 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 | ||
400 | Frees some caches. For internal use, and is mostly broken at the moment. | 407 | Reloads 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 | |||
417 | This notification is sent from server to client. | ||
418 | The client can use it to display persistent status to the user (in modline). | ||
419 | For `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: | |||
82 | An input like `fn f() { 90 + 2 }` might be parsed as | 82 | An input like `fn f() { 90 + 2 }` might be parsed as |
83 | 83 | ||
84 | ``` | 84 | ``` |
85 | FN_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 { | |||
342 | impl AstNode for FnDef { | 342 | impl 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 | } |