mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Make control token modifier less ambiguous
In textmate, keyword.control is used for all kinds of things; in fact, the default scope mapping for keyword is keyword.control! So let's add a less ambiguous controlFlow modifier See Microsoft/vscode#94367
This commit is contained in:
parent
6207ac90da
commit
48bc0ca745
5 changed files with 9 additions and 12 deletions
|
@ -232,7 +232,7 @@ fn highlight_element(
|
||||||
| T![loop]
|
| T![loop]
|
||||||
| T![match]
|
| T![match]
|
||||||
| T![return]
|
| T![return]
|
||||||
| T![while] => h | HighlightModifier::Control,
|
| T![while] => h | HighlightModifier::ControlFlow,
|
||||||
T![unsafe] => h | HighlightModifier::Unsafe,
|
T![unsafe] => h | HighlightModifier::Unsafe,
|
||||||
_ => h,
|
_ => h,
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub enum HighlightTag {
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum HighlightModifier {
|
pub enum HighlightModifier {
|
||||||
/// Used with keywords like `if` and `break`.
|
/// Used with keywords like `if` and `break`.
|
||||||
Control = 0,
|
ControlFlow = 0,
|
||||||
/// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
|
/// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
|
||||||
/// not.
|
/// not.
|
||||||
Definition,
|
Definition,
|
||||||
|
@ -91,7 +91,7 @@ impl fmt::Display for HighlightTag {
|
||||||
|
|
||||||
impl HighlightModifier {
|
impl HighlightModifier {
|
||||||
const ALL: &'static [HighlightModifier] = &[
|
const ALL: &'static [HighlightModifier] = &[
|
||||||
HighlightModifier::Control,
|
HighlightModifier::ControlFlow,
|
||||||
HighlightModifier::Definition,
|
HighlightModifier::Definition,
|
||||||
HighlightModifier::Mutable,
|
HighlightModifier::Mutable,
|
||||||
HighlightModifier::Unsafe,
|
HighlightModifier::Unsafe,
|
||||||
|
@ -99,7 +99,7 @@ impl HighlightModifier {
|
||||||
|
|
||||||
fn as_str(self) -> &'static str {
|
fn as_str(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
HighlightModifier::Control => "control",
|
HighlightModifier::ControlFlow => "control",
|
||||||
HighlightModifier::Definition => "declaration",
|
HighlightModifier::Definition => "declaration",
|
||||||
HighlightModifier::Mutable => "mutable",
|
HighlightModifier::Mutable => "mutable",
|
||||||
HighlightModifier::Unsafe => "unsafe",
|
HighlightModifier::Unsafe => "unsafe",
|
||||||
|
|
|
@ -20,7 +20,7 @@ use ra_vfs::LineEndings;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
req,
|
req,
|
||||||
semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL, MUTABLE, UNSAFE},
|
semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL_FLOW, MUTABLE, UNSAFE},
|
||||||
world::WorldSnapshot,
|
world::WorldSnapshot,
|
||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
@ -378,7 +378,7 @@ impl Conv for Highlight {
|
||||||
for modifier in self.modifiers.iter() {
|
for modifier in self.modifiers.iter() {
|
||||||
let modifier = match modifier {
|
let modifier = match modifier {
|
||||||
HighlightModifier::Definition => SemanticTokenModifier::DECLARATION,
|
HighlightModifier::Definition => SemanticTokenModifier::DECLARATION,
|
||||||
HighlightModifier::Control => CONTROL,
|
HighlightModifier::ControlFlow => CONTROL_FLOW,
|
||||||
HighlightModifier::Mutable => MUTABLE,
|
HighlightModifier::Mutable => MUTABLE,
|
||||||
HighlightModifier::Unsafe => UNSAFE,
|
HighlightModifier::Unsafe => UNSAFE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAli
|
||||||
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
|
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
|
||||||
|
|
||||||
pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant");
|
pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant");
|
||||||
pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control");
|
pub(crate) const CONTROL_FLOW: SemanticTokenModifier = SemanticTokenModifier::new("controlFlow");
|
||||||
pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable");
|
pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable");
|
||||||
pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe");
|
pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe");
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
|
||||||
CONSTANT,
|
CONSTANT,
|
||||||
MUTABLE,
|
MUTABLE,
|
||||||
UNSAFE,
|
UNSAFE,
|
||||||
CONTROL,
|
CONTROL_FLOW,
|
||||||
];
|
];
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
@ -512,7 +512,7 @@
|
||||||
"description": "Style for compile-time constants"
|
"description": "Style for compile-time constants"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "control",
|
"id": "controlFlow",
|
||||||
"description": "Style for control flow keywords"
|
"description": "Style for control flow keywords"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -546,9 +546,6 @@
|
||||||
"keyword.unsafe": [
|
"keyword.unsafe": [
|
||||||
"keyword.other.unsafe"
|
"keyword.other.unsafe"
|
||||||
],
|
],
|
||||||
"keyword.control": [
|
|
||||||
"keyword.control"
|
|
||||||
],
|
|
||||||
"variable.constant": [
|
"variable.constant": [
|
||||||
"entity.name.constant"
|
"entity.name.constant"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue