diff options
author | Aleksey Kladov <[email protected]> | 2020-02-27 18:00:10 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-28 09:39:31 +0000 |
commit | 996e18846dab8e5c4a2846641289f85fe99eb480 (patch) | |
tree | 3244e881a99bfa4a1e688fef16acfa53e407f590 /crates/ra_ide/src | |
parent | 4741ae785257bc894cd9a61c1d5e6479074c69b6 (diff) |
add more tags
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 26 |
2 files changed, 26 insertions, 17 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 | ||