mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Add static semantic token modifier for associated functions with no &self
This commit is contained in:
parent
678a29e938
commit
3baa526fb0
8 changed files with 110 additions and 2 deletions
|
|
@ -746,6 +746,21 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight {
|
|||
if func.is_unsafe(db) {
|
||||
h |= HighlightModifier::Unsafe;
|
||||
}
|
||||
if let None = func.self_param(db) {
|
||||
// if enclosing IMPL or TRAIT exists, this is a static method
|
||||
let fn_parent_kind = func
|
||||
.source(db)
|
||||
.value
|
||||
.syntax()
|
||||
.parent()
|
||||
.and_then(|s| s.parent())
|
||||
.and_then(|s| Some(s.kind()));
|
||||
if let Some(SyntaxKind::IMPL) = fn_parent_kind {
|
||||
h |= HighlightModifier::Static;
|
||||
} else if let Some(SyntaxKind::TRAIT) = fn_parent_kind {
|
||||
h |= HighlightModifier::Static;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue