diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 91 |
1 files changed, 9 insertions, 82 deletions
@@ -16,7 +16,8 @@ functionality is provided via a language server. | |||
16 | 16 | ||
17 | ## Quick Start | 17 | ## Quick Start |
18 | 18 | ||
19 | Rust analyzer builds on stable Rust >= 1.29.0. | 19 | Rust analyzer builds on Rust >= 1.30.0 (currently in beta) and uses |
20 | the 2018 edition. | ||
20 | 21 | ||
21 | ``` | 22 | ``` |
22 | # run tests | 23 | # run tests |
@@ -61,99 +62,20 @@ fold: | |||
61 | * to quickly bootstrap usable and useful language server: solution | 62 | * to quickly bootstrap usable and useful language server: solution |
62 | that covers 80% of Rust code will be useful for IDEs, and will be | 63 | that covers 80% of Rust code will be useful for IDEs, and will be |
63 | vastly simpler than 100% solution. | 64 | vastly simpler than 100% solution. |
64 | 65 | ||
65 | * to understand how the consumer-side of compiler API should look like | 66 | * to understand how the consumer-side of compiler API should look like |
66 | (especially it's on-demand aspects). If you have | 67 | (especially it's on-demand aspects). If you have |
67 | `get_expression_type` function, you can write a ton of purely-IDE | 68 | `get_expression_type` function, you can write a ton of purely-IDE |
68 | features on top of it, even if the function is only partially | 69 | features on top of it, even if the function is only partially |
69 | correct. Plugin in the precise function afterwards should just make | 70 | correct. Plugin in the precise function afterwards should just make |
70 | IDE features more reliable. | 71 | IDE features more reliable. |
71 | 72 | ||
72 | The long term plan is to merge with the mainline rustc compiler, | 73 | The long term plan is to merge with the mainline rustc compiler, |
73 | probably around the HIR boundary? That is, use rust analyzer for | 74 | probably around the HIR boundary? That is, use rust analyzer for |
74 | parsing, macro expansion and related bits of name resolution, but | 75 | parsing, macro expansion and related bits of name resolution, but |
75 | leave the rest (including type inference and trait selection) to the | 76 | leave the rest (including type inference and trait selection) to the |
76 | existing rustc. | 77 | existing rustc. |
77 | 78 | ||
78 | ## Code Walk-Through | ||
79 | |||
80 | ### `crates/ra_syntax` | ||
81 | |||
82 | Rust syntax tree structure and parser. See | ||
83 | [RFC](https://github.com/rust-lang/rfcs/pull/2256) for some design | ||
84 | notes. | ||
85 | |||
86 | - `yellow`, red/green syntax tree, heavily inspired [by this](https://github.com/apple/swift/tree/ab68f0d4cbf99cdfa672f8ffe18e433fddc8b371/lib/Syntax) | ||
87 | - `grammar`, the actual parser | ||
88 | - `parser_api/parser_impl` bridges the tree-agnostic parser from `grammar` with `yellow` trees | ||
89 | - `grammar.ron` RON description of the grammar, which is used to | ||
90 | generate `syntax_kinds` and `ast` modules. | ||
91 | - `algo`: generic tree algorithms, including `walk` for O(1) stack | ||
92 | space tree traversal (this is cool) and `visit` for type-driven | ||
93 | visiting the nodes (this is double plus cool, if you understand how | ||
94 | `Visitor` works, you understand rust-analyzer). | ||
95 | |||
96 | |||
97 | ### `crates/ra_editor` | ||
98 | |||
99 | All IDE features which can be implemented if you only have access to a | ||
100 | single file. `ra_editor` could be used to enhance editing of Rust code | ||
101 | without the need to fiddle with build-systems, file | ||
102 | synchronization and such. | ||
103 | |||
104 | In a sense, `ra_editor` is just a bunch of pure functions which take a | ||
105 | syntax tree as an input. | ||
106 | |||
107 | ### `crates/salsa` | ||
108 | |||
109 | An implementation of red-green incremental compilation algorithm from | ||
110 | rust compiler. It makes all rust-analyzer features on-demand. | ||
111 | |||
112 | |||
113 | ### `crates/ra_analysis` | ||
114 | |||
115 | A stateful library for analyzing many Rust files as they change. | ||
116 | `AnalysisHost` is a mutable entity (clojure's atom) which holds | ||
117 | current state, incorporates changes and handles out `Analysis` --- an | ||
118 | immutable consistent snapshot of world state at a point in time, which | ||
119 | actually powers analysis. | ||
120 | |||
121 | |||
122 | ### `crates/ra_lsp_server` | ||
123 | |||
124 | An LSP implementation which uses `ra_analysis` for managing state and | ||
125 | `ra_editor` for actually doing useful stuff. | ||
126 | |||
127 | |||
128 | ### `crates/cli` | ||
129 | |||
130 | A CLI interface to libsyntax | ||
131 | |||
132 | ### `crate/tools` | ||
133 | |||
134 | Code-gen tasks, used to develop rust-analyzer: | ||
135 | |||
136 | - `cargo gen-kinds` -- generate `ast` and `syntax_kinds` | ||
137 | - `cargo gen-tests` -- collect inline tests from grammar | ||
138 | - `cargo install-code` -- build and install VS Code extension and server | ||
139 | |||
140 | ### `editors/code` | ||
141 | |||
142 | VS Code plugin | ||
143 | |||
144 | |||
145 | ## Performance | ||
146 | |||
147 | Non-incremental, but seems pretty fast: | ||
148 | |||
149 | ``` | ||
150 | $ cargo build --release --package ra_cli | ||
151 | $ wc -l ~/projects/rust/src/libsyntax/parse/parser.rs | ||
152 | 7546 /home/matklad/projects/rust/src/libsyntax/parse/parser.rs | ||
153 | $ ./target/release/ra_cli parse < ~/projects/rust/src/libsyntax/parse/parser.rs --no-dump > /dev/null | ||
154 | parsing: 21.067065ms | ||
155 | ``` | ||
156 | |||
157 | ## Getting in touch | 79 | ## Getting in touch |
158 | 80 | ||
159 | @matklad can be found at Rust | 81 | @matklad can be found at Rust |
@@ -161,6 +83,11 @@ parsing: 21.067065ms | |||
161 | #ides-and-editors. | 83 | #ides-and-editors. |
162 | 84 | ||
163 | 85 | ||
86 | ## Contributing | ||
87 | |||
88 | See [CONTRIBUTING.md](./CONTRIBUTING.md) and [ARCHITECTURE.md](./ARCHITECTURE.md) | ||
89 | |||
90 | |||
164 | ## License | 91 | ## License |
165 | 92 | ||
166 | Rust analyzer is primarily distributed under the terms of both the MIT | 93 | Rust analyzer is primarily distributed under the terms of both the MIT |