aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilco Kusee <[email protected]>2019-03-23 11:07:21 +0000
committerWilco Kusee <[email protected]>2019-03-23 11:11:46 +0000
commit0c15deac760a654f03de3ae433e5260b5bdfb8c2 (patch)
tree89d7c73cb325fa14db2c6e16e8d906548849a730
parentd99abe4c252447c9940f77568a96c9a96f6f8905 (diff)
Move typing to ra_ide_api
-rw-r--r--crates/ra_ide_api/src/lib.rs7
-rw-r--r--crates/ra_ide_api/src/typing.rs (renamed from crates/ra_ide_api_light/src/typing.rs)3
-rw-r--r--crates/ra_ide_api_light/src/lib.rs3
3 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index a838c30da..c2ef61ae2 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -37,6 +37,7 @@ mod line_index;
37mod folding_ranges; 37mod folding_ranges;
38mod line_index_utils; 38mod line_index_utils;
39mod join_lines; 39mod join_lines;
40mod typing;
40 41
41#[cfg(test)] 42#[cfg(test)]
42mod marks; 43mod marks;
@@ -295,7 +296,7 @@ impl Analysis {
295 /// up minor stuff like continuing the comment. 296 /// up minor stuff like continuing the comment.
296 pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> { 297 pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> {
297 let file = self.db.parse(position.file_id); 298 let file = self.db.parse(position.file_id);
298 let edit = ra_ide_api_light::on_enter(&file, position.offset)?; 299 let edit = typing::on_enter(&file, position.offset)?;
299 Some(SourceChange::from_local_edit(position.file_id, edit)) 300 Some(SourceChange::from_local_edit(position.file_id, edit))
300 } 301 }
301 302
@@ -304,14 +305,14 @@ impl Analysis {
304 // FIXME: use a snippet completion instead of this hack here. 305 // FIXME: use a snippet completion instead of this hack here.
305 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> { 306 pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
306 let file = self.db.parse(position.file_id); 307 let file = self.db.parse(position.file_id);
307 let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?; 308 let edit = typing::on_eq_typed(&file, position.offset)?;
308 Some(SourceChange::from_local_edit(position.file_id, edit)) 309 Some(SourceChange::from_local_edit(position.file_id, edit))
309 } 310 }
310 311
311 /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. 312 /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
312 pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> { 313 pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> {
313 let file = self.db.parse(position.file_id); 314 let file = self.db.parse(position.file_id);
314 let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?; 315 let edit = typing::on_dot_typed(&file, position.offset)?;
315 Some(SourceChange::from_local_edit(position.file_id, edit)) 316 Some(SourceChange::from_local_edit(position.file_id, edit))
316 } 317 }
317 318
diff --git a/crates/ra_ide_api_light/src/typing.rs b/crates/ra_ide_api/src/typing.rs
index c69270333..b7e023d60 100644
--- a/crates/ra_ide_api_light/src/typing.rs
+++ b/crates/ra_ide_api/src/typing.rs
@@ -5,7 +5,8 @@ use ra_syntax::{
5 ast::{self, AstToken}, 5 ast::{self, AstToken},
6}; 6};
7use ra_fmt::leading_indent; 7use ra_fmt::leading_indent;
8use crate::{LocalEdit, TextEditBuilder}; 8use crate::LocalEdit;
9use ra_text_edit::TextEditBuilder;
9 10
10pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> { 11pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> {
11 let comment = 12 let comment =
diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs
index f21a91e18..0d928745f 100644
--- a/crates/ra_ide_api_light/src/lib.rs
+++ b/crates/ra_ide_api_light/src/lib.rs
@@ -4,10 +4,8 @@
4//! an edit or some auxiliary info. 4//! an edit or some auxiliary info.
5 5
6mod structure; 6mod structure;
7mod typing;
8 7
9use rustc_hash::FxHashSet; 8use rustc_hash::FxHashSet;
10use ra_text_edit::TextEditBuilder;
11use ra_syntax::{ 9use ra_syntax::{
12 SourceFile, SyntaxNode, TextRange, TextUnit, Direction, 10 SourceFile, SyntaxNode, TextRange, TextUnit, Direction,
13 algo::find_leaf_at_offset, 11 algo::find_leaf_at_offset,
@@ -17,7 +15,6 @@ use ra_syntax::{
17 15
18pub use crate::{ 16pub use crate::{
19 structure::{file_structure, StructureNode}, 17 structure::{file_structure, StructureNode},
20 typing::{on_enter, on_dot_typed, on_eq_typed},
21}; 18};
22 19
23#[derive(Debug)] 20#[derive(Debug)]