diff options
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/syntax_highlighting.rs | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 65c3eb3ec..b26e9e9ff 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -14,6 +14,7 @@ mod db; | |||
14 | mod imp; | 14 | mod imp; |
15 | mod completion; | 15 | mod completion; |
16 | mod symbol_index; | 16 | mod symbol_index; |
17 | mod syntax_highlighting; | ||
17 | pub mod mock_analysis; | 18 | pub mod mock_analysis; |
18 | 19 | ||
19 | use std::{fmt, sync::Arc}; | 20 | use std::{fmt, sync::Arc}; |
@@ -340,8 +341,7 @@ impl Analysis { | |||
340 | Ok(ra_editor::runnables(&file)) | 341 | Ok(ra_editor::runnables(&file)) |
341 | } | 342 | } |
342 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { | 343 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { |
343 | let file = self.imp.file_syntax(file_id); | 344 | syntax_highlighting::highlight(&*self.imp.db, file_id) |
344 | Ok(ra_editor::highlight(&file)) | ||
345 | } | 345 | } |
346 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { | 346 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { |
347 | self.imp.completions(position) | 347 | self.imp.completions(position) |
diff --git a/crates/ra_analysis/src/syntax_highlighting.rs b/crates/ra_analysis/src/syntax_highlighting.rs new file mode 100644 index 000000000..65409beb2 --- /dev/null +++ b/crates/ra_analysis/src/syntax_highlighting.rs | |||
@@ -0,0 +1,12 @@ | |||
1 | use ra_editor::HighlightedRange; | ||
2 | use ra_db::SyntaxDatabase; | ||
3 | |||
4 | use crate::{ | ||
5 | db::RootDatabase, | ||
6 | FileId, Cancelable, | ||
7 | }; | ||
8 | |||
9 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { | ||
10 | let file = db.source_file(file_id); | ||
11 | Ok(ra_editor::highlight(&file)) | ||
12 | } | ||