diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs index 336af3f4c9..3bee0ae468 100644 --- a/crates/ide/src/syntax_highlighting/tags.rs +++ b/crates/ide/src/syntax_highlighting/tags.rs @@ -40,8 +40,14 @@ pub enum HlTag { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] #[repr(u8)] pub enum HlMod { + /// Used for items in traits and impls. + Associated = 0, /// Used to differentiate individual elements within attributes. - Attribute = 0, + Attribute, + /// Callable item or value. + Callable, + /// Value that is being consumed in a function call + Consuming, /// Used with keywords like `if` and `break`. ControlFlow, /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is @@ -51,21 +57,14 @@ pub enum HlMod { Documentation, /// Highlighting injection like rust code in doc strings or ra_fixture. Injected, - /// Mutable binding. - Mutable, - /// Value that is being consumed in a function call - Consuming, - /// Callable item or value. - Callable, - /// Used for associated functions. - Static, - /// Used for items in traits and impls. - Associated, /// Used for intra doc links in doc injection. IntraDocLink, + /// Mutable binding. + Mutable, + /// Used for associated functions. + Static, /// Used for items in traits and trait impls. Trait, - // Keep this last! /// Used for unsafe functions, mutable statics, union accesses and unsafe operations. Unsafe, @@ -175,17 +174,17 @@ impl fmt::Display for HlTag { impl HlMod { const ALL: &'static [HlMod; HlMod::Unsafe as u8 as usize + 1] = &[ + HlMod::Associated, HlMod::Attribute, + HlMod::Callable, + HlMod::Consuming, HlMod::ControlFlow, HlMod::Definition, HlMod::Documentation, - HlMod::IntraDocLink, HlMod::Injected, + HlMod::IntraDocLink, HlMod::Mutable, - HlMod::Consuming, - HlMod::Callable, HlMod::Static, - HlMod::Associated, HlMod::Trait, HlMod::Unsafe, ]; diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html b/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html index 8cde3906c3..a0ea1db346 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_assoc_functions.html @@ -42,17 +42,17 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd struct foo {} impl foo { - pub fn is_static() {} - pub fn is_not_static(&self) {} + pub fn is_static() {} + pub fn is_not_static(&self) {} } trait t { - fn t_is_static() {} - fn t_is_not_static(&self) {} + fn t_is_static() {} + fn t_is_not_static(&self) {} } impl t for foo { - pub fn is_static() {} - pub fn is_not_static(&self) {} + pub fn is_static() {} + pub fn is_not_static(&self) {} } \ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html index 6ee6d85fbe..638f42c2f0 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html @@ -50,7 +50,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd // KILLER WHALE /// Ishmael."; /// ``` - pub const bar: bool = true; + pub const bar: bool = true; /// Constructs a new `Foo`. /// @@ -60,7 +60,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// # #![allow(unused_mut)] /// let mut foo: Foo = Foo::new(); /// ``` - pub const fn new() -> Foo { + pub const fn new() -> Foo { Foo { bar: true } } @@ -94,15 +94,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// ```sh /// echo 1 /// ``` - pub fn foo(&self) -> bool { + pub fn foo(&self) -> bool { true } } -/// [`Foo`](Foo) is a struct -/// This function is > [`all_the_links`](all_the_links) < +/// [`Foo`](Foo) is a struct +/// This function is > [`all_the_links`](all_the_links) < /// [`noop`](noop) is a macro below -/// [`Item`] is a struct in the module [`module`] +/// [`Item`] is a struct in the module [`module`] /// /// [`Item`]: module::Item /// [mix_and_match]: ThisShouldntResolve diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html index 7c6694a276..6202a03ceb 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html @@ -42,7 +42,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { fixture(r#" trait Foo { - fn foo() { + fn foo() { println!("2 + 2 = {}", 4); } }"# diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html index 72910421dc..68165bdbfd 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html @@ -47,7 +47,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd struct HasUnsafeFn; impl HasUnsafeFn { - unsafe fn unsafe_method(&self) {} + unsafe fn unsafe_method(&self) {} } struct TypeForStaticMut { @@ -62,11 +62,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } trait DoTheAutoref { - fn calls_autoref(&self); + fn calls_autoref(&self); } impl DoTheAutoref for u16 { - fn calls_autoref(&self) {} + fn calls_autoref(&self) {} } fn main() { diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html index c43bcb6911..4319e8b50f 100644 --- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -67,25 +67,25 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } trait Bar { - fn bar(&self) -> i32; + fn bar(&self) -> i32; } impl Bar for Foo { - fn bar(&self) -> i32 { + fn bar(&self) -> i32 { self.x } } impl Foo { - fn baz(mut self, f: Foo) -> i32 { - f.baz(self) + fn baz(mut self, f: Foo) -> i32 { + f.baz(self) } - fn qux(&mut self) { + fn qux(&mut self) { self.x = 0; } - fn quop(&self) -> i32 { + fn quop(&self) -> i32 { self.x } } @@ -96,15 +96,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } impl FooCopy { - fn baz(self, f: FooCopy) -> u32 { + fn baz(self, f: FooCopy) -> u32 { f.baz(self) } - fn qux(&mut self) { + fn qux(&mut self) { self.x = 0; } - fn quop(&self) -> u32 { + fn quop(&self) -> u32 { self.x } } @@ -128,7 +128,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } use ops::Fn; -fn baz<F: Fn() -> ()>(f: F) { +fn baz<F: Fn() -> ()>(f: F) { f() } @@ -199,16 +199,16 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd let mut foo = Foo { x, y: x }; let foo2 = Foo { x, y: x }; foo.quop(); - foo.qux(); - foo.baz(foo2); + foo.qux(); + foo.baz(foo2); let mut copy = FooCopy { x }; copy.quop(); - copy.qux(); + copy.qux(); copy.baz(copy); - let a = |x| x; - let bar = Foo::baz; + let a = |x| x; + let bar = Foo::baz; let baz = -42; let baz = -baz; @@ -228,7 +228,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd use Option::*; impl<T> Option<T> { - fn and<U>(self, other: Option<U>) -> Option<(T, U)> { + fn and<U>(self, other: Option<U>) -> Option<(T, U)> { match other { None => unimplemented!(), Nope => Nope,