Skip to content

Commit

Permalink
Merge pull request #3853 from matklad/cf
Browse files Browse the repository at this point in the history
Make control token modifier less ambiguous
  • Loading branch information
matklad committed Apr 6, 2020
2 parents 972816b + 48bc0ca commit ec3fb1c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/ra_ide/src/syntax_highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn highlight_element(
| T![loop]
| T![match]
| T![return]
| T![while] => h | HighlightModifier::Control,
| T![while] => h | HighlightModifier::ControlFlow,
T![unsafe] => h | HighlightModifier::Unsafe,
_ => h,
}
Expand Down
6 changes: 3 additions & 3 deletions crates/ra_ide/src/syntax_highlighting/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum HighlightTag {
#[repr(u8)]
pub enum HighlightModifier {
/// 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
/// not.
Definition,
Expand Down Expand Up @@ -91,15 +91,15 @@ impl fmt::Display for HighlightTag {

impl HighlightModifier {
const ALL: &'static [HighlightModifier] = &[
HighlightModifier::Control,
HighlightModifier::ControlFlow,
HighlightModifier::Definition,
HighlightModifier::Mutable,
HighlightModifier::Unsafe,
];

fn as_str(self) -> &'static str {
match self {
HighlightModifier::Control => "control",
HighlightModifier::ControlFlow => "control",
HighlightModifier::Definition => "declaration",
HighlightModifier::Mutable => "mutable",
HighlightModifier::Unsafe => "unsafe",
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-analyzer/src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ra_vfs::LineEndings;

use crate::{
req,
semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL, MUTABLE, UNSAFE},
semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL_FLOW, MUTABLE, UNSAFE},
world::WorldSnapshot,
Result,
};
Expand Down Expand Up @@ -378,7 +378,7 @@ impl Conv for Highlight {
for modifier in self.modifiers.iter() {
let modifier = match modifier {
HighlightModifier::Definition => SemanticTokenModifier::DECLARATION,
HighlightModifier::Control => CONTROL,
HighlightModifier::ControlFlow => CONTROL_FLOW,
HighlightModifier::Mutable => MUTABLE,
HighlightModifier::Unsafe => UNSAFE,
};
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-analyzer/src/semantic_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAli
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");

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 UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe");

Expand Down Expand Up @@ -56,7 +56,7 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
CONSTANT,
MUTABLE,
UNSAFE,
CONTROL,
CONTROL_FLOW,
];

#[derive(Default)]
Expand Down
5 changes: 1 addition & 4 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
"description": "Style for compile-time constants"
},
{
"id": "control",
"id": "controlFlow",
"description": "Style for control flow keywords"
},
{
Expand Down Expand Up @@ -551,9 +551,6 @@
"keyword.unsafe": [
"keyword.other.unsafe"
],
"keyword.control": [
"keyword.control"
],
"variable.constant": [
"entity.name.constant"
]
Expand Down

0 comments on commit ec3fb1c

Please sign in to comment.