From 771c0d8c083e9c86a309a4380039602817e09fc8 Mon Sep 17 00:00:00 2001 From: Anatol Liu Date: Wed, 4 Nov 2020 20:08:46 -0800 Subject: Add static semantic token modifier for associated functions with no &self refactor logic into code_model.rs --- crates/ide/src/syntax_highlighting.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index c28ff849a..3fcdb5e52 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -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; } -- cgit v1.2.3