mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
semantic highlighting: add reference hlmod
This commit is contained in:
parent
14f00adcb1
commit
2baef17bb1
15 changed files with 68 additions and 38 deletions
|
@ -375,11 +375,11 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
if let Some(item) = func.as_assoc_item(db) {
|
||||
h |= HlMod::Associated;
|
||||
match func.self_param(db) {
|
||||
Some(sp) => {
|
||||
if let hir::Access::Exclusive = sp.access(db) {
|
||||
h |= HlMod::Mutable;
|
||||
}
|
||||
}
|
||||
Some(sp) => match sp.access(db) {
|
||||
hir::Access::Exclusive => h |= HlMod::Mutable,
|
||||
hir::Access::Shared => h |= HlMod::Reference,
|
||||
_ => {}
|
||||
},
|
||||
None => h |= HlMod::Static,
|
||||
}
|
||||
|
||||
|
@ -460,6 +460,8 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
if s.is_mut(db) {
|
||||
h |= HlMod::Mutable;
|
||||
h |= HlMod::Unsafe;
|
||||
} else {
|
||||
h |= HlMod::Reference;
|
||||
}
|
||||
|
||||
h
|
||||
|
@ -491,6 +493,9 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
if ty.as_callable(db).is_some() || ty.impls_fnonce(db) {
|
||||
h |= HlMod::Callable;
|
||||
}
|
||||
if local.is_ref(db) || ty.is_reference() {
|
||||
h |= HlMod::Reference;
|
||||
}
|
||||
h
|
||||
}
|
||||
Definition::Label(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)),
|
||||
|
@ -549,7 +554,7 @@ fn highlight_method_call(
|
|||
|
||||
if let Some(self_param) = func.self_param(sema.db) {
|
||||
match self_param.access(sema.db) {
|
||||
hir::Access::Shared => (),
|
||||
hir::Access::Shared => h |= HlMod::Reference,
|
||||
hir::Access::Exclusive => h |= HlMod::Mutable,
|
||||
hir::Access::Owned => {
|
||||
if let Some(receiver_ty) =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue