aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r--crates/ra_analysis/src/lib.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 390c31c3f..feed44b2d 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -12,41 +12,39 @@ macro_rules! ctry {
12 }; 12 };
13} 13}
14 14
15mod db;
16mod imp;
17mod completion; 15mod completion;
16mod db;
18mod goto_defenition; 17mod goto_defenition;
19mod symbol_index; 18mod imp;
20pub mod mock_analysis; 19pub mod mock_analysis;
21mod runnables; 20mod runnables;
21mod symbol_index;
22 22
23mod extend_selection; 23mod extend_selection;
24mod syntax_highlighting;
25mod hover; 24mod hover;
25mod syntax_highlighting;
26 26
27use std::{fmt, sync::Arc}; 27use std::{fmt, sync::Arc};
28 28
29use rustc_hash::FxHashMap; 29use ra_syntax::{SmolStr, SourceFileNode, SyntaxKind, TextRange, TextUnit};
30use ra_syntax::{SourceFileNode, TextRange, TextUnit, SmolStr, SyntaxKind};
31use ra_text_edit::TextEdit; 30use ra_text_edit::TextEdit;
32use rayon::prelude::*; 31use rayon::prelude::*;
33use relative_path::RelativePathBuf; 32use relative_path::RelativePathBuf;
33use rustc_hash::FxHashMap;
34use salsa::ParallelDatabase; 34use salsa::ParallelDatabase;
35 35
36use crate::symbol_index::{SymbolIndex, FileSymbol}; 36use crate::symbol_index::{FileSymbol, SymbolIndex};
37 37
38pub use crate::{ 38pub use crate::{
39 completion::{CompletionItem, CompletionItemKind, InsertText}, 39 completion::{CompletionItem, CompletionItemKind, InsertText},
40 runnables::{Runnable, RunnableKind}, 40 runnables::{Runnable, RunnableKind},
41}; 41};
42pub use ra_editor::{
43 Fold, FoldKind, HighlightedRange, LineIndex, StructureNode, Severity
44};
45pub use hir::FnSignatureInfo; 42pub use hir::FnSignatureInfo;
43pub use ra_editor::{Fold, FoldKind, HighlightedRange, LineIndex, Severity, StructureNode};
46 44
47pub use ra_db::{ 45pub use ra_db::{
48 Canceled, Cancelable, FilePosition, FileRange, LocalSyntaxPtr, 46 Cancelable, Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, FilesDatabase,
49 CrateGraph, CrateId, SourceRootId, FileId, SyntaxDatabase, FilesDatabase 47 LocalSyntaxPtr, SourceRootId, SyntaxDatabase,
50}; 48};
51 49
52#[derive(Default)] 50#[derive(Default)]
@@ -346,7 +344,7 @@ impl Analysis {
346 let edit = ra_editor::on_enter(&file, position.offset)?; 344 let edit = ra_editor::on_enter(&file, position.offset)?;
347 Some(SourceChange::from_local_edit(position.file_id, edit)) 345 Some(SourceChange::from_local_edit(position.file_id, edit))
348 } 346 }
349 /// Returns an edit which should be applied after `=` was typed. Primaraly, 347 /// Returns an edit which should be applied after `=` was typed. Primarily,
350 /// this works when adding `let =`. 348 /// this works when adding `let =`.
351 // FIXME: use a snippet completion instead of this hack here. 349 // FIXME: use a snippet completion instead of this hack here.
352 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { 350 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
@@ -354,6 +352,12 @@ impl Analysis {
354 let edit = ra_editor::on_eq_typed(&file, position.offset)?; 352 let edit = ra_editor::on_eq_typed(&file, position.offset)?;
355 Some(SourceChange::from_local_edit(position.file_id, edit)) 353 Some(SourceChange::from_local_edit(position.file_id, edit))
356 } 354 }
355 /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
356 pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> {
357 let file = self.db.source_file(position.file_id);
358 let edit = ra_editor::on_dot_typed(&file, position.offset)?;
359 Some(SourceChange::from_local_edit(position.file_id, edit))
360 }
357 /// Returns a tree representation of symbols in the file. Useful to draw a 361 /// Returns a tree representation of symbols in the file. Useful to draw a
358 /// file outline. 362 /// file outline.
359 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> { 363 pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {