mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Highlight the name in macro declarations
This commit is contained in:
parent
11c0a5bb60
commit
22b75c4cea
3 changed files with 18 additions and 3 deletions
|
@ -27,13 +27,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
.keyword.unsafe { color: #BC8383; font-weight: bold; }
|
||||
.control { font-style: italic; }
|
||||
</style>
|
||||
<pre><code><span class="macro">macro_rules!</span> println {
|
||||
<pre><code><span class="macro">macro_rules!</span> <span class="macro declaration">println</span> {
|
||||
($($arg:tt)*) => ({
|
||||
$<span class="keyword">crate</span>::io::_print($<span class="keyword">crate</span>::format_args_nl!($($arg)*));
|
||||
})
|
||||
}
|
||||
#[rustc_builtin_macro]
|
||||
<span class="macro">macro_rules!</span> format_args_nl {
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">format_args_nl</span> {
|
||||
($fmt:expr) => {{ <span class="comment">/* compiler built-in */</span> }};
|
||||
($fmt:expr, $($args:tt)*) => {{ <span class="comment">/* compiler built-in */</span> }};
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
<span class="keyword">pub</span> <span class="field declaration">y</span>: <span class="builtin_type">i32</span>,
|
||||
}
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span>: <span class="builtin_type">i32</span> = <span class="numeric_literal">0</span>;
|
||||
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span><<span class="lifetime declaration">'a</span>, <span class="type_param declaration">T</span>>() -> <span class="type_param">T</span> {
|
||||
<span class="function">foo</span>::<<span class="lifetime">'a</span>, <span class="builtin_type">i32</span>>()
|
||||
}
|
||||
|
||||
<span class="macro">macro_rules!</span> def_fn {
|
||||
<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> {
|
||||
($($tt:tt)*) => {$($tt)*}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,19 @@ pub(crate) fn highlight(
|
|||
binding_hash: None,
|
||||
});
|
||||
}
|
||||
if let Some(name) = mc.is_macro_rules() {
|
||||
if let Some((highlight, binding_hash)) = highlight_element(
|
||||
&sema,
|
||||
&mut bindings_shadow_count,
|
||||
name.syntax().clone().into(),
|
||||
) {
|
||||
stack.add(HighlightedRange {
|
||||
range: name.syntax().text_range(),
|
||||
highlight,
|
||||
binding_hash,
|
||||
});
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
WalkEvent::Leave(Some(mc)) => {
|
||||
|
|
Loading…
Reference in a new issue