diff options
Diffstat (limited to 'crates/ide/src/syntax_highlighting/highlight.rs')
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 26118929b..e218b3dc8 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs | |||
@@ -276,6 +276,11 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
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) { | 278 | if let Some(item) = func.as_assoc_item(db) { |
279 | h |= HlMod::Associated; | ||
280 | if func.self_param(db).is_none() { | ||
281 | h |= HlMod::Static | ||
282 | } | ||
283 | |||
279 | match item.container(db) { | 284 | match item.container(db) { |
280 | AssocItemContainer::Impl(i) => { | 285 | AssocItemContainer::Impl(i) => { |
281 | if i.target_trait(db).is_some() { | 286 | if i.target_trait(db).is_some() { |
@@ -288,12 +293,6 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
288 | } | 293 | } |
289 | } | 294 | } |
290 | 295 | ||
291 | if func.as_assoc_item(db).is_some() { | ||
292 | h |= HlMod::Associated; | ||
293 | if func.self_param(db).is_none() { | ||
294 | h |= HlMod::Static | ||
295 | } | ||
296 | } | ||
297 | if func.is_unsafe(db) { | 296 | if func.is_unsafe(db) { |
298 | h |= HlMod::Unsafe; | 297 | h |= HlMod::Unsafe; |
299 | } | 298 | } |
@@ -305,9 +304,20 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight { | |||
305 | hir::ModuleDef::Variant(_) => HlTag::Symbol(SymbolKind::Variant), | 304 | hir::ModuleDef::Variant(_) => HlTag::Symbol(SymbolKind::Variant), |
306 | hir::ModuleDef::Const(konst) => { | 305 | hir::ModuleDef::Const(konst) => { |
307 | let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Const)); | 306 | let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Const)); |
308 | if konst.as_assoc_item(db).is_some() { | 307 | if let Some(item) = konst.as_assoc_item(db) { |
309 | h |= HlMod::Associated | 308 | h |= HlMod::Associated; |
309 | match item.container(db) { | ||
310 | AssocItemContainer::Impl(i) => { | ||
311 | if i.target_trait(db).is_some() { | ||
312 | h |= HlMod::Trait; | ||
313 | } | ||
314 | } | ||
315 | AssocItemContainer::Trait(_t) => { | ||
316 | h |= HlMod::Trait; | ||
317 | } | ||
318 | } | ||
310 | } | 319 | } |
320 | |||
311 | return h; | 321 | return h; |
312 | } | 322 | } |
313 | hir::ModuleDef::Trait(_) => HlTag::Symbol(SymbolKind::Trait), | 323 | hir::ModuleDef::Trait(_) => HlTag::Symbol(SymbolKind::Trait), |
@@ -375,7 +385,7 @@ fn highlight_method_call( | |||
375 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { | 385 | if func.is_unsafe(sema.db) || sema.is_unsafe_method_call(&method_call) { |
376 | h |= HlMod::Unsafe; | 386 | h |= HlMod::Unsafe; |
377 | } | 387 | } |
378 | if let Some(_t) = func.as_assoc_item(sema.db)?.containing_trait(sema.db) { | 388 | if func.as_assoc_item(sema.db).and_then(|it| it.containing_trait(sema.db)).is_some() { |
379 | h |= HlMod::Trait | 389 | h |= HlMod::Trait |
380 | } | 390 | } |
381 | 391 | ||