From 90031a267a2ea510cede2ab5c3164bb8605a69ac Mon Sep 17 00:00:00 2001 From: Anatol Liu Date: Wed, 4 Nov 2020 20:08:46 -0800 Subject: [PATCH] Add static semantic token modifier for associated functions with no &self refactor logic into code_model.rs address comments --- crates/hir/src/code_model.rs | 6 +----- crates/ide/src/syntax_highlighting.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 3277597c660..fadd010e2a7 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -789,11 +789,7 @@ pub fn has_body(self, db: &dyn HirDatabase) -> bool { } /// whether this function is associated with some trait/impl - pub fn is_associated(self, db: &dyn HirDatabase) -> bool { - if self.self_param(db).is_some() { - return false; - } - + pub fn is_assoc_item(self, db: &dyn HirDatabase) -> bool { let fn_parent_kind = self .source(db) .value diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 3fcdb5e52f1..41fd36edf8f 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -746,7 +746,7 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { if func.is_unsafe(db) { h |= HighlightModifier::Unsafe; } - if func.is_associated(db) { + if func.is_assoc_item(db) && func.self_param(db).is_none() { h |= HighlightModifier::Static; } return h;