diff options
author | Simon Vandel Sillesen <[email protected]> | 2019-01-05 23:58:03 +0000 |
---|---|---|
committer | Simon Vandel Sillesen <[email protected]> | 2019-01-05 23:58:03 +0000 |
commit | f99398d9d5e47e28f3749c7903df67b9030ac6e0 (patch) | |
tree | 64168a90441da3d19ad725b1b80513deef5864f4 /crates/ra_analysis | |
parent | 3e42a158787955ff9f2e81be43479dbe8f2b1bb6 (diff) |
indent on typing dot. fixes #439
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 30 |
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 | ||
15 | mod db; | ||
16 | mod imp; | ||
17 | mod completion; | 15 | mod completion; |
16 | mod db; | ||
18 | mod goto_defenition; | 17 | mod goto_defenition; |
19 | mod symbol_index; | 18 | mod imp; |
20 | pub mod mock_analysis; | 19 | pub mod mock_analysis; |
21 | mod runnables; | 20 | mod runnables; |
21 | mod symbol_index; | ||
22 | 22 | ||
23 | mod extend_selection; | 23 | mod extend_selection; |
24 | mod syntax_highlighting; | ||
25 | mod hover; | 24 | mod hover; |
25 | mod syntax_highlighting; | ||
26 | 26 | ||
27 | use std::{fmt, sync::Arc}; | 27 | use std::{fmt, sync::Arc}; |
28 | 28 | ||
29 | use rustc_hash::FxHashMap; | 29 | use ra_syntax::{SmolStr, SourceFileNode, SyntaxKind, TextRange, TextUnit}; |
30 | use ra_syntax::{SourceFileNode, TextRange, TextUnit, SmolStr, SyntaxKind}; | ||
31 | use ra_text_edit::TextEdit; | 30 | use ra_text_edit::TextEdit; |
32 | use rayon::prelude::*; | 31 | use rayon::prelude::*; |
33 | use relative_path::RelativePathBuf; | 32 | use relative_path::RelativePathBuf; |
33 | use rustc_hash::FxHashMap; | ||
34 | use salsa::ParallelDatabase; | 34 | use salsa::ParallelDatabase; |
35 | 35 | ||
36 | use crate::symbol_index::{SymbolIndex, FileSymbol}; | 36 | use crate::symbol_index::{FileSymbol, SymbolIndex}; |
37 | 37 | ||
38 | pub use crate::{ | 38 | pub use crate::{ |
39 | completion::{CompletionItem, CompletionItemKind, InsertText}, | 39 | completion::{CompletionItem, CompletionItemKind, InsertText}, |
40 | runnables::{Runnable, RunnableKind}, | 40 | runnables::{Runnable, RunnableKind}, |
41 | }; | 41 | }; |
42 | pub use ra_editor::{ | ||
43 | Fold, FoldKind, HighlightedRange, LineIndex, StructureNode, Severity | ||
44 | }; | ||
45 | pub use hir::FnSignatureInfo; | 42 | pub use hir::FnSignatureInfo; |
43 | pub use ra_editor::{Fold, FoldKind, HighlightedRange, LineIndex, Severity, StructureNode}; | ||
46 | 44 | ||
47 | pub use ra_db::{ | 45 | pub 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> { |