From 9fae494a8da347a32cdcd3dcd714ba00aaff9664 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Aug 2018 11:40:17 +0300 Subject: Move ParsedFile to top --- crates/libeditor/src/lib.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'crates/libeditor/src/lib.rs') 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; mod typing; use libsyntax2::{ - ast::{self, NameOwner}, - AstNode, + ast::{self, AstNode, NameOwner}, algo::{walk, find_leaf_at_offset}, SyntaxKind::{self, *}, }; @@ -52,11 +51,11 @@ pub enum RunnableKind { Bin, } -pub fn parse(text: &str) -> ast::ParsedFile { - ast::ParsedFile::parse(text) +pub fn parse(text: &str) -> ParsedFile { + ParsedFile::parse(text) } -pub fn matching_brace(file: &ast::ParsedFile, offset: TextUnit) -> Option { +pub fn matching_brace(file: &ParsedFile, offset: TextUnit) -> Option { const BRACES: &[SyntaxKind] = &[ L_CURLY, R_CURLY, L_BRACK, R_BRACK, @@ -76,7 +75,7 @@ pub fn matching_brace(file: &ast::ParsedFile, offset: TextUnit) -> Option Vec { +pub fn highlight(file: &ParsedFile) -> Vec { let mut res = Vec::new(); for node in walk::preorder(file.syntax()) { let tag = match node.kind() { @@ -99,7 +98,7 @@ pub fn highlight(file: &ast::ParsedFile) -> Vec { res } -pub fn diagnostics(file: &ast::ParsedFile) -> Vec { +pub fn diagnostics(file: &ParsedFile) -> Vec { let mut res = Vec::new(); for node in walk::preorder(file.syntax()) { @@ -117,11 +116,11 @@ pub fn diagnostics(file: &ast::ParsedFile) -> Vec { res } -pub fn syntax_tree(file: &ast::ParsedFile) -> String { +pub fn syntax_tree(file: &ParsedFile) -> String { ::libsyntax2::utils::dump_tree(file.syntax()) } -pub fn runnables(file: &ast::ParsedFile) -> Vec { +pub fn runnables(file: &ParsedFile) -> Vec { file.ast() .functions() .filter_map(|f| { -- cgit v1.2.3