aboutsummaryrefslogtreecommitdiff
path: root/guide.md
diff options
context:
space:
mode:
Diffstat (limited to 'guide.md')
-rw-r--r--guide.md19
1 files changed, 10 insertions, 9 deletions
diff --git a/guide.md b/guide.md
index beb8294ba..5196f83df 100644
--- a/guide.md
+++ b/guide.md
@@ -281,10 +281,9 @@ file", which could then be reused by several semantic models if this file
281happens to be a part of several crates. 281happens to be a part of several crates.
282 282
283Rust analyzer uses a similar representation of syntax trees to that of `Roslyn` 283Rust analyzer uses a similar representation of syntax trees to that of `Roslyn`
284and Swift's new 284and Swift's new [libsyntax]. Swift's docs give an excellent overview of the
285[libsyntax](https://github.com/apple/swift/tree/5e2c815edfd758f9b1309ce07bfc01c4bc20ec23/lib/Syntax). 285approach, so I skip this part here and instead outline the main characteristics
286Swift's docs give an excellent overview of the approach, so I skip this part 286of the syntax trees:
287here and instead outline the main characteristics of the syntax trees:
288 287
289* Syntax trees are fully lossless. Converting **any** text to a syntax tree and 288* Syntax trees are fully lossless. Converting **any** text to a syntax tree and
290 back is a total identity function. All whitespace and comments are explicitly 289 back is a total identity function. All whitespace and comments are explicitly
@@ -313,6 +312,7 @@ here and instead outline the main characteristics of the syntax trees:
313The implementation is based on the generic [rowan] crate on top of which a 312The implementation is based on the generic [rowan] crate on top of which a
314[rust-specific] AST is generated. 313[rust-specific] AST is generated.
315 314
315[libsyntax]: https://github.com/apple/swift/tree/5e2c815edfd758f9b1309ce07bfc01c4bc20ec23/lib/Syntax
316[rowan]: https://github.com/rust-analyzer/rowan/tree/100a36dc820eb393b74abe0d20ddf99077b61f88 316[rowan]: https://github.com/rust-analyzer/rowan/tree/100a36dc820eb393b74abe0d20ddf99077b61f88
317[rust-specific]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_syntax/src/ast/generated.rs 317[rust-specific]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_syntax/src/ast/generated.rs
318 318
@@ -323,8 +323,9 @@ The next step in constructing the semantic model is ...
323The algorithm for building a tree of modules is to start with a crate root 323The algorithm for building a tree of modules is to start with a crate root
324(remember, each `Crate` from a `CrateGraph` has a `FileId`), collect all mod 324(remember, each `Crate` from a `CrateGraph` has a `FileId`), collect all mod
325declarations and recursively process child modules. This is handled by the 325declarations and recursively process child modules. This is handled by the
326[`module_tree_query`](https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123), 326[`module_tree_query`], with a two slight variations.
327with a two slight variations. 327
328[`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123
328 329
329First, rust analyzer builds a module tree for all crates in a source root 330First, rust analyzer builds a module tree for all crates in a source root
330simultaneously. The main reason for this is historical (`module_tree` predates 331simultaneously. The main reason for this is historical (`module_tree` predates
@@ -345,12 +346,12 @@ names. Now, changing the whitespace results in `submodules_query` being
345re-executed for a *single* module, but because the result of this query stays 346re-executed for a *single* module, but because the result of this query stays
346the same, we don't have to re-execute [`module_tree_query`]. In fact, we only 347the same, we don't have to re-execute [`module_tree_query`]. In fact, we only
347need to re-execute it when we add/remove new files or when we change mod 348need to re-execute it when we add/remove new files or when we change mod
348declarations, 349declarations.
349 350
350[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L41) 351[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L41)
351 352
352 353We store the resulting modules in a `Vec`-based indexed arena. The indices in
353 354the arena becomes module identifiers.
354 355
355 356
356## Location Interner pattern 357## Location Interner pattern