diff options
Diffstat (limited to 'crates/libeditor/src/lib.rs')
-rw-r--r-- | crates/libeditor/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index b29603da3..b2d1dab58 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs | |||
@@ -10,8 +10,7 @@ mod code_actions; | |||
10 | mod typing; | 10 | mod typing; |
11 | 11 | ||
12 | use libsyntax2::{ | 12 | use libsyntax2::{ |
13 | ast::{self, NameOwner}, | 13 | ast::{self, AstNode, NameOwner}, |
14 | AstNode, | ||
15 | algo::{walk, find_leaf_at_offset}, | 14 | algo::{walk, find_leaf_at_offset}, |
16 | SyntaxKind::{self, *}, | 15 | SyntaxKind::{self, *}, |
17 | }; | 16 | }; |
@@ -52,11 +51,11 @@ pub enum RunnableKind { | |||
52 | Bin, | 51 | Bin, |
53 | } | 52 | } |
54 | 53 | ||
55 | pub fn parse(text: &str) -> ast::ParsedFile { | 54 | pub fn parse(text: &str) -> ParsedFile { |
56 | ast::ParsedFile::parse(text) | 55 | ParsedFile::parse(text) |
57 | } | 56 | } |
58 | 57 | ||
59 | pub fn matching_brace(file: &ast::ParsedFile, offset: TextUnit) -> Option<TextUnit> { | 58 | pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option<TextUnit> { |
60 | const BRACES: &[SyntaxKind] = &[ | 59 | const BRACES: &[SyntaxKind] = &[ |
61 | L_CURLY, R_CURLY, | 60 | L_CURLY, R_CURLY, |
62 | L_BRACK, R_BRACK, | 61 | L_BRACK, R_BRACK, |
@@ -76,7 +75,7 @@ pub fn matching_brace(file: &ast::ParsedFile, offset: TextUnit) -> Option<TextUn | |||
76 | Some(matching_node.range().start()) | 75 | Some(matching_node.range().start()) |
77 | } | 76 | } |
78 | 77 | ||
79 | pub fn highlight(file: &ast::ParsedFile) -> Vec<HighlightedRange> { | 78 | pub fn highlight(file: &ParsedFile) -> Vec<HighlightedRange> { |
80 | let mut res = Vec::new(); | 79 | let mut res = Vec::new(); |
81 | for node in walk::preorder(file.syntax()) { | 80 | for node in walk::preorder(file.syntax()) { |
82 | let tag = match node.kind() { | 81 | let tag = match node.kind() { |
@@ -99,7 +98,7 @@ pub fn highlight(file: &ast::ParsedFile) -> Vec<HighlightedRange> { | |||
99 | res | 98 | res |
100 | } | 99 | } |
101 | 100 | ||
102 | pub fn diagnostics(file: &ast::ParsedFile) -> Vec<Diagnostic> { | 101 | pub fn diagnostics(file: &ParsedFile) -> Vec<Diagnostic> { |
103 | let mut res = Vec::new(); | 102 | let mut res = Vec::new(); |
104 | 103 | ||
105 | for node in walk::preorder(file.syntax()) { | 104 | for node in walk::preorder(file.syntax()) { |
@@ -117,11 +116,11 @@ pub fn diagnostics(file: &ast::ParsedFile) -> Vec<Diagnostic> { | |||
117 | res | 116 | res |
118 | } | 117 | } |
119 | 118 | ||
120 | pub fn syntax_tree(file: &ast::ParsedFile) -> String { | 119 | pub fn syntax_tree(file: &ParsedFile) -> String { |
121 | ::libsyntax2::utils::dump_tree(file.syntax()) | 120 | ::libsyntax2::utils::dump_tree(file.syntax()) |
122 | } | 121 | } |
123 | 122 | ||
124 | pub fn runnables(file: &ast::ParsedFile) -> Vec<Runnable> { | 123 | pub fn runnables(file: &ParsedFile) -> Vec<Runnable> { |
125 | file.ast() | 124 | file.ast() |
126 | .functions() | 125 | .functions() |
127 | .filter_map(|f| { | 126 | .filter_map(|f| { |