From d91a98ec843ec8562c58ccb01a1e29d00cc744dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 7 Jan 2019 16:15:47 +0300 Subject: switch ra_syntax to new rowan API --- crates/ra_syntax/src/algo/visit.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'crates/ra_syntax/src/algo') diff --git a/crates/ra_syntax/src/algo/visit.rs b/crates/ra_syntax/src/algo/visit.rs index c021f464c..38f21594c 100644 --- a/crates/ra_syntax/src/algo/visit.rs +++ b/crates/ra_syntax/src/algo/visit.rs @@ -1,4 +1,4 @@ -use crate::{AstNode, SyntaxNodeRef}; +use crate::{AstNode, SyntaxNode}; use std::marker::PhantomData; @@ -15,11 +15,11 @@ pub fn visitor_ctx<'a, T, C>(ctx: C) -> impl VisitorCtx<'a, Output = T, Ctx = C> pub trait Visitor<'a>: Sized { type Output; - fn accept(self, node: SyntaxNodeRef<'a>) -> Option; + fn accept(self, node: &'a SyntaxNode) -> Option; fn visit(self, f: F) -> Vis where - N: AstNode<'a>, - F: FnOnce(N) -> Self::Output, + N: AstNode + 'a, + F: FnOnce(&'a N) -> Self::Output, { Vis { inner: self, @@ -32,11 +32,11 @@ pub trait Visitor<'a>: Sized { pub trait VisitorCtx<'a>: Sized { type Output; type Ctx; - fn accept(self, node: SyntaxNodeRef<'a>) -> Result; + fn accept(self, node: &'a SyntaxNode) -> Result; fn visit(self, f: F) -> VisCtx where - N: AstNode<'a>, - F: FnOnce(N, Self::Ctx) -> Self::Output, + N: AstNode + 'a, + F: FnOnce(&'a N, Self::Ctx) -> Self::Output, { VisCtx { inner: self, @@ -54,7 +54,7 @@ struct EmptyVisitor { impl<'a, T> Visitor<'a> for EmptyVisitor { type Output = T; - fn accept(self, _node: SyntaxNodeRef<'a>) -> Option { + fn accept(self, _node: &'a SyntaxNode) -> Option { None } } @@ -69,7 +69,7 @@ impl<'a, T, C> VisitorCtx<'a> for EmptyVisitorCtx { type Output = T; type Ctx = C; - fn accept(self, _node: SyntaxNodeRef<'a>) -> Result { + fn accept(self, _node: &'a SyntaxNode) -> Result { Err(self.ctx) } } @@ -84,12 +84,12 @@ pub struct Vis { impl<'a, V, N, F> Visitor<'a> for Vis where V: Visitor<'a>, - N: AstNode<'a>, - F: FnOnce(N) -> >::Output, + N: AstNode + 'a, + F: FnOnce(&'a N) -> >::Output, { type Output = >::Output; - fn accept(self, node: SyntaxNodeRef<'a>) -> Option { + fn accept(self, node: &'a SyntaxNode) -> Option { let Vis { inner, f, .. } = self; inner.accept(node).or_else(|| N::cast(node).map(f)) } @@ -105,13 +105,13 @@ pub struct VisCtx { impl<'a, V, N, F> VisitorCtx<'a> for VisCtx where V: VisitorCtx<'a>, - N: AstNode<'a>, - F: FnOnce(N, >::Ctx) -> >::Output, + N: AstNode + 'a, + F: FnOnce(&'a N, >::Ctx) -> >::Output, { type Output = >::Output; type Ctx = >::Ctx; - fn accept(self, node: SyntaxNodeRef<'a>) -> Result { + fn accept(self, node: &'a SyntaxNode) -> Result { let VisCtx { inner, f, .. } = self; inner.accept(node).or_else(|ctx| match N::cast(node) { None => Err(ctx), -- cgit v1.2.3