Add Static and Const highlighting token types

This commit is contained in:
Lukas Wirth 2024-04-15 16:54:17 +02:00
parent 91659da5a6
commit 6b98e55dbb
6 changed files with 107 additions and 95 deletions

View file

@ -444,7 +444,6 @@ pub(super) fn highlight_def(
Definition::Variant(_) => Highlight::new(HlTag::Symbol(SymbolKind::Variant)),
Definition::Const(konst) => {
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Const)) | HlMod::Const;
if let Some(item) = konst.as_assoc_item(db) {
h |= HlMod::Associated;
h |= HlMod::Static;

View file

@ -77,6 +77,7 @@ pub enum HlMod {
Library,
/// Used to differentiate individual elements within macro calls.
Macro,
/// Used to differentiate individual elements within proc-macro calls.
ProcMacro,
/// Mutable binding.
Mutable,
@ -262,6 +263,7 @@ impl HlMod {
}
fn mask(self) -> u32 {
debug_assert!(Self::ALL.len() <= 32, "HlMod::mask is not enough to cover all variants");
1 << (self as u32)
}
}

View file

@ -218,7 +218,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
<span class="bool_literal">true</span>
<span class="brace">}</span>
<span class="brace">}</span>
<span class="keyword const">const</span> <span class="constant const declaration">USAGE_OF_BOOL</span><span class="colon">:</span><span class="builtin_type">bool</span> <span class="operator">=</span> <span class="enum public">Bool</span><span class="operator">::</span><span class="enum_variant public">True</span><span class="operator">.</span><span class="method consuming public">to_primitive</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
<span class="keyword const">const</span> <span class="constant const declaration">USAGE_OF_BOOL</span><span class="colon">:</span> <span class="builtin_type">bool</span> <span class="operator">=</span> <span class="enum public">Bool</span><span class="operator">::</span><span class="enum_variant public">True</span><span class="operator">.</span><span class="method consuming public">to_primitive</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
<span class="keyword">trait</span> <span class="trait declaration">Baz</span> <span class="brace">{</span>
<span class="keyword">type</span> <span class="type_alias associated declaration static trait">Qux</span><span class="semicolon">;</span>

View file

@ -300,7 +300,7 @@ impl Bool {
true
}
}
const USAGE_OF_BOOL:bool = Bool::True.to_primitive();
const USAGE_OF_BOOL: bool = Bool::True.to_primitive();
trait Baz {
type Qux;