From 30672c420ee19faa1acc15ecc84ae8d17c309e95 Mon Sep 17 00:00:00 2001
From: Omer Ben-Amram <omerbenamram@gmail.com>
Date: Fri, 13 Dec 2019 19:00:55 +0200
Subject: scopes resolution is more granular

---
 crates/ra_ide/src/syntax_highlighting.rs | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

(limited to 'crates/ra_ide')

diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 7ecb1a027..cd9d8b058 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -108,14 +108,17 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
                 match name_kind {
                     Some(name_kind) => highlight_name(db, name_kind),
                     None => name.syntax().parent().map_or("function", |x| match x.kind() {
-                        TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type",
+                        STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type",
+                        TYPE_PARAM => "type.param",
                         RECORD_FIELD_DEF => "field",
                         _ => "function",
                     }),
                 }
             }
-            INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal",
-            LIFETIME => "parameter",
+            INT_NUMBER | FLOAT_NUMBER => "literal.numeric",
+            BYTE => "literal.byte",
+            CHAR => "literal.char",
+            LIFETIME => "lifetime",
             T![unsafe] => "keyword.unsafe",
             k if is_control_keyword(k) => "keyword.control",
             k if k.is_keyword() => "keyword",
@@ -215,17 +218,18 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
         Field(_) => "field",
         AssocItem(hir::AssocItem::Function(_)) => "function",
         AssocItem(hir::AssocItem::Const(_)) => "constant",
-        AssocItem(hir::AssocItem::TypeAlias(_)) => "type",
+        AssocItem(hir::AssocItem::TypeAlias(_)) => "type.alias",
         Def(hir::ModuleDef::Module(_)) => "module",
         Def(hir::ModuleDef::Function(_)) => "function",
         Def(hir::ModuleDef::Adt(_)) => "type",
         Def(hir::ModuleDef::EnumVariant(_)) => "constant",
         Def(hir::ModuleDef::Const(_)) => "constant",
         Def(hir::ModuleDef::Static(_)) => "constant",
