diff options
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r-- | crates/ra_editor/src/lib.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index f92181b86..ff4e8303d 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -30,7 +30,7 @@ pub use ra_syntax::AtomEdit; | |||
30 | use ra_syntax::{ | 30 | use ra_syntax::{ |
31 | algo::find_leaf_at_offset, | 31 | algo::find_leaf_at_offset, |
32 | ast::{self, AstNode, NameOwner}, | 32 | ast::{self, AstNode, NameOwner}, |
33 | File, | 33 | SourceFileNode, |
34 | Location, | 34 | Location, |
35 | SyntaxKind::{self, *}, | 35 | SyntaxKind::{self, *}, |
36 | SyntaxNodeRef, TextRange, TextUnit, | 36 | SyntaxNodeRef, TextRange, TextUnit, |
@@ -60,7 +60,7 @@ pub enum RunnableKind { | |||
60 | Bin, | 60 | Bin, |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn matching_brace(file: &File, offset: TextUnit) -> Option<TextUnit> { | 63 | pub fn matching_brace(file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { |
64 | const BRACES: &[SyntaxKind] = &[ | 64 | const BRACES: &[SyntaxKind] = &[ |
65 | L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE, | 65 | L_CURLY, R_CURLY, L_BRACK, R_BRACK, L_PAREN, R_PAREN, L_ANGLE, R_ANGLE, |
66 | ]; | 66 | ]; |
@@ -78,7 +78,7 @@ pub fn matching_brace(file: &File, offset: TextUnit) -> Option<TextUnit> { | |||
78 | Some(matching_node.range().start()) | 78 | Some(matching_node.range().start()) |
79 | } | 79 | } |
80 | 80 | ||
81 | pub fn highlight(file: &File) -> Vec<HighlightedRange> { | 81 | pub fn highlight(file: &SourceFileNode) -> Vec<HighlightedRange> { |
82 | let mut res = Vec::new(); | 82 | let mut res = Vec::new(); |
83 | for node in file.syntax().descendants() { | 83 | for node in file.syntax().descendants() { |
84 | let tag = match node.kind() { | 84 | let tag = match node.kind() { |
@@ -100,7 +100,7 @@ pub fn highlight(file: &File) -> Vec<HighlightedRange> { | |||
100 | res | 100 | res |
101 | } | 101 | } |
102 | 102 | ||
103 | pub fn diagnostics(file: &File) -> Vec<Diagnostic> { | 103 | pub fn diagnostics(file: &SourceFileNode) -> Vec<Diagnostic> { |
104 | fn location_to_range(location: Location) -> TextRange { | 104 | fn location_to_range(location: Location) -> TextRange { |
105 | match location { | 105 | match location { |
106 | Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), | 106 | Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), |
@@ -117,11 +117,11 @@ pub fn diagnostics(file: &File) -> Vec<Diagnostic> { | |||
117 | .collect() | 117 | .collect() |
118 | } | 118 | } |
119 | 119 | ||
120 | pub fn syntax_tree(file: &File) -> String { | 120 | pub fn syntax_tree(file: &SourceFileNode) -> String { |
121 | ::ra_syntax::utils::dump_tree(file.syntax()) | 121 | ::ra_syntax::utils::dump_tree(file.syntax()) |
122 | } | 122 | } |
123 | 123 | ||
124 | pub fn runnables(file: &File) -> Vec<Runnable> { | 124 | pub fn runnables(file: &SourceFileNode) -> Vec<Runnable> { |
125 | file.syntax() | 125 | file.syntax() |
126 | .descendants() | 126 | .descendants() |
127 | .filter_map(ast::FnDef::cast) | 127 | .filter_map(ast::FnDef::cast) |
@@ -163,7 +163,7 @@ mod tests { | |||
163 | 163 | ||
164 | #[test] | 164 | #[test] |
165 | fn test_highlighting() { | 165 | fn test_highlighting() { |
166 | let file = File::parse( | 166 | let file = SourceFileNode::parse( |
167 | r#" | 167 | r#" |
168 | // comment | 168 | // comment |
169 | fn main() {} | 169 | fn main() {} |
@@ -184,7 +184,7 @@ fn main() {} | |||
184 | 184 | ||
185 | #[test] | 185 | #[test] |
186 | fn test_runnables() { | 186 | fn test_runnables() { |
187 | let file = File::parse( | 187 | let file = SourceFileNode::parse( |
188 | r#" | 188 | r#" |
189 | fn main() {} | 189 | fn main() {} |
190 | 190 | ||
@@ -209,7 +209,7 @@ fn test_foo() {} | |||
209 | fn test_matching_brace() { | 209 | fn test_matching_brace() { |
210 | fn do_check(before: &str, after: &str) { | 210 | fn do_check(before: &str, after: &str) { |
211 | let (pos, before) = extract_offset(before); | 211 | let (pos, before) = extract_offset(before); |
212 | let file = File::parse(&before); | 212 | let file = SourceFileNode::parse(&before); |
213 | let new_pos = match matching_brace(&file, pos) { | 213 | let new_pos = match matching_brace(&file, pos) { |
214 | None => pos, | 214 | None => pos, |
215 | Some(pos) => pos, | 215 | Some(pos) => pos, |