From 70097504f78c4c41368a0b864a94df95fb9c27f7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Aug 2018 21:10:55 +0300 Subject: hide root --- crates/libeditor/src/code_actions.rs | 5 ++--- crates/libeditor/src/symbols.rs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/libeditor/src') diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs index 4b2515835..bb6eb0d61 100644 --- a/crates/libeditor/src/code_actions.rs +++ b/crates/libeditor/src/code_actions.rs @@ -2,8 +2,7 @@ use {TextUnit, File, EditBuilder, Edit}; use libsyntax2::{ ast::{self, AstNode, AttrsOwner}, SyntaxKind::COMMA, - SyntaxNodeRef, - SyntaxRoot, + SyntaxNodeRef, RefRoot, algo::{ Direction, siblings, find_leaf_at_offset, ancestors, @@ -71,7 +70,7 @@ fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option>(syntax: SyntaxNodeRef<'a>, offset: TextUnit) -> Option { +pub fn find_node<'a, N: AstNode>>(syntax: SyntaxNodeRef<'a>, offset: TextUnit) -> Option { let leaves = find_leaf_at_offset(syntax, offset); let leaf = leaves.clone() .find(|leaf| !leaf.kind().is_trivia()) diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index ce870430e..cf5bd2a41 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs @@ -1,6 +1,6 @@ use smol_str::SmolStr; use libsyntax2::{ - SyntaxKind, SyntaxNodeRef, SyntaxRoot, AstNode, + SyntaxKind, SyntaxNodeRef, AstNode, RefRoot, ast::{self, NameOwner}, algo::{ visit::{visitor, Visitor}, @@ -32,7 +32,7 @@ pub fn file_symbols(file: &ast::File) -> Vec { } fn to_symbol(node: SyntaxNodeRef) -> Option { - fn decl<'a, N: NameOwner<&'a SyntaxRoot>>(node: N) -> Option { + fn decl<'a, N: NameOwner>>(node: N) -> Option { let name = node.name()?; Some(FileSymbol { name: name.text(), @@ -80,7 +80,7 @@ pub fn file_structure(file: &ast::File) -> Vec { } fn structure_node(node: SyntaxNodeRef) -> Option { - fn decl<'a, N: NameOwner<&'a SyntaxRoot>>(node: N) -> Option { + fn decl<'a, N: NameOwner>>(node: N) -> Option { let name = node.name()?; Some(StructureNode { parent: None, -- cgit v1.2.3