aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/algo/visit.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-18 17:23:05 +0100
committerAleksey Kladov <[email protected]>2019-07-19 11:16:24 +0100
commitd402974aa0af6de290245a9d2a69a5d56c4fa610 (patch)
treedf4a0e38e548f9f74592e00a2c5a7d37bab3c4c2 /crates/ra_syntax/src/algo/visit.rs
parent58d4983ba5745975446d60f2886d96f8d2adf0f2 (diff)
migrate ra_syntax to the new rowan API
Diffstat (limited to 'crates/ra_syntax/src/algo/visit.rs')
-rw-r--r--crates/ra_syntax/src/algo/visit.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/algo/visit.rs b/crates/ra_syntax/src/algo/visit.rs
index 81a99228f..87bd15cc0 100644
--- a/crates/ra_syntax/src/algo/visit.rs
+++ b/crates/ra_syntax/src/algo/visit.rs
@@ -16,7 +16,7 @@ pub trait Visitor<'a>: Sized {
16 fn visit<N, F>(self, f: F) -> Vis<Self, N, F> 16 fn visit<N, F>(self, f: F) -> Vis<Self, N, F>
17 where 17 where
18 N: AstNode + 'a, 18 N: AstNode + 'a,
19 F: FnOnce(&'a N) -> Self::Output, 19 F: FnOnce(N) -> Self::Output,
20 { 20 {
21 Vis { inner: self, f, ph: PhantomData } 21 Vis { inner: self, f, ph: PhantomData }
22 } 22 }
@@ -29,7 +29,7 @@ pub trait VisitorCtx<'a>: Sized {
29 fn visit<N, F>(self, f: F) -> VisCtx<Self, N, F> 29 fn visit<N, F>(self, f: F) -> VisCtx<Self, N, F>
30 where 30 where
31 N: AstNode + 'a, 31 N: AstNode + 'a,
32 F: FnOnce(&'a N, Self::Ctx) -> Self::Output, 32 F: FnOnce(N, Self::Ctx) -> Self::Output,
33 { 33 {
34 VisCtx { inner: self, f, ph: PhantomData } 34 VisCtx { inner: self, f, ph: PhantomData }
35 } 35 }
@@ -74,13 +74,13 @@ impl<'a, V, N, F> Visitor<'a> for Vis<V, N, F>
74where 74where
75 V: Visitor<'a>, 75 V: Visitor<'a>,
76 N: AstNode + 'a, 76 N: AstNode + 'a,
77 F: FnOnce(&'a N) -> <V as Visitor<'a>>::Output, 77 F: FnOnce(N) -> <V as Visitor<'a>>::Output,
78{ 78{
79 type Output = <V as Visitor<'a>>::Output; 79 type Output = <V as Visitor<'a>>::Output;
80 80
81 fn accept(self, node: &'a SyntaxNode) -> Option<Self::Output> { 81 fn accept(self, node: &'a SyntaxNode) -> Option<Self::Output> {
82 let Vis { inner, f, .. } = self; 82 let Vis { inner, f, .. } = self;
83 inner.accept(node).or_else(|| N::cast(node).map(f)) 83 inner.accept(node).or_else(|| N::cast(node.clone()).map(f))
84 } 84 }
85} 85}
86 86
@@ -95,14 +95,14 @@ impl<'a, V, N, F> VisitorCtx<'a> for VisCtx<V, N, F>
95where 95where
96 V: VisitorCtx<'a>, 96 V: VisitorCtx<'a>,
97 N: AstNode + 'a, 97 N: AstNode + 'a,
98 F: FnOnce(&'a N, <V as VisitorCtx<'a>>::Ctx) -> <V as VisitorCtx<'a>>::Output, 98 F: FnOnce(N, <V as VisitorCtx<'a>>::Ctx) -> <V as VisitorCtx<'a>>::Output,
99{ 99{
100 type Output = <V as VisitorCtx<'a>>::Output; 100 type Output = <V as VisitorCtx<'a>>::Output;
101 type Ctx = <V as VisitorCtx<'a>>::Ctx; 101 type Ctx = <V as VisitorCtx<'a>>::Ctx;
102 102
103 fn accept(self, node: &'a SyntaxNode) -> Result<Self::Output, Self::Ctx> { 103 fn accept(self, node: &'a SyntaxNode) -> Result<Self::Output, Self::Ctx> {
104 let VisCtx { inner, f, .. } = self; 104 let VisCtx { inner, f, .. } = self;
105 inner.accept(node).or_else(|ctx| match N::cast(node) { 105 inner.accept(node).or_else(|ctx| match N::cast(node.clone()) {
106 None => Err(ctx), 106 None => Err(ctx),
107 Some(node) => Ok(f(node, ctx)), 107 Some(node) => Ok(f(node, ctx)),
108 }) 108 })