aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorAnatol Liu <[email protected]>2020-11-05 04:08:46 +0000
committerAnatol Liu <[email protected]>2020-11-05 05:55:44 +0000
commit771c0d8c083e9c86a309a4380039602817e09fc8 (patch)
tree59d966962cee08a8194706e3d20d8d19ddee6265 /crates/ide/src
parent3baa526fb07184ce9804a06c8e0251971eea3b49 (diff)
Add static semantic token modifier for associated functions with no &self
refactor logic into code_model.rs
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/syntax_highlighting.rs16
1 files changed, 2 insertions, 14 deletions
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 {
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) { 749 if func.is_associated(db) {
750 // if enclosing IMPL or TRAIT exists, this is a static method 750 h |= HighlightModifier::Static;
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 } 751 }
764 return h; 752 return h;
765 } 753 }