From 702bdacb03b498f36ed9ccf4f37ca923affb1e9c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 20:44:31 +0300 Subject: move node at offset to aglo already --- crates/ra_editor/src/assists.rs | 4 +--- crates/ra_editor/src/lib.rs | 4 ---- crates/ra_editor/src/typing.rs | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) (limited to 'crates/ra_editor/src') diff --git a/crates/ra_editor/src/assists.rs b/crates/ra_editor/src/assists.rs index f839f6a7a..83eabfc85 100644 --- a/crates/ra_editor/src/assists.rs +++ b/crates/ra_editor/src/assists.rs @@ -14,13 +14,11 @@ mod replace_if_let_with_match; use ra_text_edit::{TextEdit, TextEditBuilder}; use ra_syntax::{ Direction, SyntaxNode, TextUnit, TextRange, SourceFile, AstNode, - algo::{find_leaf_at_offset, find_covering_node, LeafAtOffset}, + algo::{find_leaf_at_offset, find_node_at_offset, find_covering_node, LeafAtOffset}, ast::{self, AstToken}, }; use itertools::Itertools; -use crate::find_node_at_offset; - pub use self::{ flip_comma::flip_comma, add_derive::add_derive, diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index 6731260a3..5a6af19b7 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs @@ -120,10 +120,6 @@ pub fn syntax_tree(file: &SourceFile) -> String { ::ra_syntax::utils::dump_tree(file.syntax()) } -pub fn find_node_at_offset(syntax: &SyntaxNode, offset: TextUnit) -> Option<&N> { - find_leaf_at_offset(syntax, offset).find_map(|leaf| leaf.ancestors().find_map(N::cast)) -} - #[cfg(test)] mod tests { use ra_syntax::AstNode; diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 5b260d2ac..576caf6be 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -2,7 +2,7 @@ use std::mem; use itertools::Itertools; use ra_syntax::{ - algo::{find_covering_node, find_leaf_at_offset, LeafAtOffset}, + algo::{find_node_at_offset, find_covering_node, find_leaf_at_offset, LeafAtOffset}, ast, text_utils::intersect, AstNode, Direction, SourceFile, SyntaxKind, @@ -11,7 +11,7 @@ use ra_syntax::{ }; use ra_text_edit::text_utils::contains_offset_nonstrict; -use crate::{find_node_at_offset, LocalEdit, TextEditBuilder}; +use crate::{LocalEdit, TextEditBuilder}; pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { let range = if range.is_empty() { -- cgit v1.2.3