@@ -65,11 +65,11 @@ Next, let's talk about what the inputs to the `Analysis` are, precisely.
65
65
66
66
rust-analyzer never does any I/O itself, all inputs get passed explicitly via
67
67
the ` AnalysisHost::apply_change ` method, which accepts a single argument, a
68
- ` Change ` . [ ` Change ` ] is a builder for a single change
68
+ ` AnalysisChange ` . [ ` AnalysisChange ` ] is a builder for a single change
69
69
"transaction", so it suffices to study its methods to understand all of the
70
70
input data.
71
71
72
- [ `Change ` ] : https://github.com/rust-lang/rust-analyzer/blob/master /crates/base_db /src/change .rs#L14-L89
72
+ [ `AnalysisChange ` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01 /crates/ra_ide_api /src/lib .rs#L119-L167
73
73
74
74
The ` (add|change|remove)_file ` methods control the set of the input files, where
75
75
each file has an integer id (` FileId ` , picked by the client), text (` String ` )
@@ -118,7 +118,7 @@ can have `#[path="/dev/random"] mod foo;`.
118
118
119
119
To solve (or explicitly refuse to solve) these problems rust-analyzer uses the
120
120
concept of a "source root". Roughly speaking, source roots are the contents of a
121
- directory on a file systems , like ` /home/matklad/projects/rustraytracer/**.rs ` .
121
+ directory on a file system , like ` /home/matklad/projects/rustraytracer/**.rs ` .
122
122
123
123
More precisely, all files (` FileId ` s) are partitioned into disjoint
124
124
` SourceRoot ` s. Each file has a relative UTF-8 path within the ` SourceRoot ` .
@@ -156,7 +156,7 @@ it should be possible to dynamically reconfigure it later without restart.
156
156
[ main_loop.rs#L62-L70] ( https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L62-L70 )
157
157
158
158
The [ ` ProjectModel ` ] we get after this step is very Cargo and sysroot specific,
159
- it needs to be lowered to get the input in the form of ` Change ` . This
159
+ it needs to be lowered to get the input in the form of ` AnalysisChange ` . This
160
160
happens in [ ` ServerWorldState::new ` ] method. Specifically
161
161
162
162
* Create a ` SourceRoot ` for each Cargo package and sysroot.
@@ -173,7 +173,7 @@ of the main loop, just like any other change. Here's where we handle:
173
173
* [ File system changes] ( https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L194 )
174
174
* [ Changes from the editor] ( https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L377 )
175
175
176
- After a single loop's turn, we group the changes into one ` Change ` and
176
+ After a single loop's turn, we group the changes into one ` AnalysisChange ` and
177
177
[ apply] it. This always happens on the main thread and blocks the loop.
178
178
179
179
[ apply ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/server_world.rs#L216
@@ -186,7 +186,7 @@ executing "goto definition" on the threadpool and a new change comes in, the
186
186
task will be canceled as soon as the main loop calls ` apply_change ` on the
187
187
` AnalysisHost ` .
188
188
189
- [ "goto definition" ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/server_world .rs#L216
189
+ [ "goto definition" ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop .rs#L296
190
190
[ `schedule` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L426-L455
191
191
[ The task ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L205-L223
192
192
@@ -250,13 +250,13 @@ All analyzer information is stored in a salsa database. `Analysis` and
250
250
` AnalysisHost ` types are newtype wrappers for [ ` RootDatabase ` ] -- a salsa
251
251
database.
252
252
253
- [ `RootDatabase` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api /src/db.rs#L88-L134
253
+ [ `RootDatabase` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api /src/db.rs#L88-L134
254
254
255
255
Salsa input queries are defined in [ ` FilesDatabase ` ] (which is a part of
256
- ` RootDatabase ` ). They closely mirror the familiar ` Change ` structure:
256
+ ` RootDatabase ` ). They closely mirror the familiar ` AnalysisChange ` structure:
257
257
indeed, what ` apply_change ` does is it sets the values of input queries.
258
258
259
- [ `FilesDatabase` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/base_db /src/input.rs#L150-L174
259
+ [ `FilesDatabase` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_db /src/input.rs#L150-L174
260
260
261
261
## From text to semantic model
262
262
@@ -281,7 +281,7 @@ methods invoke various queries on the database to build the model on demand.
281
281
Here's [ the list of queries] .
282
282
283
283
[ `code_model_api` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/code_model_api.rs
284
- [ the list of queries ] : https://github.com/rust-lang/rust-analyzer/blob/7e84440e25e19529e4ff8a66e521d1b06349c6ec /crates/ra_hir/src/db.rs#L20-L106
284
+ [ the list of queries ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01 /crates/ra_hir/src/db.rs#L20-L106
285
285
286
286
The first step of building the model is parsing the source code.
287
287
@@ -493,7 +493,7 @@ position-independent part of the lowering. The result of this query is stable.
493
493
Naturally, name resolution [ uses] this stable projection query.
494
494
495
495
[ imports ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59
496
- [ `SourceMap` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59
496
+ [ `SourceMap` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L74-L94
497
497
[ projection query ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L97-L103
498
498
[ uses ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/query_definitions.rs#L49
499
499
@@ -560,8 +560,7 @@ the type to completion.
560
560
[ receiving a message ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L203
561
561
[ schedule it on the threadpool ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L428
562
562
[ catch ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L436-L442
563
- [ the handler ] : https://salsa.zulipchat.com/#narrow/stream/181542-rfcs.2Fsalsa-query-group/topic/design.20next.20steps
564
- [ ask analysis for completion ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L439-L444
563
+ [ the handler ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L304-L343
565
564
[ ask analysis for completion ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L439-L444
566
565
[ completion implementation ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L46-L62
567
566
[ `CompletionContext` ] : https://github.com/rust-lang/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L14-L37
0 commit comments