diff options
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 26 | ||||
-rw-r--r-- | crates/rust-analyzer/src/conv.rs | 8 | ||||
-rw-r--r-- | crates/rust-analyzer/src/semantic_tokens.rs | 2 | ||||
-rw-r--r-- | editors/code/package.json | 9 |
5 files changed, 32 insertions, 30 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index d7bca1193..ae2163f9f 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -255,15 +255,15 @@ fn highlight_name(db: &RootDatabase, def: NameDefinition) -> Highlight { | |||
255 | NameDefinition::ModuleDef(def) => match def { | 255 | NameDefinition::ModuleDef(def) => match def { |
256 | hir::ModuleDef::Module(_) => HighlightTag::Module, | 256 | hir::ModuleDef::Module(_) => HighlightTag::Module, |
257 | hir::ModuleDef::Function(_) => HighlightTag::Function, | 257 | hir::ModuleDef::Function(_) => HighlightTag::Function, |
258 | hir::ModuleDef::Adt(_) => HighlightTag::Type, | 258 | hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, |
259 | hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, | ||
260 | hir::ModuleDef::Adt(hir::Adt::Union(_)) => HighlightTag::Union, | ||
259 | hir::ModuleDef::EnumVariant(_) => HighlightTag::Constant, | 261 | hir::ModuleDef::EnumVariant(_) => HighlightTag::Constant, |
260 | hir::ModuleDef::Const(_) => HighlightTag::Constant, | 262 | hir::ModuleDef::Const(_) => HighlightTag::Constant, |
261 | hir::ModuleDef::Static(_) => HighlightTag::Constant, | 263 | hir::ModuleDef::Static(_) => HighlightTag::Constant, |
262 | hir::ModuleDef::Trait(_) => HighlightTag::Type, | 264 | hir::ModuleDef::Trait(_) => HighlightTag::Trait, |
263 | hir::ModuleDef::TypeAlias(_) => HighlightTag::Type, | 265 | hir::ModuleDef::TypeAlias(_) => HighlightTag::TypeAlias, |
264 | hir::ModuleDef::BuiltinType(_) => { | 266 | hir::ModuleDef::BuiltinType(_) => HighlightTag::BuiltinType, |
265 | return HighlightTag::Type | HighlightModifier::Builtin | ||
266 | } | ||
267 | }, | 267 | }, |
268 | NameDefinition::SelfType(_) => HighlightTag::TypeSelf, | 268 | NameDefinition::SelfType(_) => HighlightTag::TypeSelf, |
269 | NameDefinition::TypeParam(_) => HighlightTag::TypeParam, | 269 | NameDefinition::TypeParam(_) => HighlightTag::TypeParam, |
@@ -287,7 +287,10 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { | |||
287 | }; | 287 | }; |
288 | 288 | ||
289 | match parent.kind() { | 289 | match parent.kind() { |
290 | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => HighlightTag::Type.into(), | 290 | STRUCT_DEF => HighlightTag::Struct.into(), |
291 | ENUM_DEF => HighlightTag::Enum.into(), | ||
292 | TRAIT_DEF => HighlightTag::Trait.into(), | ||
293 | TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), | ||
291 | TYPE_PARAM => HighlightTag::TypeParam.into(), | 294 | TYPE_PARAM => HighlightTag::TypeParam.into(), |
292 | RECORD_FIELD_DEF => HighlightTag::Field.into(), | 295 | RECORD_FIELD_DEF => HighlightTag::Field.into(), |
293 | _ => default, | 296 | _ => default, |
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 383c74c98..df2fc3c48 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs | |||
@@ -14,6 +14,13 @@ pub struct HighlightModifiers(u32); | |||
14 | 14 | ||
15 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | 15 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] |
16 | pub enum HighlightTag { | 16 | pub enum HighlightTag { |
17 | Struct, | ||
18 | Enum, | ||
19 | Union, | ||
20 | Trait, | ||
21 | TypeAlias, | ||
22 | BuiltinType, | ||
23 | |||
17 | Field, | 24 | Field, |
18 | Function, | 25 | Function, |
19 | Module, | 26 | Module, |
@@ -21,7 +28,6 @@ pub enum HighlightTag { | |||
21 | Macro, | 28 | Macro, |
22 | Variable, | 29 | Variable, |
23 | 30 | ||
24 | Type, | ||
25 | TypeSelf, | 31 | TypeSelf, |
26 | TypeParam, | 32 | TypeParam, |
27 | TypeLifetime, | 33 | TypeLifetime, |
@@ -44,19 +50,24 @@ pub enum HighlightModifier { | |||
44 | Unsafe, | 50 | Unsafe, |
45 | /// Used with keywords like `if` and `break`. | 51 | /// Used with keywords like `if` and `break`. |
46 | Control, | 52 | Control, |
47 | Builtin, | ||
48 | } | 53 | } |
49 | 54 | ||
50 | impl HighlightTag { | 55 | impl HighlightTag { |
51 | fn as_str(self) -> &'static str { | 56 | fn as_str(self) -> &'static str { |
52 | match self { | 57 | match self { |
58 | HighlightTag::Struct => "struct", | ||
59 | HighlightTag::Enum => "enum", | ||
60 | HighlightTag::Union => "union", | ||
61 | HighlightTag::Trait => "trait", | ||
62 | HighlightTag::TypeAlias => "type_alias", | ||
63 | HighlightTag::BuiltinType => "builtin_type", | ||
64 | |||
53 | HighlightTag::Field => "field", | 65 | HighlightTag::Field => "field", |
54 | HighlightTag::Function => "function", | 66 | HighlightTag::Function => "function", |
55 | HighlightTag::Module => "module", | 67 | HighlightTag::Module => "module", |
56 | HighlightTag::Constant => "constant", | 68 | HighlightTag::Constant => "constant", |
57 | HighlightTag::Macro => "macro", | 69 | HighlightTag::Macro => "macro", |
58 | HighlightTag::Variable => "variable", | 70 | HighlightTag::Variable => "variable", |
59 | HighlightTag::Type => "type", | ||
60 | HighlightTag::TypeSelf => "type.self", | 71 | HighlightTag::TypeSelf => "type.self", |
61 | HighlightTag::TypeParam => "type.param", | 72 | HighlightTag::TypeParam => "type.param", |
62 | HighlightTag::TypeLifetime => "type.lifetime", | 73 | HighlightTag::TypeLifetime => "type.lifetime", |
@@ -78,19 +89,14 @@ impl fmt::Display for HighlightTag { | |||
78 | } | 89 | } |
79 | 90 | ||
80 | impl HighlightModifier { | 91 | impl HighlightModifier { |
81 | const ALL: &'static [HighlightModifier] = &[ | 92 | const ALL: &'static [HighlightModifier] = |
82 | HighlightModifier::Mutable, | 93 | &[HighlightModifier::Mutable, HighlightModifier::Unsafe, HighlightModifier::Control]; |
83 | HighlightModifier::Unsafe, | ||
84 | HighlightModifier::Control, | ||
85 | HighlightModifier::Builtin, | ||
86 | ]; | ||
87 | 94 | ||
88 | fn as_str(self) -> &'static str { | 95 | fn as_str(self) -> &'static str { |
89 | match self { | 96 | match self { |
90 | HighlightModifier::Mutable => "mutable", | 97 | HighlightModifier::Mutable => "mutable", |
91 | HighlightModifier::Unsafe => "unsafe", | 98 | HighlightModifier::Unsafe => "unsafe", |
92 | HighlightModifier::Control => "control", | 99 | HighlightModifier::Control => "control", |
93 | HighlightModifier::Builtin => "builtin", | ||
94 | } | 100 | } |
95 | } | 101 | } |
96 | 102 | ||
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index b012f5dd5..e4255e24a 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs | |||
@@ -316,6 +316,12 @@ impl Conv for Highlight { | |||
316 | fn conv(self) -> Self::Output { | 316 | fn conv(self) -> Self::Output { |
317 | let mut mods = ModifierSet::default(); | 317 | let mut mods = ModifierSet::default(); |
318 | let type_ = match self.tag { | 318 | let type_ = match self.tag { |
319 | HighlightTag::Struct | ||
320 | | HighlightTag::Enum | ||
321 | | HighlightTag::Union | ||
322 | | HighlightTag::TypeAlias | ||
323 | | HighlightTag::Trait | ||
324 | | HighlightTag::BuiltinType => SemanticTokenType::TYPE, | ||
319 | HighlightTag::Field => SemanticTokenType::MEMBER, | 325 | HighlightTag::Field => SemanticTokenType::MEMBER, |
320 | HighlightTag::Function => SemanticTokenType::FUNCTION, | 326 | HighlightTag::Function => SemanticTokenType::FUNCTION, |
321 | HighlightTag::Module => SemanticTokenType::NAMESPACE, | 327 | HighlightTag::Module => SemanticTokenType::NAMESPACE, |
@@ -326,7 +332,6 @@ impl Conv for Highlight { | |||
326 | } | 332 | } |
327 | HighlightTag::Macro => SemanticTokenType::MACRO, | 333 | HighlightTag::Macro => SemanticTokenType::MACRO, |
328 | HighlightTag::Variable => SemanticTokenType::VARIABLE, | 334 | HighlightTag::Variable => SemanticTokenType::VARIABLE, |
329 | HighlightTag::Type => SemanticTokenType::TYPE, | ||
330 | HighlightTag::TypeSelf => { | 335 | HighlightTag::TypeSelf => { |
331 | mods |= SemanticTokenModifier::REFERENCE; | 336 | mods |= SemanticTokenModifier::REFERENCE; |
332 | SemanticTokenType::TYPE | 337 | SemanticTokenType::TYPE |
@@ -350,7 +355,6 @@ impl Conv for Highlight { | |||
350 | HighlightModifier::Mutable => MUTABLE, | 355 | HighlightModifier::Mutable => MUTABLE, |
351 | HighlightModifier::Unsafe => UNSAFE, | 356 | HighlightModifier::Unsafe => UNSAFE, |
352 | HighlightModifier::Control => CONTROL, | 357 | HighlightModifier::Control => CONTROL, |
353 | HighlightModifier::Builtin => BUILTIN, | ||
354 | }; | 358 | }; |
355 | mods |= modifier; | 359 | mods |= modifier; |
356 | } | 360 | } |
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index d8362409d..3069f3054 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs | |||
@@ -10,7 +10,6 @@ pub(crate) const CONSTANT: SemanticTokenType = SemanticTokenType::new("constant" | |||
10 | pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); | 10 | pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); |
11 | pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); | 11 | pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); |
12 | pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); | 12 | pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); |
13 | pub(crate) const BUILTIN: SemanticTokenModifier = SemanticTokenModifier::new("builtin"); | ||
14 | 13 | ||
15 | pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ | 14 | pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ |
16 | SemanticTokenType::COMMENT, | 15 | SemanticTokenType::COMMENT, |
@@ -51,7 +50,6 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ | |||
51 | MUTABLE, | 50 | MUTABLE, |
52 | UNSAFE, | 51 | UNSAFE, |
53 | CONTROL, | 52 | CONTROL, |
54 | BUILTIN, | ||
55 | ]; | 53 | ]; |
56 | 54 | ||
57 | #[derive(Default)] | 55 | #[derive(Default)] |
diff --git a/editors/code/package.json b/editors/code/package.json index 5effa3e17..fd29710ba 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -398,9 +398,6 @@ | |||
398 | }, | 398 | }, |
399 | { | 399 | { |
400 | "id": "control" | 400 | "id": "control" |
401 | }, | ||
402 | { | ||
403 | "id": "builtin" | ||
404 | } | 401 | } |
405 | ], | 402 | ], |
406 | "semanticTokenStyleDefaults": [ | 403 | "semanticTokenStyleDefaults": [ |
@@ -433,12 +430,6 @@ | |||
433 | "scope": [ | 430 | "scope": [ |
434 | "keyword.other.unsafe" | 431 | "keyword.other.unsafe" |
435 | ] | 432 | ] |
436 | }, | ||
437 | { | ||
438 | "selector": "type.builtin", | ||
439 | "scope": [ | ||
440 | "support.type.builtin" | ||
441 | ] | ||
442 | } | 433 | } |
443 | ] | 434 | ] |
444 | } | 435 | } |