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
This commit is contained in:
Aleksey Kladov
2019-07-19 15:53:16 +03:00
parent e418889996
commit f9d9e0a1f7
6 changed files with 92 additions and 68 deletions

View File

@@ -60,6 +60,17 @@ impl<N: AstNode> AstPtr<N> {
pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
self.raw
}
// FIXME: extend AstNode to do this safely
pub fn cast_checking_kind<U: AstNode>(
self,
cond: impl FnOnce(SyntaxKind) -> bool,
) -> Option<AstPtr<U>> {
if !cond(self.raw.kind()) {
return None;
}
Some(AstPtr { raw: self.raw, _ty: PhantomData })
}
}
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr {