From 54ebb2ce301813a9b5b48d5abe97ace370cfa617 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 11:21:40 -0300 Subject: Handle semantic highlight when STAR is part of the `*{const, mut}` --- crates/ra_ide/test_data/highlight_doctest.html | 14 +++++----- crates/ra_ide/test_data/highlight_injection.html | 2 +- crates/ra_ide/test_data/highlight_strings.html | 6 ++--- crates/ra_ide/test_data/highlight_unsafe.html | 6 ++--- crates/ra_ide/test_data/highlighting.html | 34 ++++++++++++------------ 5 files changed, 31 insertions(+), 31 deletions(-) (limited to 'crates/ra_ide/test_data') diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 1cc17d6d0..e79e89807 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -51,9 +51,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// /// ``` /// # #![allow(unused_mut)] - /// let mut foo: Foo = Foo::new(); + /// let mut foo: Foo = Foo::new(); /// ``` - pub const fn new() -> Foo { + pub const fn new() -> Foo { Foo { bar: true } } @@ -62,14 +62,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// # Examples /// /// ``` - /// use x::y; + /// use x::y; /// - /// let foo = Foo::new(); + /// let foo = Foo::new(); /// /// // calls bar on foo /// assert!(foo.bar()); /// - /// let bar = foo.bar || Foo::bar; + /// let bar = foo.bar || Foo::bar; /// /// /* multi-line /// comment */ @@ -81,13 +81,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// ``` /// /// ```rust,no_run - /// let foobar = Foo::new().bar(); + /// let foobar = Foo::new().bar(); /// ``` /// /// ```sh /// echo 1 /// ``` - pub fn foo(&self) -> bool { + pub fn foo(&self) -> bool { true } } diff --git a/crates/ra_ide/test_data/highlight_injection.html b/crates/ra_ide/test_data/highlight_injection.html index 461cfc437..18addd00d 100644 --- a/crates/ra_ide/test_data/highlight_injection.html +++ b/crates/ra_ide/test_data/highlight_injection.html @@ -35,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
fn fixture(ra_fixture: &str) {}
+
fn fixture(ra_fixture: &str) {}
 
 fn main() {
     fixture(r#"
diff --git a/crates/ra_ide/test_data/highlight_strings.html b/crates/ra_ide/test_data/highlight_strings.html
index 9f98e73e7..258bd404b 100644
--- a/crates/ra_ide/test_data/highlight_strings.html
+++ b/crates/ra_ide/test_data/highlight_strings.html
@@ -36,14 +36,14 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
 
 
macro_rules! println {
-    ($($arg:tt)*) => ({
-        $crate::io::_print($crate::format_args_nl!($($arg)*));
+    ($($arg:tt)*) => ({
+        $crate::io::_print($crate::format_args_nl!($($arg)*));
     })
 }
 #[rustc_builtin_macro]
 macro_rules! format_args_nl {
     ($fmt:expr) => {{ /* compiler built-in */ }};
-    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
 }
 
 fn main() {
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index 88ac91f9a..6c210bfa8 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -40,15 +40,15 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 struct HasUnsafeFn;
 
 impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
+    unsafe fn unsafe_method(&self) {}
 }
 
 fn main() {
-    let x = &5 as *const usize;
+    let x = &5 as *const usize;
     unsafe {
         unsafe_fn();
         HasUnsafeFn.unsafe_method();
         let y = *(x);
-        let z = -x;
+        let z = -x;
     }
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index 767e82f9d..c49645b0d 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -42,37 +42,37 @@ 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) -> i32 { + fn baz(mut self) -> i32 { self.x } - fn qux(&mut self) { - self.x = 0; + fn qux(&mut self) { + self.x = 0; } } static mut STATIC_MUT: i32 = 0; -fn foo<'a, T>() -> T { - foo::<'a, i32>() +fn foo<'a, T>() -> T { + foo::<'a, i32>() } macro_rules! def_fn { - ($($tt:tt)*) => {$($tt)*} + ($($tt:tt)*) => {$($tt)*} } def_fn! { - fn bar() -> u32 { + fn bar() -> u32 { 100 } } @@ -87,14 +87,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { println!("Hello, {}!", 92); - let mut vec = Vec::new(); + let mut vec = Vec::new(); if true { let x = 92; vec.push(Foo { x, y: 1 }); } unsafe { vec.set_len(0); - STATIC_MUT = 1; + STATIC_MUT = 1; } for e in vec { @@ -104,8 +104,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd noop!(noop!(1)); let mut x = 42; - let y = &mut x; - let z = &y; + let y = &mut x; + let z = &y; let Foo { x: z, y } = Foo { x: z, y }; @@ -116,13 +116,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd Some(T), None, } -use Option::*; +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, + None => unimplemented!(), + Nope => Nope, } } }
\ No newline at end of file -- cgit v1.2.3 From a662228de41a8b35d61b2bd312d30d34623e2232 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 12:36:23 -0300 Subject: Assingment semantic highlight --- crates/ra_ide/test_data/highlight_doctest.html | 16 ++++++------- crates/ra_ide/test_data/highlight_strings.html | 28 +++++++++++------------ crates/ra_ide/test_data/highlight_unsafe.html | 6 ++--- crates/ra_ide/test_data/highlighting.html | 18 +++++++-------- crates/ra_ide/test_data/rainbow_highlighting.html | 12 +++++----- 5 files changed, 40 insertions(+), 40 deletions(-) (limited to 'crates/ra_ide/test_data') diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index e79e89807..10cb9b20b 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
/// ```
-/// let _ = "early doctests should not go boom";
+/// let _ = "early doctests should not go boom";
 /// ```
 struct Foo {
     bar: bool,
 }
 
 impl Foo {
-    pub const bar: bool = true;
+    pub const bar: bool = true;
 
     /// Constructs a new `Foo`.
     ///
@@ -51,7 +51,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     ///
     /// ```
     /// # #![allow(unused_mut)]
-    /// let mut foo: Foo = Foo::new();
+    /// let mut foo: Foo = Foo::new();
     /// ```
     pub const fn new() -> Foo {
         Foo { bar: true }
@@ -64,24 +64,24 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     /// ```
     /// use x::y;
     ///
-    /// let foo = Foo::new();
+    /// let foo = Foo::new();
     ///
     /// // calls bar on foo
     /// assert!(foo.bar());
     ///
-    /// let bar = foo.bar || Foo::bar;
+    /// let bar = foo.bar || Foo::bar;
     ///
     /// /* multi-line
     ///        comment */
     ///
-    /// let multi_line_string = "Foo
+    /// let multi_line_string = "Foo
     ///   bar
     ///          ";
     ///
     /// ```
     ///
     /// ```rust,no_run
-    /// let foobar = Foo::new().bar();
+    /// let foobar = Foo::new().bar();
     /// ```
     ///
     /// ```sh
@@ -96,7 +96,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 /// noop!(1);
 /// ```
 macro_rules! noop {
-    ($expr:expr) => {
+    ($expr:expr) => {
         $expr
     }
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlight_strings.html b/crates/ra_ide/test_data/highlight_strings.html index 258bd404b..1b681b2c6 100644 --- a/crates/ra_ide/test_data/highlight_strings.html +++ b/crates/ra_ide/test_data/highlight_strings.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
macro_rules! println {
-    ($($arg:tt)*) => ({
+    ($($arg:tt)*) => ({
         $crate::io::_print($crate::format_args_nl!($($arg)*));
     })
 }
 #[rustc_builtin_macro]
 macro_rules! format_args_nl {
-    ($fmt:expr) => {{ /* compiler built-in */ }};
-    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+    ($fmt:expr) => {{ /* compiler built-in */ }};
+    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
 }
 
 fn main() {
@@ -52,18 +52,18 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello, {}!", "world");   // => "Hello, world!"
     println!("The number is {}", 1);   // => "The number is 1"
     println!("{:?}", (3, 4));          // => "(3, 4)"
-    println!("{value}", value=4);      // => "4"
+    println!("{value}", value=4);      // => "4"
     println!("{} {}", 1, 2);           // => "1 2"
     println!("{:04}", 42);             // => "0042" with leading zerosV
     println!("{1} {} {0} {}", 1, 2);   // => "2 1 1 2"
-    println!("{argument}", argument = "test");   // => "test"
-    println!("{name} {}", 1, name = 2);          // => "2 1"
-    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
+    println!("{argument}", argument = "test");   // => "test"
+    println!("{name} {}", 1, name = 2);          // => "2 1"
+    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
     println!("{{{}}}", 2);                       // => "{2}"
     println!("Hello {:5}!", "x");
     println!("Hello {:1$}!", "x", 5);
     println!("Hello {1:0$}!", 5, "x");
-    println!("Hello {:width$}!", "x", width = 5);
+    println!("Hello {:width$}!", "x", width = 5);
     println!("Hello {:<5}!", "x");
     println!("Hello {:-<5}!", "x");
     println!("Hello {:^5}!", "x");
@@ -78,10 +78,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
     println!("Hello {} is {:.*}",    "x", 5, 0.01);
     println!("Hello {} is {2:.*}",   "x", 5, 0.01);
-    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
-    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
-    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
-    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
+    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
+    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
+    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
+    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
     println!("Hello {{}}");
     println!("{{ Hello");
 
@@ -91,6 +91,6 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     println!("Hello\nWorld");
     println!("\u{48}\x65\x6C\x6C\x6F World");
 
-    println!("{\x41}", A = 92);
-    println!("{ничоси}", ничоси = 92);
+    println!("{\x41}", A = 92);
+    println!("{ничоси}", ничоси = 92);
 }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html index 6c210bfa8..b81b6f1c3 100644 --- a/crates/ra_ide/test_data/highlight_unsafe.html +++ b/crates/ra_ide/test_data/highlight_unsafe.html @@ -44,11 +44,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } fn main() { - let x = &5 as *const usize; + let x = &5 as *const usize; unsafe { unsafe_fn(); HasUnsafeFn.unsafe_method(); - let y = *(x); - let z = -x; + let y = *(x); + let z = -x; } }
\ No newline at end of file diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index c49645b0d..d72efa04a 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -61,14 +61,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } } -static mut STATIC_MUT: i32 = 0; +static mut STATIC_MUT: i32 = 0; fn foo<'a, T>() -> T { foo::<'a, i32>() } macro_rules! def_fn { - ($($tt:tt)*) => {$($tt)*} + ($($tt:tt)*) => {$($tt)*} } def_fn! { @@ -78,7 +78,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd } macro_rules! noop { - ($expr:expr) => { + ($expr:expr) => { $expr } } @@ -87,9 +87,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd fn main() { println!("Hello, {}!", 92); - let mut vec = Vec::new(); + let mut vec = Vec::new(); if true { - let x = 92; + let x = 92; vec.push(Foo { x, y: 1 }); } unsafe { @@ -103,11 +103,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd noop!(noop!(1)); - let mut x = 42; - let y = &mut x; - let z = &y; + let mut x = 42; + let y = &mut x; + let z = &y; - let Foo { x: z, y } = Foo { x: z, y }; + let Foo { x: z, y } = Foo { x: z, y }; y; } diff --git a/crates/ra_ide/test_data/rainbow_highlighting.html b/crates/ra_ide/test_data/rainbow_highlighting.html index 2fed04a44..08d83302c 100644 --- a/crates/ra_ide/test_data/rainbow_highlighting.html +++ b/crates/ra_ide/test_data/rainbow_highlighting.html @@ -36,14 +36,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
fn main() {
-    let hello = "hello";
-    let x = hello.to_string();
-    let y = hello.to_string();
+    let hello = "hello";
+    let x = hello.to_string();
+    let y = hello.to_string();
 
-    let x = "other color please!";
-    let y = x.to_string();
+    let x = "other color please!";
+    let y = x.to_string();
 }
 
 fn bar() {
-    let mut hello = "hello";
+    let mut hello = "hello";
 }
\ No newline at end of file -- cgit v1.2.3 From 04d8dc4a10be5e0c6a852011c98284f0121f3293 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Mon, 20 Jul 2020 23:19:29 -0300 Subject: `#` as Attribute - Issue #5453 --- crates/ra_ide/test_data/highlight_doctest.html | 2 +- crates/ra_ide/test_data/highlighting.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/test_data') diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 10cb9b20b..78c2a30c3 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -50,7 +50,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// # Examples /// /// ``` - /// # #![allow(unused_mut)] + /// # #![allow(unused_mut)] /// let mut foo: Foo = Foo::new(); /// ``` pub const fn new() -> Foo { diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html index d72efa04a..182a3817a 100644 --- a/crates/ra_ide/test_data/highlighting.html +++ b/crates/ra_ide/test_data/highlighting.html @@ -35,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
#[derive(Clone, Debug)]
+
#[derive(Clone, Debug)]
 struct Foo {
     pub x: i32,
     pub y: i32,
-- 
cgit v1.2.3


From 5ca3855c06b6e28aaa99f5fdda41b6b80ed871b7 Mon Sep 17 00:00:00 2001
From: GrayJack 
Date: Mon, 20 Jul 2020 23:37:31 -0300
Subject: On second thought, we want to preserve the textMate here where all
 punctuation that are from a Attr be highlited as Attribute

---
 crates/ra_ide/test_data/highlight_doctest.html | 2 +-
 crates/ra_ide/test_data/highlighting.html      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'crates/ra_ide/test_data')

diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html
index 78c2a30c3..6322d404f 100644
--- a/crates/ra_ide/test_data/highlight_doctest.html
+++ b/crates/ra_ide/test_data/highlight_doctest.html
@@ -50,7 +50,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     /// # Examples
     ///
     /// ```
-    /// # #![allow(unused_mut)]
+    /// # #![allow(unused_mut)]
     /// let mut foo: Foo = Foo::new();
     /// ```
     pub const fn new() -> Foo {
diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html
index 182a3817a..345a2f023 100644
--- a/crates/ra_ide/test_data/highlighting.html
+++ b/crates/ra_ide/test_data/highlighting.html
@@ -35,7 +35,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
 
-
#[derive(Clone, Debug)]
+
#[derive(Clone, Debug)]
 struct Foo {
     pub x: i32,
     pub y: i32,
-- 
cgit v1.2.3