diff options
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 476d1b438..9f5e9f358 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -16,6 +16,10 @@ mod completion; | |||
16 | mod symbol_index; | 16 | mod symbol_index; |
17 | pub mod mock_analysis; | 17 | pub mod mock_analysis; |
18 | 18 | ||
19 | mod extend_selection; | ||
20 | mod syntax_highlighting; | ||
21 | mod macros; | ||
22 | |||
19 | use std::{fmt, sync::Arc}; | 23 | use std::{fmt, sync::Arc}; |
20 | 24 | ||
21 | use rustc_hash::FxHashMap; | 25 | use rustc_hash::FxHashMap; |
@@ -37,7 +41,7 @@ pub use ra_editor::{ | |||
37 | pub use hir::FnSignatureInfo; | 41 | pub use hir::FnSignatureInfo; |
38 | 42 | ||
39 | pub use ra_db::{ | 43 | pub use ra_db::{ |
40 | Canceled, Cancelable, FilePosition, | 44 | Canceled, Cancelable, FilePosition, FileRange, |
41 | CrateGraph, CrateId, SourceRootId, FileId | 45 | CrateGraph, CrateId, SourceRootId, FileId |
42 | }; | 46 | }; |
43 | 47 | ||
@@ -270,14 +274,17 @@ pub struct Analysis { | |||
270 | } | 274 | } |
271 | 275 | ||
272 | impl Analysis { | 276 | impl Analysis { |
277 | pub fn file_text(&self, file_id: FileId) -> Arc<String> { | ||
278 | self.imp.file_text(file_id) | ||
279 | } | ||
273 | pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { | 280 | pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { |
274 | self.imp.file_syntax(file_id).clone() | 281 | self.imp.file_syntax(file_id).clone() |
275 | } | 282 | } |
276 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 283 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
277 | self.imp.file_line_index(file_id) | 284 | self.imp.file_line_index(file_id) |
278 | } | 285 | } |
279 | pub fn extend_selection(&self, file: &SourceFileNode, range: TextRange) -> TextRange { | 286 | pub fn extend_selection(&self, frange: FileRange) -> TextRange { |
280 | ra_editor::extend_selection(file, range).unwrap_or(range) | 287 | extend_selection::extend_selection(&self.imp.db, frange) |
281 | } | 288 | } |
282 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { | 289 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { |
283 | ra_editor::matching_brace(file, offset) | 290 | ra_editor::matching_brace(file, offset) |
@@ -286,9 +293,9 @@ impl Analysis { | |||
286 | let file = self.imp.file_syntax(file_id); | 293 | let file = self.imp.file_syntax(file_id); |
287 | ra_editor::syntax_tree(&file) | 294 | ra_editor::syntax_tree(&file) |
288 | } | 295 | } |
289 | pub fn join_lines(&self, file_id: FileId, range: TextRange) -> SourceChange { | 296 | pub fn join_lines(&self, frange: FileRange) -> SourceChange { |
290 | let file = self.imp.file_syntax(file_id); | 297 | let file = self.imp.file_syntax(frange.file_id); |
291 | SourceChange::from_local_edit(file_id, ra_editor::join_lines(&file, range)) | 298 | SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range)) |
292 | } | 299 | } |
293 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { | 300 | pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { |
294 | let file = self.imp.file_syntax(position.file_id); | 301 | let file = self.imp.file_syntax(position.file_id); |
@@ -323,13 +330,6 @@ impl Analysis { | |||
323 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { | 330 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |
324 | self.imp.find_all_refs(position) | 331 | self.imp.find_all_refs(position) |
325 | } | 332 | } |
326 | pub fn doc_comment_for( | ||
327 | &self, | ||
328 | file_id: FileId, | ||
329 | symbol: FileSymbol, | ||
330 | ) -> Cancelable<Option<String>> { | ||
331 | self.imp.doc_comment_for(file_id, symbol) | ||
332 | } | ||
333 | pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable<Option<String>> { | 333 | pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable<Option<String>> { |
334 | self.imp.doc_text_for(file_id, symbol) | 334 | self.imp.doc_text_for(file_id, symbol) |
335 | } | 335 | } |
@@ -347,14 +347,13 @@ impl Analysis { | |||
347 | Ok(ra_editor::runnables(&file)) | 347 | Ok(ra_editor::runnables(&file)) |
348 | } | 348 | } |
349 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { | 349 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { |
350 | let file = self.imp.file_syntax(file_id); | 350 | syntax_highlighting::highlight(&*self.imp.db, file_id) |
351 | Ok(ra_editor::highlight(&file)) | ||
352 | } | 351 | } |
353 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { | 352 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { |
354 | self.imp.completions(position) | 353 | self.imp.completions(position) |
355 | } | 354 | } |
356 | pub fn assists(&self, file_id: FileId, range: TextRange) -> Cancelable<Vec<SourceChange>> { | 355 | pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> { |
357 | Ok(self.imp.assists(file_id, range)) | 356 | Ok(self.imp.assists(frange)) |
358 | } | 357 | } |
359 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { | 358 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { |
360 | self.imp.diagnostics(file_id) | 359 | self.imp.diagnostics(file_id) |
@@ -365,8 +364,8 @@ impl Analysis { | |||
365 | ) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> { | 364 | ) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> { |
366 | self.imp.resolve_callable(position) | 365 | self.imp.resolve_callable(position) |
367 | } | 366 | } |
368 | pub fn type_of(&self, file_id: FileId, range: TextRange) -> Cancelable<Option<String>> { | 367 | pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { |
369 | self.imp.type_of(file_id, range) | 368 | self.imp.type_of(frange) |
370 | } | 369 | } |
371 | } | 370 | } |
372 | 371 | ||