mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Remove syntax highlighting hack for builtin attrs
This commit is contained in:
parent
e58af219a4
commit
d1677f3286
@ -2028,7 +2028,7 @@ pub struct BuiltinAttr(usize);
|
||||
|
||||
impl BuiltinAttr {
|
||||
pub(crate) fn by_name(name: &str) -> Option<Self> {
|
||||
// TODO: def maps registered attrs?
|
||||
// FIXME: def maps registered attrs?
|
||||
hir_def::builtin_attr::find_builtin_attr_idx(name).map(Self)
|
||||
}
|
||||
}
|
||||
@ -2038,7 +2038,7 @@ pub struct Tool(usize);
|
||||
|
||||
impl Tool {
|
||||
pub(crate) fn by_name(name: &str) -> Option<Self> {
|
||||
// TODO: def maps registered tools
|
||||
// FIXME: def maps registered tools
|
||||
hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self)
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ pub struct HlRange {
|
||||
// parameter:: Emitted for non-self function parameters.
|
||||
// property:: Emitted for struct and union fields.
|
||||
// selfKeyword:: Emitted for the self function parameter and self path-specifier.
|
||||
// tool:: Emitted for tool modules.
|
||||
// typeParameter:: Emitted for type parameters.
|
||||
// unresolvedReference:: Emitted for unresolved references, names that rust-analyzer can't find the definition of.
|
||||
// variable:: Emitted for locals, constants and statics.
|
||||
|
@ -208,22 +208,14 @@ fn node(
|
||||
},
|
||||
// Highlight references like the definitions they resolve to
|
||||
ast::NameRef(name_ref) => {
|
||||
if node.ancestors().any(|it| it.kind() == ATTR) {
|
||||
|
||||
// FIXME: We highlight paths in attributes slightly differently to work around this module
|
||||
// currently not knowing about tool attributes and rustc builtin attributes as
|
||||
// we do not want to resolve those to functions that may be defined in scope.
|
||||
highlight_name_ref_in_attr(sema, name_ref)
|
||||
} else {
|
||||
highlight_name_ref(
|
||||
sema,
|
||||
krate,
|
||||
bindings_shadow_count,
|
||||
&mut binding_hash,
|
||||
syntactic_name_ref_highlighting,
|
||||
name_ref,
|
||||
)
|
||||
}
|
||||
highlight_name_ref(
|
||||
sema,
|
||||
krate,
|
||||
bindings_shadow_count,
|
||||
&mut binding_hash,
|
||||
syntactic_name_ref_highlighting,
|
||||
name_ref,
|
||||
)
|
||||
},
|
||||
ast::Lifetime(lifetime) => {
|
||||
match NameClass::classify_lifetime(sema, &lifetime) {
|
||||
@ -243,28 +235,6 @@ fn node(
|
||||
Some((highlight, binding_hash))
|
||||
}
|
||||
|
||||
fn highlight_name_ref_in_attr(sema: &Semantics<RootDatabase>, name_ref: ast::NameRef) -> Highlight {
|
||||
match NameRefClass::classify(sema, &name_ref) {
|
||||
Some(name_class) => match name_class {
|
||||
NameRefClass::Definition(Definition::Module(_))
|
||||
if name_ref
|
||||
.syntax()
|
||||
.ancestors()
|
||||
.find_map(ast::Path::cast)
|
||||
.map_or(false, |it| it.parent_path().is_some()) =>
|
||||
{
|
||||
HlTag::Symbol(SymbolKind::Module)
|
||||
}
|
||||
NameRefClass::Definition(Definition::Macro(m)) if m.kind() == hir::MacroKind::Attr => {
|
||||
HlTag::Symbol(SymbolKind::Macro)
|
||||
}
|
||||
_ => HlTag::BuiltinAttr,
|
||||
},
|
||||
None => HlTag::BuiltinAttr,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
fn highlight_name_ref(
|
||||
sema: &Semantics<RootDatabase>,
|
||||
krate: Option<hir::Crate>,
|
||||
@ -542,8 +512,8 @@ fn highlight_def(
|
||||
h
|
||||
}
|
||||
Definition::Label(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)),
|
||||
Definition::BuiltinAttr(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)), // FIXME
|
||||
Definition::Tool(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)), // FIXME
|
||||
Definition::BuiltinAttr(_) => Highlight::new(HlTag::Symbol(SymbolKind::BuiltinAttr)),
|
||||
Definition::Tool(_) => Highlight::new(HlTag::Symbol(SymbolKind::Tool)),
|
||||
};
|
||||
|
||||
let famous_defs = FamousDefs(sema, krate);
|
||||
|
@ -263,8 +263,8 @@ fn module_def_to_hl_tag(def: Definition) -> HlTag {
|
||||
hir::GenericParam::ConstParam(_) => SymbolKind::ConstParam,
|
||||
},
|
||||
Definition::Label(_) => SymbolKind::Label,
|
||||
Definition::BuiltinAttr(_) => SymbolKind::Label, // FIXME
|
||||
Definition::Tool(_) => SymbolKind::Label, // FIXME
|
||||
Definition::BuiltinAttr(_) => SymbolKind::BuiltinAttr,
|
||||
Definition::Tool(_) => SymbolKind::Tool,
|
||||
};
|
||||
HlTag::Symbol(symbol)
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ pub enum HlTag {
|
||||
|
||||
Attribute,
|
||||
BoolLiteral,
|
||||
BuiltinAttr,
|
||||
BuiltinType,
|
||||
ByteLiteral,
|
||||
CharLiteral,
|
||||
@ -125,30 +124,31 @@ impl HlTag {
|
||||
fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
HlTag::Symbol(symbol) => match symbol {
|
||||
SymbolKind::BuiltinAttr => "builtin_attr",
|
||||
SymbolKind::Const => "constant",
|
||||
SymbolKind::Static => "static",
|
||||
SymbolKind::ConstParam => "const_param",
|
||||
SymbolKind::Enum => "enum",
|
||||
SymbolKind::Variant => "enum_variant",
|
||||
SymbolKind::Struct => "struct",
|
||||
SymbolKind::Union => "union",
|
||||
SymbolKind::Field => "field",
|
||||
SymbolKind::Module => "module",
|
||||
SymbolKind::Trait => "trait",
|
||||
SymbolKind::Function => "function",
|
||||
SymbolKind::Impl => "self_type",
|
||||
SymbolKind::Label => "label",
|
||||
SymbolKind::LifetimeParam => "lifetime",
|
||||
SymbolKind::Local => "variable",
|
||||
SymbolKind::Macro => "macro",
|
||||
SymbolKind::Module => "module",
|
||||
SymbolKind::SelfParam => "self_keyword",
|
||||
SymbolKind::Static => "static",
|
||||
SymbolKind::Struct => "struct",
|
||||
SymbolKind::Tool => "tool",
|
||||
SymbolKind::Trait => "trait",
|
||||
SymbolKind::TypeAlias => "type_alias",
|
||||
SymbolKind::TypeParam => "type_param",
|
||||
SymbolKind::ConstParam => "const_param",
|
||||
SymbolKind::LifetimeParam => "lifetime",
|
||||
SymbolKind::Macro => "macro",
|
||||
SymbolKind::Local => "variable",
|
||||
SymbolKind::Label => "label",
|
||||
SymbolKind::Union => "union",
|
||||
SymbolKind::ValueParam => "value_param",
|
||||
SymbolKind::SelfParam => "self_keyword",
|
||||
SymbolKind::Impl => "self_type",
|
||||
SymbolKind::Variant => "enum_variant",
|
||||
},
|
||||
HlTag::Attribute => "attribute",
|
||||
HlTag::BoolLiteral => "bool_literal",
|
||||
HlTag::BuiltinAttr => "builtin_attr",
|
||||
HlTag::BuiltinType => "builtin_type",
|
||||
HlTag::ByteLiteral => "byte_literal",
|
||||
HlTag::CharLiteral => "char_literal",
|
||||
|
@ -72,7 +72,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="comment documentation">/// # Examples</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// #</span><span class="none injected"> </span><span class="attribute attribute injected">#</span><span class="attribute attribute injected">!</span><span class="attribute attribute injected">[</span><span class="builtin_attr attribute injected">allow</span><span class="parenthesis attribute injected">(</span><span class="none attribute injected">unused_mut</span><span class="parenthesis attribute injected">)</span><span class="attribute attribute injected">]</span>
|
||||
<span class="comment documentation">/// #</span><span class="none injected"> </span><span class="attribute attribute injected">#</span><span class="attribute attribute injected">!</span><span class="attribute attribute injected">[</span><span class="builtin_attr attribute injected library">allow</span><span class="parenthesis attribute injected">(</span><span class="none attribute injected">unused_mut</span><span class="parenthesis attribute injected">)</span><span class="attribute attribute injected">]</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="keyword injected">mut</span><span class="none injected"> </span><span class="variable declaration injected mutable">foo</span><span class="colon injected">:</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="struct injected">Foo</span><span class="operator injected">::</span><span class="function injected">new</span><span class="parenthesis injected">(</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function associated declaration public static">new</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="operator">-></span> <span class="struct">Foo</span> <span class="brace">{</span>
|
||||
@ -143,12 +143,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"false"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"false"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"</span><span class="keyword control injected">loop</span><span class="none injected"> </span><span class="brace injected">{</span><span class="brace injected">}</span><span class="string_literal attribute">"</span><span class="attribute attribute">]</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="comment documentation">///</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"alloc"</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"```rust"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"alloc"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"```ignore"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"alloc"</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"```rust"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">cfg_attr</span><span class="parenthesis attribute">(</span><span class="none attribute">not</span><span class="parenthesis attribute">(</span><span class="none attribute">feature</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"alloc"</span><span class="parenthesis attribute">)</span><span class="comma attribute">,</span><span class="attribute attribute"> </span><span class="none attribute">doc</span><span class="attribute attribute"> </span><span class="operator attribute">=</span><span class="attribute attribute"> </span><span class="string_literal attribute">"```ignore"</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="none injected"> </span><span class="punctuation injected">_</span><span class="none injected"> </span><span class="operator injected">=</span><span class="none injected"> </span><span class="function injected">example</span><span class="parenthesis injected">(</span><span class="operator injected">&</span><span class="none injected">alloc::</span><span class="macro injected">vec!</span><span class="bracket injected">[</span><span class="numeric_literal injected">1</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">2</span><span class="comma injected">,</span><span class="none injected"> </span><span class="numeric_literal injected">3</span><span class="bracket injected">]</span><span class="parenthesis injected">)</span><span class="semicolon injected">;</span>
|
||||
<span class="comment documentation">/// ```</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration public">mix_and_match</span><span class="parenthesis">(</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
@ -45,14 +45,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="punctuation">$</span>crate<span class="colon">:</span><span class="colon">:</span>io<span class="colon">:</span><span class="colon">:</span>_print<span class="parenthesis">(</span><span class="punctuation">$</span>crate<span class="colon">:</span><span class="colon">:</span>format_args_nl<span class="punctuation">!</span><span class="parenthesis">(</span><span class="punctuation">$</span><span class="parenthesis">(</span><span class="punctuation">$</span>arg<span class="parenthesis">)</span><span class="punctuation">*</span><span class="parenthesis">)</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||
<span class="brace">}</span><span class="parenthesis">)</span>
|
||||
<span class="brace">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">format_args</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">const_format_args</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">format_args_nl</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="keyword">mod</span> <span class="module declaration">panic</span> <span class="brace">{</span>
|
||||
@ -77,12 +77,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="brace">}</span>
|
||||
<span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="parenthesis attribute">(</span><span class="none attribute">std_panic</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="parenthesis attribute">(</span><span class="none attribute">std_panic</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">macro_export</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">panic</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">assert</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">rustc_builtin_macro</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">asm</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="keyword">macro_rules</span><span class="punctuation">!</span> <span class="macro declaration">toho</span> <span class="brace">{</span>
|
||||
|
@ -54,7 +54,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="keyword unsafe">unsafe</span> <span class="keyword">fn</span> <span class="function associated declaration reference unsafe">unsafe_method</span><span class="parenthesis">(</span><span class="operator">&</span><span class="self_keyword declaration reference">self</span><span class="parenthesis">)</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">repr</span><span class="parenthesis attribute">(</span><span class="none attribute">packed</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">repr</span><span class="parenthesis attribute">(</span><span class="none attribute">packed</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">Packed</span> <span class="brace">{</span>
|
||||
<span class="field declaration">a</span><span class="colon">:</span> <span class="builtin_type">u16</span><span class="comma">,</span>
|
||||
<span class="brace">}</span>
|
||||
|
@ -43,15 +43,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<pre><code><span class="keyword">use</span> <span class="module">inner</span><span class="operator">::</span><span class="brace">{</span><span class="self_keyword">self</span> <span class="keyword">as</span> <span class="module declaration">inner_mod</span><span class="brace">}</span><span class="semicolon">;</span>
|
||||
<span class="keyword">mod</span> <span class="module declaration">inner</span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="module attribute">proc_macros</span><span class="operator attribute">::</span><span class="macro attribute">identity</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="module attribute crate_root library">proc_macros</span><span class="operator attribute">::</span><span class="macro attribute library">identity</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">mod</span> <span class="module declaration public">ops</span> <span class="brace">{</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_once"</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_once"</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">FnOnce</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_mut"</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn_mut"</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">FnMut</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></span><span class="colon">:</span> <span class="trait public">FnOnce</span><span class="angle"><</span><span class="type_param">Args</span><span class="angle">></span> <span class="brace">{</span><span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn"</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="builtin_attr attribute library">lang</span> <span class="operator attribute">=</span> <span class="string_literal attribute">"fn"</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">pub</span> <span class="keyword">trait</span> <span class="trait declaration public">Fn</span><span class="angle"><</span><span class="type_param declaration">Args</span><span class="angle">></span><span class="colon">:</span> <span class="trait public">FnMut</span><span class="angle"><</span><span class="type_param">Args</span><span class="angle">></span> <span class="brace">{</span><span class="brace">}</span>
|
||||
<span class="brace">}</span>
|
||||
|
||||
@ -86,7 +86,7 @@ proc_macros::<span class="macro">mirror!</span> <span class="brace">{</span>
|
||||
<span class="brace">}</span>
|
||||
<span class="brace">}</span>
|
||||
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="macro attribute">derive</span><span class="parenthesis attribute">(</span><span class="macro attribute default_library library">Copy</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="attribute attribute">#</span><span class="attribute attribute">[</span><span class="macro attribute default_library library">derive</span><span class="parenthesis attribute">(</span><span class="macro attribute default_library library">Copy</span><span class="parenthesis attribute">)</span><span class="attribute attribute">]</span>
|
||||
<span class="keyword">struct</span> <span class="struct declaration">FooCopy</span> <span class="brace">{</span>
|
||||
<span class="field declaration">x</span><span class="colon">:</span> <span class="builtin_type">u32</span><span class="comma">,</span>
|
||||
<span class="brace">}</span>
|
||||
|
@ -232,6 +232,7 @@ impl CompletionItemKind {
|
||||
pub(crate) fn tag(&self) -> &'static str {
|
||||
match self {
|
||||
CompletionItemKind::SymbolKind(kind) => match kind {
|
||||
SymbolKind::BuiltinAttr => "ba",
|
||||
SymbolKind::Const => "ct",
|
||||
SymbolKind::ConstParam => "cp",
|
||||
SymbolKind::Enum => "en",
|
||||
@ -246,6 +247,7 @@ impl CompletionItemKind {
|
||||
SymbolKind::SelfParam => "sp",
|
||||
SymbolKind::Static => "sc",
|
||||
SymbolKind::Struct => "st",
|
||||
SymbolKind::Tool => "tl",
|
||||
SymbolKind::Trait => "tt",
|
||||
SymbolKind::TypeAlias => "ta",
|
||||
SymbolKind::TypeParam => "tp",
|
||||
|
@ -145,6 +145,7 @@ fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub enum SymbolKind {
|
||||
BuiltinAttr,
|
||||
Const,
|
||||
ConstParam,
|
||||
Enum,
|
||||
@ -159,6 +160,7 @@ pub enum SymbolKind {
|
||||
SelfParam,
|
||||
Static,
|
||||
Struct,
|
||||
Tool,
|
||||
Trait,
|
||||
TypeAlias,
|
||||
TypeParam,
|
||||
|
@ -65,6 +65,7 @@ define_semantic_token_types![
|
||||
(SELF_KEYWORD, "selfKeyword"),
|
||||
(SEMICOLON, "semicolon"),
|
||||
(TYPE_ALIAS, "typeAlias"),
|
||||
(TOOL, "tool"),
|
||||
(UNION, "union"),
|
||||
(UNRESOLVED_REFERENCE, "unresolvedReference"),
|
||||
];
|
||||
|
@ -50,8 +50,8 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
||||
SymbolKind::Enum => lsp_types::SymbolKind::ENUM,
|
||||
SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER,
|
||||
SymbolKind::Trait => lsp_types::SymbolKind::INTERFACE,
|
||||
SymbolKind::Macro => lsp_types::SymbolKind::FUNCTION,
|
||||
SymbolKind::Module => lsp_types::SymbolKind::MODULE,
|
||||
SymbolKind::Macro | SymbolKind::BuiltinAttr => lsp_types::SymbolKind::FUNCTION,
|
||||
SymbolKind::Module | SymbolKind::Tool => lsp_types::SymbolKind::MODULE,
|
||||
SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TYPE_PARAMETER,
|
||||
SymbolKind::Field => lsp_types::SymbolKind::FIELD,
|
||||
SymbolKind::Static => lsp_types::SymbolKind::CONSTANT,
|
||||
@ -128,6 +128,8 @@ pub(crate) fn completion_item_kind(
|
||||
SymbolKind::Union => lsp_types::CompletionItemKind::STRUCT,
|
||||
SymbolKind::ValueParam => lsp_types::CompletionItemKind::VALUE,
|
||||
SymbolKind::Variant => lsp_types::CompletionItemKind::ENUM_MEMBER,
|
||||
SymbolKind::BuiltinAttr => lsp_types::CompletionItemKind::FUNCTION,
|
||||
SymbolKind::Tool => lsp_types::CompletionItemKind::MODULE,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -499,10 +501,11 @@ fn semantic_token_type_and_modifiers(
|
||||
SymbolKind::TypeAlias => semantic_tokens::TYPE_ALIAS,
|
||||
SymbolKind::Trait => lsp_types::SemanticTokenType::INTERFACE,
|
||||
SymbolKind::Macro => lsp_types::SemanticTokenType::MACRO,
|
||||
SymbolKind::BuiltinAttr => semantic_tokens::BUILTIN_ATTRIBUTE,
|
||||
SymbolKind::Tool => semantic_tokens::TOOL,
|
||||
},
|
||||
HlTag::Attribute => semantic_tokens::ATTRIBUTE,
|
||||
HlTag::BoolLiteral => semantic_tokens::BOOLEAN,
|
||||
HlTag::BuiltinAttr => semantic_tokens::BUILTIN_ATTRIBUTE,
|
||||
HlTag::BuiltinType => semantic_tokens::BUILTIN_TYPE,
|
||||
HlTag::ByteLiteral | HlTag::NumericLiteral => lsp_types::SemanticTokenType::NUMBER,
|
||||
HlTag::CharLiteral => semantic_tokens::CHAR,
|
||||
|
Loading…
Reference in New Issue
Block a user