aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-25 09:40:17 +0100
committerAleksey Kladov <[email protected]>2018-08-25 09:40:17 +0100
commit9fae494a8da347a32cdcd3dcd714ba00aaff9664 (patch)
tree9fe4fb51c374d036e22d5a60ce50b63dbe287142 /crates/libeditor/src/lib.rs
parentf104458d45e30024f8a4a02c1ad4101ed74b08f9 (diff)
Move ParsedFile to top
Diffstat (limited to 'crates/libeditor/src/lib.rs')
-rw-r--r--crates/libeditor/src/lib.rs17
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;
10mod typing; 10mod typing;
11 11
12use libsyntax2::{ 12use 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
55pub fn parse(text: &str) -> ast::ParsedFile { 54pub fn parse(text: &str) -> ParsedFile {
56 ast::ParsedFile::parse(text) 55 ParsedFile::parse(text)
57} 56}
58 57
59pub fn matching_brace(file: &ast::ParsedFile, offset: TextUnit) -> Option<TextUnit> { 58pub 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
79pub fn highlight(file: &ast::ParsedFile) -> Vec<HighlightedRange> { 78pub 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
102pub fn diagnostics(file: &ast::ParsedFile) -> Vec<Diagnostic> { 101pub 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
120pub fn syntax_tree(file: &ast::ParsedFile) -> String { 119pub fn syntax_tree(file: &ParsedFile) -> String {
121 ::libsyntax2::utils::dump_tree(file.syntax()) 120 ::libsyntax2::utils::dump_tree(file.syntax())
122} 121}
123 122
124pub fn runnables(file: &ast::ParsedFile) -> Vec<Runnable> { 123pub fn runnables(file: &ParsedFile) -> Vec<Runnable> {
125 file.ast() 124 file.ast()
126 .functions() 125 .functions()
127 .filter_map(|f| { 126 .filter_map(|f| {