From 48bc0ca745a0ebdd61b7db3935582bf5ec95042b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 5 Apr 2020 14:46:07 +0200 Subject: 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 --- crates/ra_ide/src/syntax_highlighting.rs | 2 +- crates/ra_ide/src/syntax_highlighting/tags.rs | 6 +++--- crates/rust-analyzer/src/conv.rs | 4 ++-- crates/rust-analyzer/src/semantic_tokens.rs | 4 ++-- editors/code/package.json | 5 +---- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 7fc94d3cd..d833a816b 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -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, } diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 8835a5de2..e8b138e1a 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -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, @@ -91,7 +91,7 @@ impl fmt::Display for HighlightTag { impl HighlightModifier { const ALL: &'static [HighlightModifier] = &[ - HighlightModifier::Control, + HighlightModifier::ControlFlow, HighlightModifier::Definition, HighlightModifier::Mutable, HighlightModifier::Unsafe, @@ -99,7 +99,7 @@ impl HighlightModifier { fn as_str(self) -> &'static str { match self { - HighlightModifier::Control => "control", + HighlightModifier::ControlFlow => "control", HighlightModifier::Definition => "declaration", HighlightModifier::Mutable => "mutable", HighlightModifier::Unsafe => "unsafe", diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index 57c4c8ce5..b2b1cb625 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs @@ -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, }; @@ -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, }; diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 2a66bbfd8..865fa3b1c 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -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"); @@ -56,7 +56,7 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ CONSTANT, MUTABLE, UNSAFE, - CONTROL, + CONTROL_FLOW, ]; #[derive(Default)] diff --git a/editors/code/package.json b/editors/code/package.json index 595d6e378..8ca8c76cc 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -512,7 +512,7 @@ "description": "Style for compile-time constants" }, { - "id": "control", + "id": "controlFlow", "description": "Style for control flow keywords" }, { @@ -546,9 +546,6 @@ "keyword.unsafe": [ "keyword.other.unsafe" ], - "keyword.control": [ - "keyword.control" - ], "variable.constant": [ "entity.name.constant" ] -- cgit v1.2.3