Add semantic tag for unresolved references
This is a quick way to implement unresolved reference diagnostics.
For example, adding to VS Code config
"editor.tokenColorCustomizationsExperimental": {
"unresolvedReference": "#FF0000"
},
will highlight all unresolved refs in red.
This commit is contained in:
@@ -24,7 +24,9 @@ use crate::{
|
||||
world::WorldSnapshot,
|
||||
Result,
|
||||
};
|
||||
use semantic_tokens::{ATTRIBUTE, BUILTIN_TYPE, ENUM_MEMBER, LIFETIME, TYPE_ALIAS, UNION};
|
||||
use semantic_tokens::{
|
||||
ATTRIBUTE, BUILTIN_TYPE, ENUM_MEMBER, LIFETIME, TYPE_ALIAS, UNION, UNRESOLVED_REFERENCE,
|
||||
};
|
||||
|
||||
pub trait Conv {
|
||||
type Output;
|
||||
@@ -373,6 +375,7 @@ impl Conv for Highlight {
|
||||
HighlightTag::Comment => SemanticTokenType::COMMENT,
|
||||
HighlightTag::Attribute => ATTRIBUTE,
|
||||
HighlightTag::Keyword => SemanticTokenType::KEYWORD,
|
||||
HighlightTag::UnresolvedReference => UNRESOLVED_REFERENCE,
|
||||
};
|
||||
|
||||
for modifier in self.modifiers.iter() {
|
||||
|
||||
@@ -10,6 +10,8 @@ pub(crate) const ENUM_MEMBER: SemanticTokenType = SemanticTokenType::new("enumMe
|
||||
pub(crate) const LIFETIME: SemanticTokenType = SemanticTokenType::new("lifetime");
|
||||
pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAlias");
|
||||
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
|
||||
pub(crate) const UNRESOLVED_REFERENCE: SemanticTokenType =
|
||||
SemanticTokenType::new("unresolvedReference");
|
||||
|
||||
pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant");
|
||||
pub(crate) const CONTROL_FLOW: SemanticTokenModifier = SemanticTokenModifier::new("controlFlow");
|
||||
@@ -43,6 +45,7 @@ pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[
|
||||
LIFETIME,
|
||||
TYPE_ALIAS,
|
||||
UNION,
|
||||
UNRESOLVED_REFERENCE,
|
||||
];
|
||||
|
||||
pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
|
||||
|
||||
Reference in New Issue
Block a user