diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index be1a0f12b..33e6619ec 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs | |||
@@ -45,8 +45,10 @@ pub enum HighlightTag { | |||
45 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | 45 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] |
46 | #[repr(u8)] | 46 | #[repr(u8)] |
47 | pub enum HighlightModifier { | 47 | pub enum HighlightModifier { |
48 | /// Used to differentiate individual elements within attributes. | ||
49 | Attribute = 0, | ||
48 | /// Used with keywords like `if` and `break`. | 50 | /// Used with keywords like `if` and `break`. |
49 | ControlFlow = 0, | 51 | ControlFlow, |
50 | /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is | 52 | /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is |
51 | /// not. | 53 | /// not. |
52 | Definition, | 54 | Definition, |
@@ -95,6 +97,7 @@ impl fmt::Display for HighlightTag { | |||
95 | 97 | ||
96 | impl HighlightModifier { | 98 | impl HighlightModifier { |
97 | const ALL: &'static [HighlightModifier] = &[ | 99 | const ALL: &'static [HighlightModifier] = &[ |
100 | HighlightModifier::Attribute, | ||
98 | HighlightModifier::ControlFlow, | 101 | HighlightModifier::ControlFlow, |
99 | HighlightModifier::Definition, | 102 | HighlightModifier::Definition, |
100 | HighlightModifier::Mutable, | 103 | HighlightModifier::Mutable, |
@@ -103,6 +106,7 @@ impl HighlightModifier { | |||
103 | 106 | ||
104 | fn as_str(self) -> &'static str { | 107 | fn as_str(self) -> &'static str { |
105 | match self { | 108 | match self { |
109 | HighlightModifier::Attribute => "attribute", | ||
106 | HighlightModifier::ControlFlow => "control", | 110 | HighlightModifier::ControlFlow => "control", |
107 | HighlightModifier::Definition => "declaration", | 111 | HighlightModifier::Definition => "declaration", |
108 | HighlightModifier::Mutable => "mutable", | 112 | HighlightModifier::Mutable => "mutable", |
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 13894869c..eb43a23da 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -17,6 +17,16 @@ struct Foo { | |||
17 | pub y: i32, | 17 | pub y: i32, |
18 | } | 18 | } |
19 | 19 | ||
20 | trait Bar { | ||
21 | fn bar(&self) -> i32; | ||
22 | } | ||
23 | |||
24 | impl Bar for Foo { | ||
25 | fn bar(&self) -> i32 { | ||
26 | self.x | ||
27 | } | ||
28 | } | ||
29 | |||
20 | static mut STATIC_MUT: i32 = 0; | 30 | static mut STATIC_MUT: i32 = 0; |
21 | 31 | ||
22 | fn foo<'a, T>() -> T { | 32 | fn foo<'a, T>() -> T { |
@@ -47,6 +57,10 @@ fn main() { | |||
47 | STATIC_MUT = 1; | 57 | STATIC_MUT = 1; |
48 | } | 58 | } |
49 | 59 | ||
60 | for e in vec { | ||
61 | // Do nothing | ||
62 | } | ||
63 | |||
50 | let mut x = 42; | 64 | let mut x = 42; |
51 | let y = &mut x; | 65 | let y = &mut x; |
52 | let z = &y; | 66 | let z = &y; |