Unnamed repository; edit this file 'description' to name the repository.
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 c6e11b9cbd..d580b3001c 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -703,7 +703,24 @@ fn highlight_name_ref_by_syntax( }; match parent.kind() { - EXTERN_CRATE => HlTag::Symbol(SymbolKind::Module).into(), + EXTERN_CRATE => { + let mut h: Highlight = HlTag::Symbol(SymbolKind::Module).into(); + let is_crate_root = if let Some(extern_crate) = ast::ExternCrate::cast(parent.clone()) { + if let Some(first_segment) = extern_crate.name_ref() { + first_segment.syntax().text() == name.syntax().text() + } else { + false + } + } else { + false + }; + + if is_crate_root { + h |= HlMod::CrateRoot; + } + + h | HlMod::Library + }, METHOD_CALL_EXPR => ast::MethodCallExpr::cast(parent) .and_then(|it| highlight_method_call(sema, krate, &it, edition)) .unwrap_or_else(|| SymbolKind::Method.into()), |