remove some methods from analysis impl

This commit is contained in:
Aleksey Kladov 2019-01-02 18:11:49 +03:00
parent a94530afb3
commit 2f22c861a9
2 changed files with 13 additions and 22 deletions

View File

@ -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<String> {
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<LineIndex> {
self.db.file_lines(file_id)
}
pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> {
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<SourceChange> {
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()),

View File

@ -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<String> {
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<LineIndex> {
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<SourceChange> {
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<SourceChange> {
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<StructureNode> {
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<Fold> {
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<Vec<NavigationTarget>> {
@ -373,7 +373,7 @@ impl Analysis {
Ok(self.imp.crate_root(crate_id))
}
pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
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<Vec<HighlightedRange>> {