diff options
author | Laurențiu Nicola <[email protected]> | 2019-05-28 19:27:54 +0100 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2019-05-29 06:30:53 +0100 |
commit | 9146a64386b0ae0c5f680fcca5e0cd08a8844e85 (patch) | |
tree | 584ecc92533e0ee9046a831e4344b50c1becd2b8 /crates/ra_ide_api | |
parent | 0545e4781d3aba3083835cfa8afab07b7442a3aa (diff) |
Highlight type names correctly
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/snapshots/highlighting.html | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html index ebd187a35..2a32b3241 100644 --- a/crates/ra_ide_api/src/snapshots/highlighting.html +++ b/crates/ra_ide_api/src/snapshots/highlighting.html | |||
@@ -18,13 +18,14 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e | |||
18 | .keyword\.control { color: #DC8CC3; } | 18 | .keyword\.control { color: #DC8CC3; } |
19 | </style> | 19 | </style> |
20 | <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> | 20 | <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> |
21 | <span class="keyword">struct</span> <span class="function">Foo</span> { | 21 | <span class="keyword">struct</span> <span class="type">Foo</span> { |
22 | <span class="keyword">pub</span> <span class="function">x</span>: <span class="text">i32</span>, | 22 | <span class="keyword">pub</span> <span class="function">x</span>: <span class="text">i32</span>, |
23 | <span class="keyword">pub</span> <span class="function">y</span>: <span class="text">i32</span>, | 23 | <span class="keyword">pub</span> <span class="function">y</span>: <span class="text">i32</span>, |
24 | } | 24 | } |
25 | 25 | ||
26 | <span class="keyword">fn</span> <span class="function">foo</span><<span class="type function">T</span>>() -> <span class="type">T</span> { | 26 | <span class="keyword">fn</span> <span class="function">foo</span><<span class="type type">T</span>>() -> <span class="type">T</span> { |
27 | <span class="macro">unimplemented</span><span class="macro">!</span>(); | 27 | <span class="macro">unimplemented</span><span class="macro">!</span>(); |
28 | <span class="function">foo</span>::<<span class="type text">i32</span>>(); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | <span class="comment">// comment</span> | 31 | <span class="comment">// comment</span> |
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index dcefb0513..739b898d2 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,6 +1,8 @@ | |||
1 | use rustc_hash::{FxHashSet, FxHashMap}; | 1 | use rustc_hash::{FxHashSet, FxHashMap}; |
2 | 2 | ||
3 | use ra_syntax::{ast, AstNode, TextRange, Direction, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxElement, T}; | 3 | use ra_syntax::{ |
4 | ast, AstNode, TextRange, Direction, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxElement, T, | ||
5 | }; | ||
4 | use ra_db::SourceDatabase; | 6 | use ra_db::SourceDatabase; |
5 | use ra_prof::profile; | 7 | use ra_prof::profile; |
6 | 8 | ||
@@ -116,6 +118,19 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
116 | calc_binding_hash(file_id, &text, *shadow_count) | 118 | calc_binding_hash(file_id, &text, *shadow_count) |
117 | }); | 119 | }); |
118 | "variable" | 120 | "variable" |
121 | } else if name | ||
122 | .syntax() | ||
123 | .parent() | ||
124 | .map(|x| { | ||
125 | x.kind() == TYPE_PARAM | ||
126 | || x.kind() == STRUCT_DEF | ||
127 | || x.kind() == ENUM_DEF | ||
128 | || x.kind() == TRAIT_DEF | ||
129 | || x.kind() == TYPE_ALIAS_DEF | ||
130 | }) | ||
131 | .unwrap_or(false) | ||
132 | { | ||
133 | "type" | ||
119 | } else { | 134 | } else { |
120 | "function" | 135 | "function" |
121 | } | 136 | } |
@@ -263,6 +278,7 @@ struct Foo { | |||
263 | 278 | ||
264 | fn foo<T>() -> T { | 279 | fn foo<T>() -> T { |
265 | unimplemented!(); | 280 | unimplemented!(); |
281 | foo::<i32>(); | ||
266 | } | 282 | } |
267 | 283 | ||
268 | // comment | 284 | // comment |