diff options
Diffstat (limited to 'crates/ide/src/syntax_highlighting/highlight.rs')
-rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 6834fe11a..82e16a51b 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}; | 3 | use hir::{AsAssocItem, HasVisibility, Semantics}; |
4 | use ide_db::{ | 4 | use ide_db::{ |
5 | defs::{Definition, NameClass, NameRefClass}, | 5 | defs::{Definition, NameClass, NameRefClass}, |
6 | RootDatabase, SymbolKind, | 6 | RootDatabase, SymbolKind, |
@@ -439,9 +439,12 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition) | |||
439 | 439 | ||
440 | let is_from_other_crate = def.module(db).map(hir::Module::krate) != krate; | 440 | let is_from_other_crate = def.module(db).map(hir::Module::krate) != krate; |
441 | let is_builtin_type = matches!(def, Definition::ModuleDef(hir::ModuleDef::BuiltinType(_))); | 441 | let is_builtin_type = matches!(def, Definition::ModuleDef(hir::ModuleDef::BuiltinType(_))); |
442 | let is_public = def.visibility(db) == Some(hir::Visibility::Public); | ||
442 | 443 | ||
443 | if is_from_other_crate && !is_builtin_type { | 444 | match (is_from_other_crate, is_builtin_type, is_public) { |
444 | h |= HlMod::Library; | 445 | (true, false, _) => h |= HlMod::Library, |
446 | (false, _, true) => h |= HlMod::Public, | ||
447 | _ => {} | ||
445 | } | 448 | } |
446 | 449 | ||
447 | h | 450 | h |
@@ -475,8 +478,14 @@ fn highlight_method_call( | |||
475 | if func.as_assoc_item(sema.db).and_then(|it| it.containing_trait(sema.db)).is_some() { | 478 | if func.as_assoc_item(sema.db).and_then(|it| it.containing_trait(sema.db)).is_some() { |
476 | h |= HlMod::Trait; | 479 | h |= HlMod::Trait; |
477 | } | 480 | } |
478 | if Some(func.module(sema.db).krate()) != krate { | 481 | |
482 | let is_from_other_crate = Some(func.module(sema.db).krate()) != krate; | ||
483 | let is_public = func.visibility(sema.db) == hir::Visibility::Public; | ||
484 | |||
485 | if is_from_other_crate { | ||
479 | h |= HlMod::Library; | 486 | h |= HlMod::Library; |
487 | } else if is_public { | ||
488 | h |= HlMod::Public; | ||
480 | } | 489 | } |
481 | 490 | ||
482 | if let Some(self_param) = func.self_param(sema.db) { | 491 | if let Some(self_param) = func.self_param(sema.db) { |