Add static semantic token modifier for associated functions with no &self

refactor logic into code_model.rs
This commit is contained in:
Anatol Liu 2020-11-04 20:08:46 -08:00
parent 3baa526fb0
commit 771c0d8c08
2 changed files with 22 additions and 17 deletions

View file

@ -746,20 +746,8 @@ 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;
}
if func.is_associated(db) {
h |= HighlightModifier::Static;
}
return h;
}