aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/syntax_highlighting/highlight.rs
diff options
context:
space:
mode:
authorChetan Khilosiya <[email protected]>2021-03-29 18:27:05 +0100
committerChetan Khilosiya <[email protected]>2021-03-30 20:01:15 +0100
commitf269fe71569984dea7738926d164f284552196ed (patch)
tree994fb62cf27c4c65ba841074664f9516ad780565 /crates/ide/src/syntax_highlighting/highlight.rs
parentfd7c454d516e3af90d8c0d0d8a22655345fec2d7 (diff)
8024: Added the trait modifier for methods
method in impls and method calls will have trait modifier.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/highlight.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs19
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
3use hir::{AsAssocItem, Semantics, VariantDef}; 3use hir::{AsAssocItem, AssocItemContainer, Semantics, VariantDef};
4use ide_db::{ 4use 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 => (),