aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-02 15:11:49 +0000
committerAleksey Kladov <[email protected]>2019-01-02 15:11:49 +0000
commit2f22c861a925b6851540430ede0b87fe83c5374c (patch)
tree801061ea610de645b9ce7826d7af39f843ae20aa /crates
parenta94530afb354d2f9a3e3864c678aa496c8de6a23 (diff)
remove some methods from analysis impl
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/imp.rs13
-rw-r--r--crates/ra_analysis/src/lib.rs22
2 files changed, 13 insertions, 22 deletions
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::{
9 self, FnSignatureInfo, Problem, source_binder, 9 self, FnSignatureInfo, Problem, source_binder,
10}; 10};
11use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; 11use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase};
12use ra_editor::{self, find_node_at_offset, LineIndex, LocalEdit, Severity}; 12use ra_editor::{self, find_node_at_offset, LocalEdit, Severity};
13use ra_syntax::{ 13use ra_syntax::{
14 algo::find_covering_node, 14 algo::find_covering_node,
15 ast::{self, ArgListOwner, Expr, FnDef, NameOwner}, 15 ast::{self, ArgListOwner, Expr, FnDef, NameOwner},
@@ -139,15 +139,6 @@ impl fmt::Debug for AnalysisImpl {
139} 139}
140 140
141impl AnalysisImpl { 141impl AnalysisImpl {
142 pub fn file_text(&self, file_id: FileId) -> Arc<String> {
143 self.db.file_text(file_id)
144 }
145 pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode {
146 self.db.source_file(file_id)
147 }
148 pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> {
149 self.db.file_lines(file_id)
150 }
151 pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> { 142 pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> {
152 let descr = match source_binder::module_from_position(&*self.db, position)? { 143 let descr = match source_binder::module_from_position(&*self.db, position)? {
153 None => return Ok(None), 144 None => return Ok(None),
@@ -400,7 +391,7 @@ impl AnalysisImpl {
400 } 391 }
401 392
402 pub fn assists(&self, frange: FileRange) -> Vec<SourceChange> { 393 pub fn assists(&self, frange: FileRange) -> Vec<SourceChange> {
403 let file = self.file_syntax(frange.file_id); 394 let file = self.db.source_file(frange.file_id);
404 let offset = frange.range.start(); 395 let offset = frange.range.start();
405 let actions = vec![ 396 let actions = vec![
406 ra_editor::flip_comma(&file, offset).map(|f| f()), 397 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;
44 44
45pub use ra_db::{ 45pub use ra_db::{
46 Canceled, Cancelable, FilePosition, FileRange, 46 Canceled, Cancelable, FilePosition, FileRange,
47 CrateGraph, CrateId, SourceRootId, FileId 47 CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase
48}; 48};
49 49
50#[derive(Default)] 50#[derive(Default)]
@@ -298,13 +298,13 @@ pub struct Analysis {
298 298
299impl Analysis { 299impl Analysis {
300 pub fn file_text(&self, file_id: FileId) -> Arc<String> { 300 pub fn file_text(&self, file_id: FileId) -> Arc<String> {
301 self.imp.file_text(file_id) 301 self.imp.db.file_text(file_id)
302 } 302 }
303 pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { 303 pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode {
304 self.imp.file_syntax(file_id).clone() 304 self.imp.db.source_file(file_id).clone()
305 } 305 }
306 pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { 306 pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> {
307 self.imp.file_line_index(file_id) 307 self.imp.db.file_lines(file_id)
308 } 308 }
309 pub fn extend_selection(&self, frange: FileRange) -> TextRange { 309 pub fn extend_selection(&self, frange: FileRange) -> TextRange {
310 extend_selection::extend_selection(&self.imp.db, frange) 310 extend_selection::extend_selection(&self.imp.db, frange)
@@ -313,32 +313,32 @@ impl Analysis {
313 ra_editor::matching_brace(file, offset) 313 ra_editor::matching_brace(file, offset)
314 } 314 }
315 pub fn syntax_tree(&self, file_id: FileId) -> String { 315 pub fn syntax_tree(&self, file_id: FileId) -> String {
316 let file = self.imp.file_syntax(file_id); 316 let file = self.imp.db.source_file(file_id);
317 ra_editor::syntax_tree(&file) 317 ra_editor::syntax_tree(&file)
318 } 318 }
319 pub fn join_lines(&self, frange: FileRange) -> SourceChange { 319 pub fn join_lines(&self, frange: FileRange) -> SourceChange {
320 let file = self.imp.file_syntax(frange.file_id); 320 let file = self.imp.db.source_file(frange.file_id);
321 SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range)) 321 SourceChange::from_local_edit(frange.file_id, ra_editor::join_lines(&file, frange.range))
322 } 322 }
323 pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { 323 pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> {
324 let file = self.imp.file_syntax(position.file_id); 324 let file = self.imp.db.source_file(position.file_id);
325 let edit = ra_editor::on_enter(&file, position.offset)?; 325 let edit = ra_editor::on_enter(&file, position.offset)?;
326 let res = SourceChange::from_local_edit(position.file_id, edit); 326 let res = SourceChange::from_local_edit(position.file_id, edit);
327 Some(res) 327 Some(res)
328 } 328 }
329 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { 329 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
330 let file = self.imp.file_syntax(position.file_id); 330 let file = self.imp.db.source_file(position.file_id);
331 Some(SourceChange::from_local_edit( 331 Some(SourceChange::from_local_edit(
332 position.file_id, 332 position.file_id,
333 ra_editor::on_eq_typed(&file, position.offset)?, 333 ra_editor::on_eq_typed(&file, position.offset)?,
334 )) 334 ))
335 } 335 }
336 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { 336 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
337 let file = self.imp.file_syntax(file_id); 337 let file = self.imp.db.source_file(file_id);
338 ra_editor::file_structure(&file) 338 ra_editor::file_structure(&file)
339 } 339 }
340 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> { 340 pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
341 let file = self.imp.file_syntax(file_id); 341 let file = self.imp.db.source_file(file_id);
342 ra_editor::folding_ranges(&file) 342 ra_editor::folding_ranges(&file)
343 } 343 }
344 pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> { 344 pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> {
@@ -373,7 +373,7 @@ impl Analysis {
373 Ok(self.imp.crate_root(crate_id)) 373 Ok(self.imp.crate_root(crate_id))
374 } 374 }
375 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { 375 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
376 let file = self.imp.file_syntax(file_id); 376 let file = self.imp.db.source_file(file_id);
377 Ok(runnables::runnables(self, &file, file_id)) 377 Ok(runnables::runnables(self, &file, file_id))
378 } 378 }
379 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { 379 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {