aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src
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
parentf104458d45e30024f8a4a02c1ad4101ed74b08f9 (diff)
Move ParsedFile to top
Diffstat (limited to 'crates/libeditor/src')
-rw-r--r--crates/libeditor/src/code_actions.rs3
-rw-r--r--crates/libeditor/src/lib.rs17
-rw-r--r--crates/libeditor/src/typing.rs4
3 files changed, 12 insertions, 12 deletions
diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs
index c25ee973c..c7c043b39 100644
--- a/crates/libeditor/src/code_actions.rs
+++ b/crates/libeditor/src/code_actions.rs
@@ -3,7 +3,8 @@ use std::{
3}; 3};
4 4
5use libsyntax2::{ 5use libsyntax2::{
6 ast::{self, AstNode, AttrsOwner, TypeParamsOwner, NameOwner, ParsedFile}, 6 ParsedFile,
7 ast::{self, AstNode, AttrsOwner, TypeParamsOwner, NameOwner},
7 SyntaxKind::COMMA, 8 SyntaxKind::COMMA,
8 SyntaxNodeRef, 9 SyntaxNodeRef,
9 algo::{ 10 algo::{
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| {
diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs
index cc0d3d272..8903af177 100644
--- a/crates/libeditor/src/typing.rs
+++ b/crates/libeditor/src/typing.rs
@@ -1,5 +1,5 @@
1use libsyntax2::{ 1use libsyntax2::{
2 TextUnit, TextRange, SyntaxNodeRef, 2 TextUnit, TextRange, SyntaxNodeRef, ParsedFile,
3 ast, 3 ast,
4 algo::{ 4 algo::{
5 walk::preorder, 5 walk::preorder,
@@ -11,7 +11,7 @@ use libsyntax2::{
11 11
12use {ActionResult, EditBuilder}; 12use {ActionResult, EditBuilder};
13 13
14pub fn join_lines(file: &ast::ParsedFile, range: TextRange) -> ActionResult { 14pub fn join_lines(file: &ParsedFile, range: TextRange) -> ActionResult {
15 let range = if range.is_empty() { 15 let range = if range.is_empty() {
16 let text = file.syntax().text(); 16 let text = file.syntax().text();
17 let text = &text[TextRange::from_to(range.start(), TextUnit::of_str(&text))]; 17 let text = &text[TextRange::from_to(range.start(), TextUnit::of_str(&text))];