aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting.rs
diff options
context:
space:
mode:
authorAnatol Liu <[email protected]>2020-11-05 04:08:46 +0000
committerAnatol Liu <[email protected]>2020-11-05 04:08:46 +0000
commit3baa526fb07184ce9804a06c8e0251971eea3b49 (patch)
treef895bdab50f6a839b30da4a4acb7d11a79e83ac3 /crates/ide/src/syntax_highlighting.rs
parent678a29e938f5833ecbf5a50eee0e29c5d99b56c4 (diff)
Add static semantic token modifier for associated functions with no &self
Diffstat (limited to 'crates/ide/src/syntax_highlighting.rs')
-rw-r--r--crates/ide/src/syntax_highlighting.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index efcc8ecfe..c28ff849a 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -746,6 +746,21 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight {
746 if func.is_unsafe(db) { 746 if func.is_unsafe(db) {
747 h |= HighlightModifier::Unsafe; 747 h |= HighlightModifier::Unsafe;
748 } 748 }
749 if let None = func.self_param(db) {
750 // if enclosing IMPL or TRAIT exists, this is a static method
751 let fn_parent_kind = func
752 .source(db)
753 .value
754 .syntax()
755 .parent()
756 .and_then(|s| s.parent())
757 .and_then(|s| Some(s.kind()));
758 if let Some(SyntaxKind::IMPL) = fn_parent_kind {
759 h |= HighlightModifier::Static;
760 } else if let Some(SyntaxKind::TRAIT) = fn_parent_kind {
761 h |= HighlightModifier::Static;
762 }
763 }
749 return h; 764 return h;
750 } 765 }
751 hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, 766 hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct,