]> git.lizzy.rs Git - rust.git/commitdiff
Make control token modifier less ambiguous
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 5 Apr 2020 12:46:07 +0000 (14:46 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 6 Apr 2020 07:57:50 +0000 (09:57 +0200)
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
crates/ra_ide/src/syntax_highlighting/tags.rs
crates/rust-analyzer/src/conv.rs
crates/rust-analyzer/src/semantic_tokens.rs
editors/code/package.json

index 7fc94d3cdbcebc93c5b1866f2a22bd2897b57a08..d833a816b127d68cc3198252d343e3fc982c1513 100644 (file)
@@ -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,
             }
index 8835a5de214ff6d04e261db6b939e764fc60c2ab..e8b138e1a7a638a5d357787b6d082a5327d8e97f 100644 (file)
@@ -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 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
 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",
index 57c4c8ce55c87f9bdf21b56265ab073bbf1075da..b2b1cb625885c038fc859f9c2a300d3aa0478a58 100644 (file)
@@ -20,7 +20,7 @@
 
 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 @@ fn conv(self) -> Self::Output {
         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,
             };
index 2a66bbfd85e5183209c9ac23f88d1db34a08a36e..865fa3b1c56b874a3e16ad32013c94d64af892e8 100644 (file)
@@ -12,7 +12,7 @@
 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 @@
     CONSTANT,
     MUTABLE,
     UNSAFE,
-    CONTROL,
+    CONTROL_FLOW,
 ];
 
 #[derive(Default)]
index 595d6e378c1a0fa69ddafce1606d82f9022bdc87..8ca8c76cce4aad215fbbee5b9b2037b227be49a7 100644 (file)
                 "description": "Style for compile-time constants"
             },
             {
-                "id": "control",
+                "id": "controlFlow",
                 "description": "Style for control flow keywords"
             },
             {
                     "keyword.unsafe": [
                         "keyword.other.unsafe"
                     ],
-                    "keyword.control": [
-                        "keyword.control"
-                    ],
                     "variable.constant": [
                         "entity.name.constant"
                     ]