aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-19 13:53:16 +0100
committerAleksey Kladov <[email protected]>2019-07-19 14:09:32 +0100
commitf9d9e0a1f75b48813fe816a1e2a6c30146a36503 (patch)
tree254e13d1f0fb3072d02ba58f918de043a5cfcded /crates/ra_syntax/src
parente4188899962774713707629d4e15255e3bc9c85e (diff)
several highlighting cleanups
* make stuff more type-safe by using `BindPat` instead of just `Pat` * don't add `mut` into binding hash * reset shadow counter when we enter a function
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ptr.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 016256075..25824722f 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -60,6 +60,17 @@ impl<N: AstNode> AstPtr<N> {
60 pub fn syntax_node_ptr(self) -> SyntaxNodePtr { 60 pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
61 self.raw 61 self.raw
62 } 62 }
63
64 // FIXME: extend AstNode to do this safely
65 pub fn cast_checking_kind<U: AstNode>(
66 self,
67 cond: impl FnOnce(SyntaxKind) -> bool,
68 ) -> Option<AstPtr<U>> {
69 if !cond(self.raw.kind()) {
70 return None;
71 }
72 Some(AstPtr { raw: self.raw, _ty: PhantomData })
73 }
63} 74}
64 75
65impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr { 76impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr {