aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-28 10:14:39 +0000
committerAleksey Kladov <[email protected]>2018-12-28 10:14:39 +0000
commitdc496d05160f9693a4e48977b7f7a3fe2689ac51 (patch)
tree2a88e1538f96be40713f0e08fed8101393485bf4 /crates
parente80021cbd0bcfea82f3b855e13a409c73b563673 (diff)
move highlightning to a separate file
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/lib.rs4
-rw-r--r--crates/ra_analysis/src/syntax_highlighting.rs12
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;
14mod imp; 14mod imp;
15mod completion; 15mod completion;
16mod symbol_index; 16mod symbol_index;
17mod syntax_highlighting;
17pub mod mock_analysis; 18pub mod mock_analysis;
18 19
19use std::{fmt, sync::Arc}; 20use 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 @@
1use ra_editor::HighlightedRange;
2use ra_db::SyntaxDatabase;
3
4use crate::{
5 db::RootDatabase,
6 FileId, Cancelable,
7};
8
9pub(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}