diff options
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 0ea9ebee7..ab0e3cb0c 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | //! ra_analyzer crate is the brain of Rust analyzer. It relies on the `salsa` | 1 | //! ra_analyzer crate is the brain of Rust analyzer. It relies on the `salsa` |
2 | //! crate, which provides and incremental on-deman database of facts. | 2 | //! crate, which provides and incremental on-demand database of facts. |
3 | 3 | ||
4 | extern crate fst; | 4 | extern crate fst; |
5 | extern crate ra_editor; | 5 | extern crate ra_editor; |
@@ -20,7 +20,7 @@ pub mod mock_analysis; | |||
20 | 20 | ||
21 | use std::{fmt, sync::Arc}; | 21 | use std::{fmt, sync::Arc}; |
22 | 22 | ||
23 | use ra_syntax::{AtomEdit, File, TextRange, TextUnit}; | 23 | use ra_syntax::{AtomEdit, SourceFileNode, TextRange, TextUnit}; |
24 | use rayon::prelude::*; | 24 | use rayon::prelude::*; |
25 | use relative_path::RelativePathBuf; | 25 | use relative_path::RelativePathBuf; |
26 | 26 | ||
@@ -128,13 +128,13 @@ pub struct FilePosition { | |||
128 | #[derive(Debug)] | 128 | #[derive(Debug)] |
129 | pub struct SourceChange { | 129 | pub struct SourceChange { |
130 | pub label: String, | 130 | pub label: String, |
131 | pub source_file_edits: Vec<SourceFileEdit>, | 131 | pub source_file_edits: Vec<SourceFileNodeEdit>, |
132 | pub file_system_edits: Vec<FileSystemEdit>, | 132 | pub file_system_edits: Vec<FileSystemEdit>, |
133 | pub cursor_position: Option<FilePosition>, | 133 | pub cursor_position: Option<FilePosition>, |
134 | } | 134 | } |
135 | 135 | ||
136 | #[derive(Debug)] | 136 | #[derive(Debug)] |
137 | pub struct SourceFileEdit { | 137 | pub struct SourceFileNodeEdit { |
138 | pub file_id: FileId, | 138 | pub file_id: FileId, |
139 | pub edits: Vec<AtomEdit>, | 139 | pub edits: Vec<AtomEdit>, |
140 | } | 140 | } |
@@ -204,16 +204,16 @@ pub struct Analysis { | |||
204 | } | 204 | } |
205 | 205 | ||
206 | impl Analysis { | 206 | impl Analysis { |
207 | pub fn file_syntax(&self, file_id: FileId) -> File { | 207 | pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { |
208 | self.imp.file_syntax(file_id).clone() | 208 | self.imp.file_syntax(file_id).clone() |
209 | } | 209 | } |
210 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 210 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
211 | self.imp.file_line_index(file_id) | 211 | self.imp.file_line_index(file_id) |
212 | } | 212 | } |
213 | pub fn extend_selection(&self, file: &File, range: TextRange) -> TextRange { | 213 | pub fn extend_selection(&self, file: &SourceFileNode, range: TextRange) -> TextRange { |
214 | ra_editor::extend_selection(file, range).unwrap_or(range) | 214 | ra_editor::extend_selection(file, range).unwrap_or(range) |
215 | } | 215 | } |
216 | pub fn matching_brace(&self, file: &File, offset: TextUnit) -> Option<TextUnit> { | 216 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { |
217 | ra_editor::matching_brace(file, offset) | 217 | ra_editor::matching_brace(file, offset) |
218 | } | 218 | } |
219 | pub fn syntax_tree(&self, file_id: FileId) -> String { | 219 | pub fn syntax_tree(&self, file_id: FileId) -> String { |
@@ -258,6 +258,13 @@ impl Analysis { | |||
258 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { | 258 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |
259 | Ok(self.imp.find_all_refs(position)) | 259 | Ok(self.imp.find_all_refs(position)) |
260 | } | 260 | } |
261 | pub fn doc_comment_for( | ||
262 | &self, | ||
263 | file_id: FileId, | ||
264 | symbol: FileSymbol, | ||
265 | ) -> Cancelable<Option<String>> { | ||
266 | self.imp.doc_comment_for(file_id, symbol) | ||
267 | } | ||
261 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 268 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
262 | self.imp.parent_module(position) | 269 | self.imp.parent_module(position) |
263 | } | 270 | } |
@@ -302,7 +309,7 @@ pub struct LibraryData { | |||
302 | impl LibraryData { | 309 | impl LibraryData { |
303 | pub fn prepare(files: Vec<(FileId, String)>, file_resolver: Arc<FileResolver>) -> LibraryData { | 310 | pub fn prepare(files: Vec<(FileId, String)>, file_resolver: Arc<FileResolver>) -> LibraryData { |
304 | let symbol_index = SymbolIndex::for_files(files.par_iter().map(|(file_id, text)| { | 311 | let symbol_index = SymbolIndex::for_files(files.par_iter().map(|(file_id, text)| { |
305 | let file = File::parse(text); | 312 | let file = SourceFileNode::parse(text); |
306 | (*file_id, file) | 313 | (*file_id, file) |
307 | })); | 314 | })); |
308 | LibraryData { | 315 | LibraryData { |