@@ -134,29 +134,29 @@ This is to enable parallel parsing of all files.
134
134
** Architecture Invariant:** Syntax trees are by design incomplete and do not enforce well-formedness.
135
135
If an AST method returns an ` Option ` , it * can* be ` None ` at runtime, even if this is forbidden by the grammar.
136
136
137
- ### ` crates/base_db `
137
+ ### ` crates/base-db `
138
138
139
139
We use the [ salsa] ( https://github.com/salsa-rs/salsa ) crate for incremental and on-demand computation.
140
140
Roughly, you can think of salsa as a key-value store, but it can also compute derived values using specified functions.
141
- The ` base_db ` crate provides basic infrastructure for interacting with salsa.
141
+ The ` base-db ` crate provides basic infrastructure for interacting with salsa.
142
142
Crucially, it defines most of the "input" queries: facts supplied by the client of the analyzer.
143
143
Reading the docs of the ` base_db::input ` module should be useful: everything else is strictly derived from those inputs.
144
144
145
145
** Architecture Invariant:** particularities of the build system are * not* the part of the ground state.
146
- In particular, ` base_db ` knows nothing about cargo.
146
+ In particular, ` base-db ` knows nothing about cargo.
147
147
For example, ` cfg ` flags are a part of ` base_db ` , but ` feature ` s are not.
148
148
A ` foo ` feature is a Cargo-level concept, which is lowered by Cargo to ` --cfg feature=foo ` argument on the command line.
149
149
The ` CrateGraph ` structure is used to represent the dependencies between the crates abstractly.
150
150
151
- ** Architecture Invariant:** ` base_db ` doesn't know about file system and file paths.
151
+ ** Architecture Invariant:** ` base-db ` doesn't know about file system and file paths.
152
152
Files are represented with opaque ` FileId ` , there's no operation to get an ` std::path::Path ` out of the ` FileId ` .
153
153
154
- ### ` crates/hir_expand ` , ` crates/hir_def ` , ` crates/hir_ty `
154
+ ### ` crates/hir-expand ` , ` crates/hir-def ` , ` crates/hir_ty `
155
155
156
156
These crates are the * brain* of rust-analyzer.
157
157
This is the compiler part of the IDE.
158
158
159
- ` hir_xxx ` crates have a strong [ ECS] ( https://en.wikipedia.org/wiki/Entity_component_system ) flavor, in that they work with raw ids and directly query the database.
159
+ ` hir-xxx ` crates have a strong [ ECS] ( https://en.wikipedia.org/wiki/Entity_component_system ) flavor, in that they work with raw ids and directly query the database.
160
160
There's little abstraction here.
161
161
These crates integrate deeply with salsa and chalk.
162
162
@@ -186,7 +186,7 @@ If you think about "using rust-analyzer as a library", `hir` crate is most likel
186
186
It wraps ECS-style internal API into a more OO-flavored API (with an extra ` db ` argument for each call).
187
187
188
188
** Architecture Invariant:** ` hir ` provides a static, fully resolved view of the code.
189
- While internal ` hir_ *` crates _ compute_ things, ` hir ` , from the outside, looks like an inert data structure.
189
+ While internal ` hir- *` crates _ compute_ things, ` hir ` , from the outside, looks like an inert data structure.
190
190
191
191
` hir ` also handles the delicate task of going from syntax to the corresponding ` hir ` .
192
192
Remember that the mapping here is one-to-many.
@@ -200,7 +200,7 @@ Then we look for our node in the set of children.
200
200
This is the heart of many IDE features, like goto definition, which start with figuring out the hir node at the cursor.
201
201
This is some kind of (yet unnamed) uber-IDE pattern, as it is present in Roslyn and Kotlin as well.
202
202
203
- ### ` crates/ide `
203
+ ### ` crates/ide ` , ` crates/ide-db ` , ` crates/ide-assists ` , ` crates/ide-completion ` , ` crates/ide-diagnostics ` , ` crates/ide-ssr `
204
204
205
205
The ` ide ` crate builds on top of ` hir ` semantic model to provide high-level IDE features like completion or goto definition.
206
206
It is an ** API Boundary** .
@@ -217,8 +217,8 @@ Shout outs to LSP developers for popularizing the idea that "UI" is a good place
217
217
` AnalysisHost ` is a state to which you can transactionally ` apply_change ` .
218
218
` Analysis ` is an immutable snapshot of the state.
219
219
220
- Internally, ` ide ` is split across several crates. ` ide_assists ` , ` ide_completion ` and ` ide_ssr ` implement large isolated features.
221
- ` ide_db ` implements common IDE functionality (notably, reference search is implemented here).
220
+ Internally, ` ide ` is split across several crates. ` ide-assists ` , ` ide-completion ` , ` ide-diagnostics ` and ` ide-ssr ` implement large isolated features.
221
+ ` ide-db ` implements common IDE functionality (notably, reference search is implemented here).
222
222
The ` ide ` contains a public API/façade, as well as implementation for a plethora of smaller features.
223
223
224
224
** Architecture Invariant:** ` ide ` crate strives to provide a _ perfect_ API.
@@ -251,14 +251,14 @@ This is a tricky business.
251
251
** Architecture Invariant:** ` rust-analyzer ` should be partially available even when the build is broken.
252
252
Reloading process should not prevent IDE features from working.
253
253
254
- ### ` crates/toolchain ` , ` crates/project_model ` , ` crates/flycheck `
254
+ ### ` crates/toolchain ` , ` crates/project-model ` , ` crates/flycheck `
255
255
256
256
These crates deal with invoking ` cargo ` to learn about project structure and get compiler errors for the "check on save" feature.
257
257
258
- They use ` crates/path ` heavily instead of ` std::path ` .
258
+ They use ` crates/paths ` heavily instead of ` std::path ` .
259
259
A single ` rust-analyzer ` process can serve many projects, so it is important that server's current directory does not leak.
260
260
261
- ### ` crates/mbe ` , ` crates/tt ` , ` crates/proc_macro_api ` , ` crates/proc_macro_srv `
261
+ ### ` crates/mbe ` , ` crates/tt ` , ` crates/proc-macro-api ` , ` crates/proc-macro-srv ` , ` crates/proc-macro-srv-cli `
262
262
263
263
These crates implement macros as token tree -> token tree transforms.
264
264
They are independent from the rest of the code.
@@ -268,8 +268,8 @@ They are independent from the rest of the code.
268
268
And it also handles the actual parsing and expansion of declarative macro (a-la "Macros By Example" or mbe).
269
269
270
270
For proc macros, the client-server model are used.
271
- We start a separate process (` proc_macro_srv ` ) which loads and runs the proc-macros for us.
272
- And the client (` proc_macro_api ` ) provides an interface to talk to that server separately.
271
+ We start a separate process (` proc-macro-srv-cli ` ) which loads and runs the proc-macros for us.
272
+ And the client (` proc-macro-api ` ) provides an interface to talk to that server separately.
273
273
274
274
And then token trees are passed from client, and the server will load the corresponding dynamic library (which built by ` cargo ` ).
275
275
And due to the fact the api for getting result from proc macro are always unstable in ` rustc ` ,
@@ -283,7 +283,7 @@ And they may be non-deterministic which conflict how `salsa` works, so special a
283
283
284
284
This crate is responsible for parsing, evaluation and general definition of ` cfg ` attributes.
285
285
286
- ### ` crates/vfs ` , ` crates/vfs-notify `
286
+ ### ` crates/vfs ` , ` crates/vfs-notify ` , ` crates/paths `
287
287
288
288
These crates implement a virtual file system.
289
289
They provide consistent snapshots of the underlying file system and insulate messy OS paths.
@@ -301,6 +301,25 @@ as copies of unstable std items we would like to make use of already, like `std:
301
301
302
302
This crate contains utilities for CPU and memory profiling.
303
303
304
+ ### ` crates/intern `
305
+
306
+ This crate contains infrastructure for globally interning things via ` Arc ` .
307
+
308
+ ### ` crates/load-cargo `
309
+
310
+ This crate exposes several utilities for loading projects, used by the main ` rust-analyzer ` crate
311
+ and other downstream consumers.
312
+
313
+ ### ` crates/rustc-dependencies `
314
+
315
+ This crate wraps the ` rustc_* ` crates rust-analyzer relies on and conditionally points them to
316
+ mirrored crates-io releases such that rust-analyzer keeps building on stable.
317
+
318
+ ### ` crates/span `
319
+
320
+ This crate exposes types and functions related to rust-analyzer's span for macros.
321
+
322
+ A span is effectively a text range relative to some item in a file with a given ` SyntaxContext ` (hygiene).
304
323
305
324
## Cross-Cutting Concerns
306
325
0 commit comments