From 7094291573dc819e3115950ec3b2316bd5e9ea33 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Aug 2018 12:51:40 +0300 Subject: tt-attrs --- crates/libeditor/src/lib.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/libeditor/src/lib.rs') diff --git a/crates/libeditor/src/lib.rs b/crates/libeditor/src/lib.rs index 28da457d1..76cb4d028 100644 --- a/crates/libeditor/src/lib.rs +++ b/crates/libeditor/src/lib.rs @@ -21,7 +21,10 @@ pub use self::{ extend_selection::extend_selection, symbols::{StructureNode, file_structure, FileSymbol, file_symbols}, edit::{EditBuilder, Edit, AtomEdit}, - code_actions::{flip_comma, add_derive, ActionResult, CursorPosition}, + code_actions::{ + ActionResult, CursorPosition, find_node, + flip_comma, add_derive, + }, }; #[derive(Debug)] @@ -59,9 +62,7 @@ pub fn matching_brace(file: &ast::File, offset: TextUnit) -> Option { L_PAREN, R_PAREN, L_ANGLE, R_ANGLE, ]; - let syntax = file.syntax(); - let syntax = syntax.as_ref(); - let (brace_node, brace_idx) = find_leaf_at_offset(syntax, offset) + let (brace_node, brace_idx) = find_leaf_at_offset(file.syntax_ref(), offset) .filter_map(|node| { let idx = BRACES.iter().position(|&brace| brace == node.kind())?; Some((node, idx)) @@ -75,9 +76,8 @@ pub fn matching_brace(file: &ast::File, offset: TextUnit) -> Option { } pub fn highlight(file: &ast::File) -> Vec { - let syntax = file.syntax(); let mut res = Vec::new(); - for node in walk::preorder(syntax.as_ref()) { + for node in walk::preorder(file.syntax_ref()) { let tag = match node.kind() { ERROR => "error", COMMENT | DOC_COMMENT => "comment", @@ -99,10 +99,9 @@ pub fn highlight(file: &ast::File) -> Vec { } pub fn diagnostics(file: &ast::File) -> Vec { - let syntax = file.syntax(); let mut res = Vec::new(); - for node in walk::preorder(syntax.as_ref()) { + for node in walk::preorder(file.syntax_ref()) { if node.kind() == ERROR { res.push(Diagnostic { range: node.range(), -- cgit v1.2.3