semantic highlighting: add reference hlmod

This commit is contained in:
Jake Heinz 2021-07-31 04:42:47 +00:00
parent 14f00adcb1
commit 2baef17bb1
15 changed files with 68 additions and 38 deletions

View file

@ -1840,6 +1840,11 @@ impl Local {
matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. })
}
pub fn is_ref(self, db: &dyn HirDatabase) -> bool {
let body = db.body(self.parent);
matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Ref, .. })
}
pub fn parent(self, _db: &dyn HirDatabase) -> DefWithBody {
self.parent.into()
}
@ -2195,6 +2200,10 @@ impl Type {
matches!(self.ty.kind(&Interner), TyKind::Ref(hir_ty::Mutability::Mut, ..))
}
pub fn is_reference(&self) -> bool {
matches!(self.ty.kind(&Interner), TyKind::Ref(hir_ty::Mutability::Not, ..))
}
pub fn is_usize(&self) -> bool {
matches!(self.ty.kind(&Interner), TyKind::Scalar(Scalar::Uint(UintTy::Usize)))
}