diff options
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r-- | crates/ra_editor/src/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index de929d73a..a93924e00 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -21,7 +21,7 @@ mod test_utils; | |||
21 | use ra_syntax::{ | 21 | use ra_syntax::{ |
22 | File, TextUnit, TextRange, SyntaxNodeRef, | 22 | File, TextUnit, TextRange, SyntaxNodeRef, |
23 | ast::{self, AstNode, NameOwner}, | 23 | ast::{self, AstNode, NameOwner}, |
24 | algo::{walk, find_leaf_at_offset, ancestors}, | 24 | algo::find_leaf_at_offset, |
25 | SyntaxKind::{self, *}, | 25 | SyntaxKind::{self, *}, |
26 | }; | 26 | }; |
27 | pub use ra_syntax::AtomEdit; | 27 | pub use ra_syntax::AtomEdit; |
@@ -86,7 +86,7 @@ pub fn matching_brace(file: &File, offset: TextUnit) -> Option<TextUnit> { | |||
86 | 86 | ||
87 | pub fn highlight(file: &File) -> Vec<HighlightedRange> { | 87 | pub fn highlight(file: &File) -> Vec<HighlightedRange> { |
88 | let mut res = Vec::new(); | 88 | let mut res = Vec::new(); |
89 | for node in walk::preorder(file.syntax()) { | 89 | for node in file.syntax().descendants() { |
90 | let tag = match node.kind() { | 90 | let tag = match node.kind() { |
91 | ERROR => "error", | 91 | ERROR => "error", |
92 | COMMENT | DOC_COMMENT => "comment", | 92 | COMMENT | DOC_COMMENT => "comment", |
@@ -110,7 +110,7 @@ pub fn highlight(file: &File) -> Vec<HighlightedRange> { | |||
110 | pub fn diagnostics(file: &File) -> Vec<Diagnostic> { | 110 | pub fn diagnostics(file: &File) -> Vec<Diagnostic> { |
111 | let mut res = Vec::new(); | 111 | let mut res = Vec::new(); |
112 | 112 | ||
113 | for node in walk::preorder(file.syntax()) { | 113 | for node in file.syntax().descendants() { |
114 | if node.kind() == ERROR { | 114 | if node.kind() == ERROR { |
115 | res.push(Diagnostic { | 115 | res.push(Diagnostic { |
116 | range: node.range(), | 116 | range: node.range(), |
@@ -130,7 +130,7 @@ pub fn syntax_tree(file: &File) -> String { | |||
130 | } | 130 | } |
131 | 131 | ||
132 | pub fn runnables(file: &File) -> Vec<Runnable> { | 132 | pub fn runnables(file: &File) -> Vec<Runnable> { |
133 | walk::preorder(file.syntax()) | 133 | file.syntax().descendants() |
134 | .filter_map(ast::FnDef::cast) | 134 | .filter_map(ast::FnDef::cast) |
135 | .filter_map(|f| { | 135 | .filter_map(|f| { |
136 | let name = f.name()?.text(); | 136 | let name = f.name()?.text(); |
@@ -159,7 +159,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>( | |||
159 | let leaf = leaves.clone() | 159 | let leaf = leaves.clone() |
160 | .find(|leaf| !leaf.kind().is_trivia()) | 160 | .find(|leaf| !leaf.kind().is_trivia()) |
161 | .or_else(|| leaves.right_biased())?; | 161 | .or_else(|| leaves.right_biased())?; |
162 | ancestors(leaf) | 162 | leaf.ancestors() |
163 | .filter_map(N::cast) | 163 | .filter_map(N::cast) |
164 | .next() | 164 | .next() |
165 | } | 165 | } |