move highlightning to a separate file

This commit is contained in:
Aleksey Kladov 2018-12-28 13:14:39 +03:00
parent e80021cbd0
commit dc496d0516
2 changed files with 14 additions and 2 deletions

View File

@ -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<Vec<HighlightedRange>> {
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<Option<Vec<CompletionItem>>> {
self.imp.completions(position)

View File

@ -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<Vec<HighlightedRange>> {
let file = db.source_file(file_id);
Ok(ra_editor::highlight(&file))
}