From 72f013b3b9ba48d3e850cba84e91c37fbe52cc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 4 Dec 2020 18:27:10 +0200 Subject: Use METHOD semantic token type --- crates/ide/src/syntax_highlighting.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'crates/ide/src/syntax_highlighting.rs') diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 5150a970c..f5c6eabef 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -726,7 +726,7 @@ fn highlight_method_call( method_call: &ast::MethodCallExpr, ) -> Option { let func = sema.resolve_method_call(&method_call)?; - let mut h = HighlightTag::Function.into(); + let mut h = HighlightTag::Method.into(); if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { h |= HighlightModifier::Unsafe; } @@ -755,13 +755,18 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { Definition::ModuleDef(def) => match def { hir::ModuleDef::Module(_) => HighlightTag::Module, hir::ModuleDef::Function(func) => { - let mut h = HighlightTag::Function.into(); + let mut h = if func.as_assoc_item(db).is_some() { + if func.self_param(db).is_none() { + Highlight::from(HighlightTag::Method) | HighlightModifier::Static + } else { + HighlightTag::Method.into() + } + } else { + HighlightTag::Function.into() + }; if func.is_unsafe(db) { h |= HighlightModifier::Unsafe; } - if func.as_assoc_item(db).is_some() && func.self_param(db).is_none() { - h |= HighlightModifier::Static; - } return h; } hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, -- cgit v1.2.3