mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
remove some methods from analysis impl
This commit is contained in:
parent
a94530afb3
commit
2f22c861a9
2 changed files with 13 additions and 22 deletions
|
@ -9,7 +9,7 @@ use hir::{
|
||||||
self, FnSignatureInfo, Problem, source_binder,
|
self, FnSignatureInfo, Problem, source_binder,
|
||||||
};
|
};
|
||||||
use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase};
|
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::{
|
use ra_syntax::{
|
||||||
algo::find_covering_node,
|
algo::find_covering_node,
|
||||||
ast::{self, ArgListOwner, Expr, FnDef, NameOwner},
|
ast::{self, ArgListOwner, Expr, FnDef, NameOwner},
|
||||||
|
@ -139,15 +139,6 @@ impl fmt::Debug for AnalysisImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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>> {
|
pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> {
|
||||||
let descr = match source_binder::module_from_position(&*self.db, position)? {
|
let descr = match source_binder::module_from_position(&*self.db, position)? {
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
|
@ -400,7 +391,7 @@ impl AnalysisImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assists(&self, frange: FileRange) -> Vec<SourceChange> {
|
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 offset = frange.range.start();
|
||||||
let actions = vec![
|
let actions = vec![
|
||||||
ra_editor::flip_comma(&file, offset).map(|f| f()),
|
ra_editor::flip_comma(&file, offset).map(|f| f()),
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub use hir::FnSignatureInfo;
|
||||||
|
|
||||||
pub use ra_db::{
|
pub use ra_db::{
|
||||||
Canceled, Cancelable, FilePosition, FileRange,
|
Canceled, Cancelable, FilePosition, FileRange,
|
||||||
CrateGraph, CrateId, SourceRootId, FileId
|
CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -298,13 +298,13 @@ pub struct Analysis {
|
||||||
|
|
||||||
impl Analysis {
|
impl Analysis {
|
||||||
pub fn file_text(&self, file_id: FileId) -> Arc<String> {
|
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 {
|
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> {
|
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 {
|
pub fn extend_selection(&self, frange: FileRange) -> TextRange {
|
||||||
extend_selection::extend_selection(&self.imp.db, frange)
|
extend_selection::extend_selection(&self.imp.db, frange)
|
||||||
|
@ -313,32 +313,32 @@ impl Analysis {
|
||||||
ra_editor::matching_brace(file, offset)
|
ra_editor::matching_brace(file, offset)
|
||||||
}
|
}
|
||||||
pub fn syntax_tree(&self, file_id: FileId) -> String {
|
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)
|
ra_editor::syntax_tree(&file)
|
||||||
}
|
}
|
||||||
pub fn join_lines(&self, frange: FileRange) -> SourceChange {
|
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))
|
SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range))
|
||||||
}
|
}
|
||||||
pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> {
|
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 edit = ra_editor::on_enter(&file, position.offset)?;
|
||||||
let res = SourceChange::from_local_edit(position.file_id, edit);
|
let res = SourceChange::from_local_edit(position.file_id, edit);
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
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(
|
Some(SourceChange::from_local_edit(
|
||||||
position.file_id,
|
position.file_id,
|
||||||
ra_editor::on_eq_typed(&file, position.offset)?,
|
ra_editor::on_eq_typed(&file, position.offset)?,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
|
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)
|
ra_editor::file_structure(&file)
|
||||||
}
|
}
|
||||||
pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
|
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)
|
ra_editor::folding_ranges(&file)
|
||||||
}
|
}
|
||||||
pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> {
|
pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> {
|
||||||
|
@ -373,7 +373,7 @@ impl Analysis {
|
||||||
Ok(self.imp.crate_root(crate_id))
|
Ok(self.imp.crate_root(crate_id))
|
||||||
}
|
}
|
||||||
pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
|
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))
|
Ok(runnables::runnables(self, &file, file_id))
|
||||||
}
|
}
|
||||||
pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
|
pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue