From 6dbba4d75d56728a95f84ee978eae3ac84016c73 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Jan 2021 20:15:33 +0300 Subject: Remove useless wrapper --- crates/syntax/src/algo.rs | 6 +----- crates/syntax/src/parsing/reparsing.rs | 5 ++--- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'crates/syntax') diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 384d031e7..1456270d0 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -45,7 +45,7 @@ pub fn find_node_at_offset(syntax: &SyntaxNode, offset: TextSize) -> } pub fn find_node_at_range(syntax: &SyntaxNode, range: TextRange) -> Option { - find_covering_element(syntax, range).ancestors().find_map(N::cast) + syntax.covering_element(range).ancestors().find_map(N::cast) } /// Skip to next non `trivia` token @@ -74,10 +74,6 @@ pub fn non_trivia_sibling(element: SyntaxElement, direction: Direction) -> Optio } } -pub fn find_covering_element(root: &SyntaxNode, range: TextRange) -> SyntaxElement { - root.covering_element(range) -} - pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option { if u == v { return Some(u.clone()); diff --git a/crates/syntax/src/parsing/reparsing.rs b/crates/syntax/src/parsing/reparsing.rs index 78eaf3410..76f01084c 100644 --- a/crates/syntax/src/parsing/reparsing.rs +++ b/crates/syntax/src/parsing/reparsing.rs @@ -10,7 +10,6 @@ use parser::Reparser; use text_edit::Indel; use crate::{ - algo, parsing::{ lexer::{lex_single_syntax_kind, tokenize, Token}, text_token_source::TextTokenSource, @@ -41,7 +40,7 @@ fn reparse_token<'node>( root: &'node SyntaxNode, edit: &Indel, ) -> Option<(GreenNode, Vec, TextRange)> { - let prev_token = algo::find_covering_element(root, edit.delete).as_token()?.clone(); + let prev_token = root.covering_element(edit.delete).as_token()?.clone(); let prev_token_kind = prev_token.kind(); match prev_token_kind { WHITESPACE | COMMENT | IDENT | STRING => { @@ -124,7 +123,7 @@ fn is_contextual_kw(text: &str) -> bool { } fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { - let node = algo::find_covering_element(node, range); + let node = node.covering_element(range); let mut ancestors = match node { NodeOrToken::Token(it) => it.parent().ancestors(), -- cgit v1.2.3