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/libanalysis/src/lib.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'crates/libanalysis/src') diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 983029587..85c23e4d9 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs @@ -26,9 +26,8 @@ use std::{ use libsyntax2::{ TextUnit, ast::{self, AstNode}, - algo::{find_leaf_at_offset, ancestors}, }; -use libeditor::{LineIndex, FileSymbol}; +use libeditor::{LineIndex, FileSymbol, find_node}; use self::symbol_index::FileSymbols; pub use self::symbol_index::Query; @@ -123,13 +122,7 @@ impl World { let file = self.file_syntax(id)?; let syntax = file.syntax(); let syntax = syntax.as_ref(); - let name_ref = - find_leaf_at_offset(syntax, offset) - .left_biased() - .into_iter() - .flat_map(|node| ancestors(node)) - .flat_map(ast::NameRef::cast) - .next(); + let name_ref = find_node::>(syntax, offset); let name = match name_ref { None => return Ok(vec![]), Some(name_ref) => name_ref.text(), -- cgit v1.2.3