diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-19 14:10:10 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-19 14:10:10 +0100 |
commit | 8718a47088585bdb411f37d1b7cd1244d7528eaa (patch) | |
tree | 254e13d1f0fb3072d02ba58f918de043a5cfcded /crates/ra_syntax/src | |
parent | c0e36ab0c33a7c721c0919b4285e0b23e10ce9d5 (diff) | |
parent | f9d9e0a1f75b48813fe816a1e2a6c30146a36503 (diff) |
Merge #1551
1551: several highlighting cleanups r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ptr.rs | 11 |
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 | ||
65 | impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr { | 76 | impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr { |