diff options
Diffstat (limited to 'crates/ra_editor')
-rw-r--r-- | crates/ra_editor/src/assists.rs | 4 | ||||
-rw-r--r-- | crates/ra_editor/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_editor/src/typing.rs | 4 |
3 files changed, 3 insertions, 9 deletions
diff --git a/crates/ra_editor/src/assists.rs b/crates/ra_editor/src/assists.rs index f839f6a7a..83eabfc85 100644 --- a/crates/ra_editor/src/assists.rs +++ b/crates/ra_editor/src/assists.rs | |||
@@ -14,13 +14,11 @@ mod replace_if_let_with_match; | |||
14 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 14 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
15 | use ra_syntax::{ | 15 | use ra_syntax::{ |
16 | Direction, SyntaxNode, TextUnit, TextRange, SourceFile, AstNode, | 16 | Direction, SyntaxNode, TextUnit, TextRange, SourceFile, AstNode, |
17 | algo::{find_leaf_at_offset, find_covering_node, LeafAtOffset}, | 17 | algo::{find_leaf_at_offset, find_node_at_offset, find_covering_node, LeafAtOffset}, |
18 | ast::{self, AstToken}, | 18 | ast::{self, AstToken}, |
19 | }; | 19 | }; |
20 | use itertools::Itertools; | 20 | use itertools::Itertools; |
21 | 21 | ||
22 | use crate::find_node_at_offset; | ||
23 | |||
24 | pub use self::{ | 22 | pub use self::{ |
25 | flip_comma::flip_comma, | 23 | flip_comma::flip_comma, |
26 | add_derive::add_derive, | 24 | add_derive::add_derive, |
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index 6731260a3..5a6af19b7 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -120,10 +120,6 @@ pub fn syntax_tree(file: &SourceFile) -> String { | |||
120 | ::ra_syntax::utils::dump_tree(file.syntax()) | 120 | ::ra_syntax::utils::dump_tree(file.syntax()) |
121 | } | 121 | } |
122 | 122 | ||
123 | pub fn find_node_at_offset<N: AstNode>(syntax: &SyntaxNode, offset: TextUnit) -> Option<&N> { | ||
124 | find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast)) | ||
125 | } | ||
126 | |||
127 | #[cfg(test)] | 123 | #[cfg(test)] |
128 | mod tests { | 124 | mod tests { |
129 | use ra_syntax::AstNode; | 125 | use ra_syntax::AstNode; |
diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 5b260d2ac..576caf6be 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs | |||
@@ -2,7 +2,7 @@ use std::mem; | |||
2 | 2 | ||
3 | use itertools::Itertools; | 3 | use itertools::Itertools; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | algo::{find_covering_node, find_leaf_at_offset, LeafAtOffset}, | 5 | algo::{find_node_at_offset, find_covering_node, find_leaf_at_offset, LeafAtOffset}, |
6 | ast, | 6 | ast, |
7 | text_utils::intersect, | 7 | text_utils::intersect, |
8 | AstNode, Direction, SourceFile, SyntaxKind, | 8 | AstNode, Direction, SourceFile, SyntaxKind, |
@@ -11,7 +11,7 @@ use ra_syntax::{ | |||
11 | }; | 11 | }; |
12 | use ra_text_edit::text_utils::contains_offset_nonstrict; | 12 | use ra_text_edit::text_utils::contains_offset_nonstrict; |
13 | 13 | ||
14 | use crate::{find_node_at_offset, LocalEdit, TextEditBuilder}; | 14 | use crate::{LocalEdit, TextEditBuilder}; |
15 | 15 | ||
16 | pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { | 16 | pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { |
17 | let range = if range.is_empty() { | 17 | let range = if range.is_empty() { |