diff options
Diffstat (limited to 'crates/ide/src/syntax_highlighting/highlight.rs')
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index b0cfdd8b7..26118929b 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Computes color for a single element. | 1 | //! Computes color for a single element. |
2 | 2 | ||
3 | use hir::{AsAssocItem, Semantics, VariantDef}; | 3 | use hir::{AsAssocItem, AssocItemContainer, Semantics, VariantDef}; |
4 | use ide_db::{ | 4 | use ide_db::{ |
5 | defs::{Definition, NameClass, NameRefClass}, | 5 | defs::{Definition, NameClass, NameRefClass}, |
6 | RootDatabase, SymbolKind, | 6 | RootDatabase, SymbolKind, |
@@ -275,6 +275,19 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
275 | hir::ModuleDef::Module(_) => HlTag::Symbol(SymbolKind::Module), | 275 | hir::ModuleDef::Module(_) => HlTag::Symbol(SymbolKind::Module), |
276 | hir::ModuleDef::Function(func) => { | 276 | hir::ModuleDef::Function(func) => { |
277 | let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Function)); | 277 | let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Function)); |
278 | if let Some(item) = func.as_assoc_item(db) { | ||
279 | match item.container(db) { | ||
280 | AssocItemContainer::Impl(i) => { | ||
281 | if i.target_trait(db).is_some() { | ||
282 | h |= HlMod::Trait; | ||
283 | } | ||
284 | } | ||
285 | AssocItemContainer::Trait(_t) => { | ||
286 | h |= HlMod::Trait; | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
278 | if func.as_assoc_item(db).is_some() { | 291 | if func.as_assoc_item(db).is_some() { |
279 | h |= HlMod::Associated; | 292 | h |= HlMod::Associated; |
280 | if func.self_param(db).is_none() { | 293 | if func.self_param(db).is_none() { |
@@ -362,6 +375,10 @@ fn highlight_method_call( | |||
362 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { | 375 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { |
363 | h |= HlMod::Unsafe; | 376 | h |= HlMod::Unsafe; |
364 | } | 377 | } |
378 | if let Some(_t) = func.as_assoc_item(sema.db)?.containing_trait(sema.db) { | ||
379 | h |= HlMod::Trait | ||
380 | } | ||
381 | |||
365 | if let Some(self_param) = func.self_param(sema.db) { | 382 | if let Some(self_param) = func.self_param(sema.db) { |
366 | match self_param.access(sema.db) { | 383 | match self_param.access(sema.db) { |
367 | hir::Access::Shared => (), | 384 | hir::Access::Shared => (), |