From 26bd7a896b4bbc4a2432df47dceff939aac921fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Dec 2019 11:06:50 +0100 Subject: Drop support for legacy colorization --- crates/ra_ide/src/snapshots/highlighting.html | 6 ++--- .../ra_ide/src/snapshots/rainbow_highlighting.html | 6 ++--- crates/ra_ide/src/syntax_highlighting.rs | 27 ++++++++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index a097cf8e8..1d130544f 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -38,12 +38,12 @@ 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 }); + vec.push(Foo { x, y: 1 }); } - unsafe { vec.set_len(0); } + unsafe { vec.set_len(0); } let mut x = 42; let y = &mut x; diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 110556c09..d90ee8540 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -25,11 +25,11 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
fn main() {
     let hello = "hello";
-    let x = hello.to_string();
-    let y = hello.to_string();
+    let x = hello.to_string();
+    let y = hello.to_string();
 
     let x = "other color please!";
-    let y = x.to_string();
+    let y = x.to_string();
 }
 
 fn bar() {
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 0228ee7e9..56a36f587 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -20,13 +20,13 @@ pub mod tags {
     pub(crate) const FIELD: &str = "field";
     pub(crate) const FUNCTION: &str = "function";
     pub(crate) const MODULE: &str = "module";
-    pub(crate) const TYPE: &str = "type";
     pub(crate) const CONSTANT: &str = "constant";
     pub(crate) const MACRO: &str = "macro";
+
     pub(crate) const VARIABLE: &str = "variable";
     pub(crate) const VARIABLE_MUT: &str = "variable.mut";
-    pub(crate) const TEXT: &str = "text";
 
+    pub(crate) const TYPE: &str = "type";
     pub(crate) const TYPE_BUILTIN: &str = "type.builtin";
     pub(crate) const TYPE_SELF: &str = "type.self";
     pub(crate) const TYPE_PARAM: &str = "type.param";
@@ -35,13 +35,14 @@ pub mod tags {
     pub(crate) const LITERAL_BYTE: &str = "literal.byte";
     pub(crate) const LITERAL_NUMERIC: &str = "literal.numeric";
     pub(crate) const LITERAL_CHAR: &str = "literal.char";
+
     pub(crate) const LITERAL_COMMENT: &str = "comment";
     pub(crate) const LITERAL_STRING: &str = "string";
     pub(crate) const LITERAL_ATTRIBUTE: &str = "attribute";
 
+    pub(crate) const KEYWORD: &str = "keyword";
     pub(crate) const KEYWORD_UNSAFE: &str = "keyword.unsafe";
     pub(crate) const KEYWORD_CONTROL: &str = "keyword.control";
-    pub(crate) const KEYWORD: &str = "keyword";
 }
 
 #[derive(Debug)]
@@ -109,15 +110,21 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec {
+                        if let Local(local) = &name_kind {
+                            if let Some(name) = local.name(db) {
+                                let shadow_count =
+                                    bindings_shadow_count.entry(name.clone()).or_default();
+                                binding_hash =
+                                    Some(calc_binding_hash(file_id, &name, *shadow_count))
+                            }
+                        };
 
-                if let Some(Local(local)) = &name_kind {
-                    if let Some(name) = local.name(db) {
-                        let shadow_count = bindings_shadow_count.entry(name.clone()).or_default();
-                        binding_hash = Some(calc_binding_hash(file_id, &name, *shadow_count))
+                        highlight_name(db, name_kind)
                     }
-                };
-
-                name_kind.map_or(tags::TEXT, |it| highlight_name(db, it))
+                    _ => continue,
+                }
             }
             NAME => {
                 let name = node.as_node().cloned().and_then(ast::Name::cast).unwrap();
-- 
cgit v1.2.3