aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-19 14:10:10 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-19 14:10:10 +0100
commit8718a47088585bdb411f37d1b7cd1244d7528eaa (patch)
tree254e13d1f0fb3072d02ba58f918de043a5cfcded /crates/ra_syntax
parentc0e36ab0c33a7c721c0919b4285e0b23e10ce9d5 (diff)
parentf9d9e0a1f75b48813fe816a1e2a6c30146a36503 (diff)
Merge #1551
1551: several highlighting cleanups r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-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 {