From 3ffd5dd2a63e8efe182e79439a879ec1f9420b77 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 8 Jan 2019 11:47:28 +0300 Subject: migrate ra_analysis to new rowan --- crates/ra_analysis/src/imp.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'crates/ra_analysis/src/imp.rs') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 07a966290..8ac430e41 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -8,10 +8,9 @@ use hir::{ use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; use ra_editor::{self, find_node_at_offset, assists, LocalEdit, Severity}; use ra_syntax::{ - ast::{self, ArgListOwner, Expr, NameOwner}, - AstNode, SourceFileNode, + SyntaxNode, TextRange, TextUnit, AstNode, SourceFile, + ast::{self, ArgListOwner, NameOwner}, SyntaxKind::*, - SyntaxNodeRef, TextRange, TextUnit, }; use crate::{ @@ -113,7 +112,6 @@ impl db::RootDatabase { None => return Ok(Vec::new()), Some(it) => it, }; - let ast_module = ast_module.borrowed(); let name = ast_module.name().unwrap(); Ok(vec![NavigationTarget { file_id, @@ -163,9 +161,9 @@ impl db::RootDatabase { fn find_binding<'a>( db: &db::RootDatabase, - source_file: &'a SourceFileNode, + source_file: &'a SourceFile, position: FilePosition, - ) -> Cancelable, hir::Function)>> { + ) -> Cancelable> { let syntax = source_file.syntax(); if let Some(binding) = find_node_at_offset::(syntax, position.offset) { let descr = ctry!(source_binder::function_from_child_node( @@ -281,7 +279,7 @@ impl db::RootDatabase { if symbol.ptr.kind() == FN_DEF { let fn_file = self.source_file(symbol.file_id); let fn_def = symbol.ptr.resolve(&fn_file); - let fn_def = ast::FnDef::cast(fn_def.borrowed()).unwrap(); + let fn_def = ast::FnDef::cast(&fn_def).unwrap(); let descr = ctry!(source_binder::function_from_source( self, symbol.file_id, @@ -352,7 +350,7 @@ impl db::RootDatabase { .collect::>(); Ok(res) } - pub(crate) fn index_resolve(&self, name_ref: ast::NameRef) -> Cancelable> { + pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Cancelable> { let name = name_ref.text(); let mut query = Query::new(name.to_string()); query.exact(); @@ -379,12 +377,12 @@ impl SourceChange { } enum FnCallNode<'a> { - CallExpr(ast::CallExpr<'a>), - MethodCallExpr(ast::MethodCallExpr<'a>), + CallExpr(&'a ast::CallExpr), + MethodCallExpr(&'a ast::MethodCallExpr), } impl<'a> FnCallNode<'a> { - pub fn with_node(syntax: SyntaxNodeRef, offset: TextUnit) -> Option { + pub fn with_node(syntax: &'a SyntaxNode, offset: TextUnit) -> Option> { if let Some(expr) = find_node_at_offset::(syntax, offset) { return Some(FnCallNode::CallExpr(expr)); } @@ -394,10 +392,10 @@ impl<'a> FnCallNode<'a> { None } - pub fn name_ref(&self) -> Option { + pub fn name_ref(&self) -> Option<&'a ast::NameRef> { match *self { - FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()? { - Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, + FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()?.kind() { + ast::ExprKind::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, _ => return None, }), @@ -409,7 +407,7 @@ impl<'a> FnCallNode<'a> { } } - pub fn arg_list(&self) -> Option { + pub fn arg_list(&self) -> Option<&'a ast::ArgList> { match *self { FnCallNode::CallExpr(expr) => expr.arg_list(), FnCallNode::MethodCallExpr(expr) => expr.arg_list(), -- cgit v1.2.3