aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/snapshots/highlighting.html4
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs24
2 files changed, 12 insertions, 16 deletions
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html
index af7b4a0d0..b39c4d371 100644
--- a/crates/ra_ide_api/src/snapshots/highlighting.html
+++ b/crates/ra_ide_api/src/snapshots/highlighting.html
@@ -21,8 +21,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
21</style> 21</style>
22<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> 22<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>
23<span class="keyword">struct</span> <span class="type">Foo</span> { 23<span class="keyword">struct</span> <span class="type">Foo</span> {
24 <span class="keyword">pub</span> <span class="function">x</span>: <span class="type">i32</span>, 24 <span class="keyword">pub</span> <span class="field">x</span>: <span class="type">i32</span>,
25 <span class="keyword">pub</span> <span class="function">y</span>: <span class="type">i32</span>, 25 <span class="keyword">pub</span> <span class="field">y</span>: <span class="type">i32</span>,
26} 26}
27 27
28<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">T</span> { 28<span class="keyword">fn</span> <span class="function">foo</span>&lt;<span class="type">T</span>&gt;() -&gt; <span class="type">T</span> {
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 878a94f06..448acffc8 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -158,21 +158,17 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
158 } else { 158 } else {
159 "variable" 159 "variable"
160 } 160 }
161 } else if name
162 .syntax()
163 .parent()
164 .map(|x| {
165 x.kind() == TYPE_PARAM
166 || x.kind() == STRUCT_DEF
167 || x.kind() == ENUM_DEF
168 || x.kind() == TRAIT_DEF
169 || x.kind() == TYPE_ALIAS_DEF
170 })
171 .unwrap_or(false)
172 {
173 "type"
174 } else { 161 } else {
175 "function" 162 name.syntax()
163 .parent()
164 .map(|x| match x.kind() {
165 TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => {
166 "type"
167 }
168 NAMED_FIELD_DEF => "field",
169 _ => "function",
170 })
171 .unwrap_or("function")
176 } 172 }
177 } else { 173 } else {
178 "text" 174 "text"