From 7ae98626fc5f0ecb7fc26aeb2aee40e700a1329d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 10 Mar 2025 06:47:02 +0100 Subject: [PATCH] Add missing name-ref parents to syntactic highlighting --- crates/ide/src/syntax_highlighting/highlight.rs | 3 +++ .../syntax_highlighting/test_data/highlight_doctest.html | 9 ++++----- crates/ide/src/syntax_highlighting/tests.rs | 9 ++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 282fbb4433b2..2b7c871a386d 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -824,6 +824,7 @@ fn highlight_name_ref_by_syntax( h.into() } } + RECORD_EXPR_FIELD | RECORD_PAT_FIELD => HlTag::Symbol(SymbolKind::Field).into(), PATH_SEGMENT => { let name_based_fallback = || { if name.text().chars().next().unwrap_or_default().is_uppercase() { @@ -862,6 +863,8 @@ fn highlight_name_ref_by_syntax( .into(), } } + ASSOC_TYPE_ARG => SymbolKind::TypeAlias.into(), + USE_BOUND_GENERIC_ARG => SymbolKind::TypeParam.into(), _ => default.into(), } } diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html index c8c8c5dba4c4..d00f279c8299 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html @@ -45,14 +45,13 @@ //! fn test() {} //! ``` +//! Syntactic name ref highlighting testing //! ```rust //! extern crate self; -//! extern crate std; +//! extern crate other as otter; //! extern crate core; -//! extern crate alloc; -//! extern crate proc_macro; -//! extern crate test; -//! extern crate Krate; +//! trait T { type Assoc; } +//! fn f<Arg>() -> use<Arg> where (): T<Assoc = ()> {} //! ``` mod outline_module; diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 8f69bb823000..9e8af4bac227 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -739,14 +739,13 @@ fn test_highlight_doc_comment() { //! fn test() {} //! ``` +//! Syntactic name ref highlighting testing //! ```rust //! extern crate self; -//! extern crate std; +//! extern crate other as otter; //! extern crate core; -//! extern crate alloc; -//! extern crate proc_macro; -//! extern crate test; -//! extern crate Krate; +//! trait T { type Assoc; } +//! fn f() -> use where (): T {} //! ``` mod outline_module;