aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-05 13:46:07 +0100
committerAleksey Kladov <[email protected]>2020-04-06 08:57:50 +0100
commit48bc0ca745a0ebdd61b7db3935582bf5ec95042b (patch)
tree2a9f6b1f5a9995c3bddf7a1ef829cb6890413b7d
parent6207ac90da7e607218457bf872fa32df6b78f224 (diff)
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
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs6
-rw-r--r--crates/rust-analyzer/src/conv.rs4
-rw-r--r--crates/rust-analyzer/src/semantic_tokens.rs4
-rw-r--r--editors/code/package.json5
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(
232 | T![loop] 232 | T![loop]
233 | T![match] 233 | T![match]
234 | T![return] 234 | T![return]
235 | T![while] => h | HighlightModifier::Control, 235 | T![while] => h | HighlightModifier::ControlFlow,
236 T![unsafe] => h | HighlightModifier::Unsafe, 236 T![unsafe] => h | HighlightModifier::Unsafe,
237 _ => h, 237 _ => h,
238 } 238 }
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 {
44#[repr(u8)] 44#[repr(u8)]
45pub enum HighlightModifier { 45pub enum HighlightModifier {
46 /// Used with keywords like `if` and `break`. 46 /// Used with keywords like `if` and `break`.
47 Control = 0, 47 ControlFlow = 0,
48 /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is 48 /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
49 /// not. 49 /// not.
50 Definition, 50 Definition,
@@ -91,7 +91,7 @@ impl fmt::Display for HighlightTag {
91 91
92impl HighlightModifier { 92impl HighlightModifier {
93 const ALL: &'static [HighlightModifier] = &[ 93 const ALL: &'static [HighlightModifier] = &[
94 HighlightModifier::Control, 94 HighlightModifier::ControlFlow,
95 HighlightModifier::Definition, 95 HighlightModifier::Definition,
96 HighlightModifier::Mutable, 96 HighlightModifier::Mutable,
97 HighlightModifier::Unsafe, 97 HighlightModifier::Unsafe,
@@ -99,7 +99,7 @@ impl HighlightModifier {
99 99
100 fn as_str(self) -> &'static str { 100 fn as_str(self) -> &'static str {
101 match self { 101 match self {
102 HighlightModifier::Control => "control", 102 HighlightModifier::ControlFlow => "control",
103 HighlightModifier::Definition => "declaration", 103 HighlightModifier::Definition => "declaration",
104 HighlightModifier::Mutable => "mutable", 104 HighlightModifier::Mutable => "mutable",
105 HighlightModifier::Unsafe => "unsafe", 105 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;
20 20
21use crate::{ 21use crate::{
22 req, 22 req,
23 semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL, MUTABLE, UNSAFE}, 23 semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL_FLOW, MUTABLE, UNSAFE},
24 world::WorldSnapshot, 24 world::WorldSnapshot,
25 Result, 25 Result,
26}; 26};
@@ -378,7 +378,7 @@ impl Conv for Highlight {
378 for modifier in self.modifiers.iter() { 378 for modifier in self.modifiers.iter() {
379 let modifier = match modifier { 379 let modifier = match modifier {
380 HighlightModifier::Definition => SemanticTokenModifier::DECLARATION, 380 HighlightModifier::Definition => SemanticTokenModifier::DECLARATION,
381 HighlightModifier::Control => CONTROL, 381 HighlightModifier::ControlFlow => CONTROL_FLOW,
382 HighlightModifier::Mutable => MUTABLE, 382 HighlightModifier::Mutable => MUTABLE,
383 HighlightModifier::Unsafe => UNSAFE, 383 HighlightModifier::Unsafe => UNSAFE,
384 }; 384 };
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
12pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union"); 12pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
13 13
14pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant"); 14pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant");
15pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); 15pub(crate) const CONTROL_FLOW: SemanticTokenModifier = SemanticTokenModifier::new("controlFlow");
16pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); 16pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable");
17pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); 17pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe");
18 18
@@ -56,7 +56,7 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[
56 CONSTANT, 56 CONSTANT,
57 MUTABLE, 57 MUTABLE,
58 UNSAFE, 58 UNSAFE,
59 CONTROL, 59 CONTROL_FLOW,
60]; 60];
61 61
62#[derive(Default)] 62#[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 @@
512 "description": "Style for compile-time constants" 512 "description": "Style for compile-time constants"
513 }, 513 },
514 { 514 {
515 "id": "control", 515 "id": "controlFlow",
516 "description": "Style for control flow keywords" 516 "description": "Style for control flow keywords"
517 }, 517 },
518 { 518 {
@@ -546,9 +546,6 @@
546 "keyword.unsafe": [ 546 "keyword.unsafe": [
547 "keyword.other.unsafe" 547 "keyword.other.unsafe"
548 ], 548 ],
549 "keyword.control": [
550 "keyword.control"
551 ],
552 "variable.constant": [ 549 "variable.constant": [
553 "entity.name.constant" 550 "entity.name.constant"
554 ] 551 ]