-        Def(hir::ModuleDef::Trait(_)) => "type",
-        Def(hir::ModuleDef::TypeAlias(_)) => "type",
-        Def(hir::ModuleDef::BuiltinType(_)) => "type",
-        SelfType(_) | TypeParam(_) => "type",
+        Def(hir::ModuleDef::Trait(_)) => "type.trait",
+        Def(hir::ModuleDef::TypeAlias(_)) => "type.alias",
+        Def(hir::ModuleDef::BuiltinType(_)) => "type.builtin",
+        SelfType(_) => "type.self",
+        TypeParam(_) => "type.param",
         Local(local) => {
             if local.is_mut(db) {
                 "variable.mut"
-- 
cgit v1.2.3


From 67641d3f5fd1cfd49673c4eea9e3d646ed97e108 Mon Sep 17 00:00:00 2001
From: Omer Ben-Amram <omerbenamram@gmail.com>
Date: Sat, 14 Dec 2019 13:24:07 +0200
Subject: added decorations

---
 crates/ra_ide/src/syntax_highlighting.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'crates/ra_ide')

diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index cd9d8b058..7be25b234 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -225,8 +225,8 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
         Def(hir::ModuleDef::EnumVariant(_)) => "constant",
         Def(hir::ModuleDef::Const(_)) => "constant",
         Def(hir::ModuleDef::Static(_)) => "constant",
-        Def(hir::ModuleDef::Trait(_)) => "type.trait",
-        Def(hir::ModuleDef::TypeAlias(_)) => "type.alias",
+        Def(hir::ModuleDef::Trait(_)) => "type",
+        Def(hir::ModuleDef::TypeAlias(_)) => "type",
         Def(hir::ModuleDef::BuiltinType(_)) => "type.builtin",
         SelfType(_) => "type.self",
         TypeParam(_) => "type.param",
-- 
cgit v1.2.3


From 083010f6339e558184f06ce76a18e1ad0b0ee936 Mon Sep 17 00:00:00 2001
From: Omer Ben-Amram <omerbenamram@gmail.com>
Date: Sat, 14 Dec 2019 13:29:42 +0200
Subject: removed `type.alias`

---
 crates/ra_ide/src/snapshots/highlighting.html | 26 ++++++++++++++------------
 crates/ra_ide/src/syntax_highlighting.rs      |  6 ++++--
 2 files changed, 18 insertions(+), 14 deletions(-)

(limited to 'crates/ra_ide')

diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html
index 4166a8f90..40605d9ef 100644
--- a/crates/ra_ide/src/snapshots/highlighting.html
+++ b/crates/ra_ide/src/snapshots/highlighting.html
@@ -10,8 +10,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .builtin            { color: #DD6718; }
 .text               { color: #DCDCCC; }
 .type               { color: #7CB8BB; }
+.type\.param       { color: #20999D; }
 .attribute          { color: #94BFF3; }
 .literal            { color: #BFEBBF; }
+.literal\.numeric  { color: #6A8759; }
 .macro              { color: #94BFF3; }
 .variable           { color: #DCDCCC; }
 .variable\.mut     { color: #DCDCCC; text-decoration: underline; }
@@ -22,36 +24,36 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 </style>
 <pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span>
 <span class="keyword">struct</span> <span class="type">Foo</span> {
-    <span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
-    <span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>,
+    <span class="keyword">pub</span> <span class="field">x</span>: <span class="type.builtin">i32</span>,
+    <span class="keyword">pub</span> <span class="field">y</span>: <span class="type.builtin">i32</span>,
 }
 
-<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">T</span> {
+<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type.param">T</span>&gt;() -&gt; <span class="type.param">T</span> {
     <span class="macro">unimplemented</span><span class="macro">!</span>();
-    <span class="function">foo</span>::&lt;<span class="type">i32</span>&gt;();
+    <span class="function">foo</span>::&lt;<span class="type.builtin">i32</span>&gt;();
 }
 
 <span class="comment">// comment</span>
 <span class="keyword">fn</span> <span class="function">main</span>() {
-    <span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal">92</span>);
+    <span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal.numeric">92</span>);
 
     <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
     <span class="keyword.control">if</span> <span class="keyword">true</span> {
-        <span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal">0</span>, <span class="field">y</span>: <span class="literal">1</span> });
+        <span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal.numeric">0</span>, <span class="field">y</span>: <span class="literal.numeric">1</span> });
     }
-    <span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
+    <span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal.numeric">0</span>); }
 
-    <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">x</span> = <span class="literal">42</span>;
+    <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">x</span> = <span class="literal.numeric">42</span>;
     <span class="keyword">let</span> <span class="variable.mut">y</span> = &<span class="keyword">mut</span> <span class="variable.mut">x</span>;
     <span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable.mut">y</span>;
 
     <span class="variable.mut">y</span>;
 }
 
-<span class="keyword">enum</span> <span class="type">E</span>&lt;<span class="type">X</span>&gt; {
-    <span class="constant">V</span>(<span class="type">X</span>)
+<span class="keyword">enum</span> <span class="type">E</span>&lt;<span class="type.param">X</span>&gt; {
+    <span class="constant">V</span>(<span class="type.param">X</span>)
 }
 
-<span class="keyword">impl</span>&lt;<span class="type">X</span>&gt; <span class="type">E</span>&lt;<span class="type">X</span>&gt; {
-    <span class="keyword">fn</span> <span class="function">new</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">E</span>&lt;<span class="type">T</span>&gt; {}
+<span class="keyword">impl</span>&lt;<span class="type.param">X</span>&gt; <span class="type">E</span>&lt;<span class="type.param">X</span>&gt; {
+    <span class="keyword">fn</span> <span class="function">new</span>&lt;<span class="type.param">T</span>&gt;() -&gt; <span class="type">E</span>&lt;<span class="type.param">T</span>&gt; {}
 }</code></pre>
\ No newline at end of file
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 7be25b234..235e09ffc 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -118,7 +118,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
             INT_NUMBER | FLOAT_NUMBER => "literal.numeric",
             BYTE => "literal.byte",
             CHAR => "literal.char",
-            LIFETIME => "lifetime",
+            LIFETIME => "type.lifetime",
             T![unsafe] => "keyword.unsafe",
             k if is_control_keyword(k) => "keyword.control",
             k if k.is_keyword() => "keyword",
@@ -218,7 +218,7 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
         Field(_) => "field",
         AssocItem(hir::AssocItem::Function(_)) => "function",
         AssocItem(hir::AssocItem::Const(_)) => "constant",
-        AssocItem(hir::AssocItem::TypeAlias(_)) => "type.alias",
+        AssocItem(hir::AssocItem::TypeAlias(_)) => "type",
         Def(hir::ModuleDef::Module(_)) => "module",
         Def(hir::ModuleDef::Function(_)) => "function",
         Def(hir::ModuleDef::Adt(_)) => "type",
@@ -259,8 +259,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .builtin            { color: #DD6718; }
 .text               { color: #DCDCCC; }
 .type               { color: #7CB8BB; }
+.type\\.param       { color: #20999D; }
 .attribute          { color: #94BFF3; }
 .literal            { color: #BFEBBF; }
+.literal\\.numeric  { color: #6A8759; }
 .macro              { color: #94BFF3; }
 .variable           { color: #DCDCCC; }
 .variable\\.mut     { color: #DCDCCC; text-decoration: underline; }
-- 
cgit v1.2.3


From feb5a4a8b8b0a30d71cf34c7927bd41cbae4e104 Mon Sep 17 00:00:00 2001
From: Omer Ben-Amram <omerbenamram@gmail.com>
Date: Sun, 15 Dec 2019 10:20:22 +0200
Subject: fixed rainbow-highlighting test

---
 crates/ra_ide/src/snapshots/rainbow_highlighting.html | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'crates/ra_ide')

diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
index 9dfbc8047..ecf26c708 100644
--- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html
+++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
@@ -10,8 +10,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 .builtin            { color: #DD6718; }
 .text               { color: #DCDCCC; }
 .type               { color: #7CB8BB; }
+.type\.param       { color: #20999D; }
 .attribute          { color: #94BFF3; }
 .literal            { color: #BFEBBF; }
+.literal\.numeric  { color: #6A8759; }
 .macro              { color: #94BFF3; }
 .variable           { color: #DCDCCC; }
 .variable\.mut     { color: #DCDCCC; text-decoration: underline; }
-- 
cgit v1.2.3