From dc496d05160f9693a4e48977b7f7a3fe2689ac51 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Dec 2018 13:14:39 +0300 Subject: move highlightning to a separate file --- crates/ra_analysis/src/lib.rs | 4 ++-- crates/ra_analysis/src/syntax_highlighting.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 crates/ra_analysis/src/syntax_highlighting.rs (limited to 'crates') 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; mod imp; mod completion; mod symbol_index; +mod syntax_highlighting; pub mod mock_analysis; use std::{fmt, sync::Arc}; @@ -340,8 +341,7 @@ impl Analysis { Ok(ra_editor::runnables(&file)) } pub fn highlight(&self, file_id: FileId) -> Cancelable> { - let file = self.imp.file_syntax(file_id); - Ok(ra_editor::highlight(&file)) + syntax_highlighting::highlight(&*self.imp.db, file_id) } pub fn completions(&self, position: FilePosition) -> Cancelable>> { 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 @@ +use ra_editor::HighlightedRange; +use ra_db::SyntaxDatabase; + +use crate::{ + db::RootDatabase, + FileId, Cancelable, +}; + +pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Cancelable> { + let file = db.source_file(file_id); + Ok(ra_editor::highlight(&file)) +} -- cgit v1.2.3