From 2f22c861a925b6851540430ede0b87fe83c5374c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 2 Jan 2019 18:11:49 +0300 Subject: remove some methods from analysis impl --- crates/ra_analysis/src/imp.rs | 13 ++----------- crates/ra_analysis/src/lib.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 9ac52b5c3..248b77f5a 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -9,7 +9,7 @@ use hir::{ self, FnSignatureInfo, Problem, source_binder, }; use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; -use ra_editor::{self, find_node_at_offset, LineIndex, LocalEdit, Severity}; +use ra_editor::{self, find_node_at_offset, LocalEdit, Severity}; use ra_syntax::{ algo::find_covering_node, ast::{self, ArgListOwner, Expr, FnDef, NameOwner}, @@ -139,15 +139,6 @@ impl fmt::Debug for AnalysisImpl { } impl AnalysisImpl { - pub fn file_text(&self, file_id: FileId) -> Arc { - self.db.file_text(file_id) - } - pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { - self.db.source_file(file_id) - } - pub fn file_line_index(&self, file_id: FileId) -> Arc { - self.db.file_lines(file_id) - } pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable> { let descr = match source_binder::module_from_position(&*self.db, position)? { None => return Ok(None), @@ -400,7 +391,7 @@ impl AnalysisImpl { } pub fn assists(&self, frange: FileRange) -> Vec { - let file = self.file_syntax(frange.file_id); + let file = self.db.source_file(frange.file_id); let offset = frange.range.start(); let actions = vec![ ra_editor::flip_comma(&file, offset).map(|f| f()), diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 03550832e..ef08a721c 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -44,7 +44,7 @@ pub use hir::FnSignatureInfo; pub use ra_db::{ Canceled, Cancelable, FilePosition, FileRange, - CrateGraph, CrateId, SourceRootId, FileId + CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase }; #[derive(Default)] @@ -298,13 +298,13 @@ pub struct Analysis { impl Analysis { pub fn file_text(&self, file_id: FileId) -> Arc { - self.imp.file_text(file_id) + self.imp.db.file_text(file_id) } pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { - self.imp.file_syntax(file_id).clone() + self.imp.db.source_file(file_id).clone() } pub fn file_line_index(&self, file_id: FileId) -> Arc { - self.imp.file_line_index(file_id) + self.imp.db.file_lines(file_id) } pub fn extend_selection(&self, frange: FileRange) -> TextRange { extend_selection::extend_selection(&self.imp.db, frange) @@ -313,32 +313,32 @@ impl Analysis { ra_editor::matching_brace(file, offset) } pub fn syntax_tree(&self, file_id: FileId) -> String { - let file = self.imp.file_syntax(file_id); + let file = self.imp.db.source_file(file_id); ra_editor::syntax_tree(&file) } pub fn join_lines(&self, frange: FileRange) -> SourceChange { - let file = self.imp.file_syntax(frange.file_id); + let file = self.imp.db.source_file(frange.file_id); SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range)) } pub fn on_enter(&self, position: FilePosition) -> Option { - let file = self.imp.file_syntax(position.file_id); + let file = self.imp.db.source_file(position.file_id); let edit = ra_editor::on_enter(&file, position.offset)?; let res = SourceChange::from_local_edit(position.file_id, edit); Some(res) } pub fn on_eq_typed(&self, position: FilePosition) -> Option { - let file = self.imp.file_syntax(position.file_id); + let file = self.imp.db.source_file(position.file_id); Some(SourceChange::from_local_edit( position.file_id, ra_editor::on_eq_typed(&file, position.offset)?, )) } pub fn file_structure(&self, file_id: FileId) -> Vec { - let file = self.imp.file_syntax(file_id); + let file = self.imp.db.source_file(file_id); ra_editor::file_structure(&file) } pub fn folding_ranges(&self, file_id: FileId) -> Vec { - let file = self.imp.file_syntax(file_id); + let file = self.imp.db.source_file(file_id); ra_editor::folding_ranges(&file) } pub fn symbol_search(&self, query: Query) -> Cancelable> { @@ -373,7 +373,7 @@ impl Analysis { Ok(self.imp.crate_root(crate_id)) } pub fn runnables(&self, file_id: FileId) -> Cancelable> { - let file = self.imp.file_syntax(file_id); + let file = self.imp.db.source_file(file_id); Ok(runnables::runnables(self, &file, file_id)) } pub fn highlight(&self, file_id: FileId) -> Cancelable> { -- cgit v1.2.3