diff options
-rw-r--r-- | crates/ra_ide/src/snapshots/highlight_doctest.html | 32 | ||||
-rw-r--r-- | crates/ra_ide/src/snapshots/highlight_injection.html | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/snapshots/highlight_strings.html | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/snapshots/highlight_unsafe.html | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/snapshots/highlighting.html | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/snapshots/rainbow_highlighting.html | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting.rs | 64 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/html.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/injection.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/semantic_tokens.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 2 |
12 files changed, 92 insertions, 39 deletions
diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html index ac546806e..e8155def7 100644 --- a/crates/ra_ide/src/snapshots/highlight_doctest.html +++ b/crates/ra_ide/src/snapshots/highlight_doctest.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
@@ -33,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
33 | .control { font-style: italic; } | 35 | .control { font-style: italic; } |
34 | </style> | 36 | </style> |
35 | <pre><code><span class="comment documentation">/// ```</span> | 37 | <pre><code><span class="comment documentation">/// ```</span> |
36 | <span class="comment documentation">/// </span><span class="keyword">let</span> _ = <span class="string_literal">"early doctests should not go boom"</span>; | 38 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> _ = </span><span class="string_literal injected">"early doctests should not go boom"</span><span class="generic injected">;</span> |
37 | <span class="comment documentation">/// ```</span> | 39 | <span class="comment documentation">/// ```</span> |
38 | <span class="keyword">struct</span> <span class="struct declaration">Foo</span> { | 40 | <span class="keyword">struct</span> <span class="struct declaration">Foo</span> { |
39 | <span class="field declaration">bar</span>: <span class="builtin_type">bool</span>, | 41 | <span class="field declaration">bar</span>: <span class="builtin_type">bool</span>, |
@@ -47,8 +49,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
47 | <span class="comment documentation">/// # Examples</span> | 49 | <span class="comment documentation">/// # Examples</span> |
48 | <span class="comment documentation">///</span> | 50 | <span class="comment documentation">///</span> |
49 | <span class="comment documentation">/// ```</span> | 51 | <span class="comment documentation">/// ```</span> |
50 | <span class="comment documentation">/// #</span> <span class="attribute">#![</span><span class="function attribute">allow</span><span class="attribute">(unused_mut)]</span> | 52 | <span class="comment documentation">/// #</span><span class="generic injected"> </span><span class="attribute injected">#![</span><span class="function attribute injected">allow</span><span class="attribute injected">(unused_mut)]</span> |
51 | <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span>: <span class="struct">Foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>(); | 53 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="keyword injected">mut</span><span class="generic injected"> </span><span class="variable declaration injected mutable">foo</span><span class="generic injected">: </span><span class="struct injected">Foo</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">();</span> |
52 | <span class="comment documentation">/// ```</span> | 54 | <span class="comment documentation">/// ```</span> |
53 | <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -> <span class="struct">Foo</span> { | 55 | <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -> <span class="struct">Foo</span> { |
54 | <span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> } | 56 | <span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> } |
@@ -59,26 +61,26 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
59 | <span class="comment documentation">/// # Examples</span> | 61 | <span class="comment documentation">/// # Examples</span> |
60 | <span class="comment documentation">///</span> | 62 | <span class="comment documentation">///</span> |
61 | <span class="comment documentation">/// ```</span> | 63 | <span class="comment documentation">/// ```</span> |
62 | <span class="comment documentation">/// </span><span class="keyword">use</span> <span class="module">x</span>::<span class="module">y</span>; | 64 | <span class="comment documentation">/// </span><span class="keyword injected">use</span><span class="generic injected"> </span><span class="module injected">x</span><span class="generic injected">::</span><span class="module injected">y</span><span class="generic injected">;</span> |
63 | <span class="comment documentation">///</span> | 65 | <span class="comment documentation">///</span> |
64 | <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>(); | 66 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foo</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">();</span> |
65 | <span class="comment documentation">///</span> | 67 | <span class="comment documentation">///</span> |
66 | <span class="comment documentation">/// </span><span class="comment">// calls bar on foo</span> | 68 | <span class="comment documentation">/// </span><span class="comment injected">// calls bar on foo</span> |
67 | <span class="comment documentation">/// </span><span class="macro">assert!</span>(foo.bar()); | 69 | <span class="comment documentation">/// </span><span class="macro injected">assert!</span><span class="generic injected">(foo.bar());</span> |
68 | <span class="comment documentation">///</span> | 70 | <span class="comment documentation">///</span> |
69 | <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">bar</span> = <span class="variable">foo</span>.<span class="field">bar</span> || <span class="struct">Foo</span>::<span class="constant">bar</span>; | 71 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">bar</span><span class="generic injected"> = </span><span class="variable injected">foo</span><span class="generic injected">.</span><span class="field injected">bar</span><span class="generic injected"> || </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="constant injected">bar</span><span class="generic injected">;</span> |
70 | <span class="comment documentation">///</span> | 72 | <span class="comment documentation">///</span> |
71 | <span class="comment documentation">/// </span><span class="comment">/* multi-line | 73 | <span class="comment documentation">/// </span><span class="comment injected">/* multi-line |
72 | </span><span class="comment documentation">/// </span><span class="comment"> comment */</span> | 74 | </span><span class="comment documentation">/// </span><span class="comment injected"> comment */</span> |
73 | <span class="comment documentation">///</span> | 75 | <span class="comment documentation">///</span> |
74 | <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">multi_line_string</span> = <span class="string_literal">"Foo | 76 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">multi_line_string</span><span class="generic injected"> = </span><span class="string_literal injected">"Foo |
75 | </span><span class="comment documentation">/// </span><span class="string_literal"> bar | 77 | </span><span class="comment documentation">/// </span><span class="string_literal injected"> bar |
76 | </span><span class="comment documentation">/// </span><span class="string_literal"> "</span>; | 78 | </span><span class="comment documentation">/// </span><span class="string_literal injected"> "</span><span class="generic injected">;</span> |
77 | <span class="comment documentation">///</span> | 79 | <span class="comment documentation">///</span> |
78 | <span class="comment documentation">/// ```</span> | 80 | <span class="comment documentation">/// ```</span> |
79 | <span class="comment documentation">///</span> | 81 | <span class="comment documentation">///</span> |
80 | <span class="comment documentation">/// ```rust,no_run</span> | 82 | <span class="comment documentation">/// ```rust,no_run</span> |
81 | <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">foobar</span> = <span class="struct">Foo</span>::<span class="function">new</span>().<span class="function">bar</span>(); | 83 | <span class="comment documentation">/// </span><span class="keyword injected">let</span><span class="generic injected"> </span><span class="variable declaration injected">foobar</span><span class="generic injected"> = </span><span class="struct injected">Foo</span><span class="generic injected">::</span><span class="function injected">new</span><span class="generic injected">().</span><span class="function injected">bar</span><span class="generic injected">();</span> |
82 | <span class="comment documentation">/// ```</span> | 84 | <span class="comment documentation">/// ```</span> |
83 | <span class="comment documentation">///</span> | 85 | <span class="comment documentation">///</span> |
84 | <span class="comment documentation">/// ```sh</span> | 86 | <span class="comment documentation">/// ```sh</span> |
@@ -90,7 +92,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
90 | } | 92 | } |
91 | 93 | ||
92 | <span class="comment documentation">/// ```</span> | 94 | <span class="comment documentation">/// ```</span> |
93 | <span class="comment documentation">/// </span><span class="macro">noop!</span>(<span class="numeric_literal">1</span>); | 95 | <span class="comment documentation">/// </span><span class="macro injected">noop!</span><span class="generic injected">(</span><span class="numeric_literal injected">1</span><span class="generic injected">);</span> |
94 | <span class="comment documentation">/// ```</span> | 96 | <span class="comment documentation">/// ```</span> |
95 | <span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> { | 97 | <span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> { |
96 | ($expr:expr) => { | 98 | ($expr:expr) => { |
diff --git a/crates/ra_ide/src/snapshots/highlight_injection.html b/crates/ra_ide/src/snapshots/highlight_injection.html index 47dbd7bc8..1b0349bae 100644 --- a/crates/ra_ide/src/snapshots/highlight_injection.html +++ b/crates/ra_ide/src/snapshots/highlight_injection.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/snapshots/highlight_strings.html b/crates/ra_ide/src/snapshots/highlight_strings.html index b46fa44c6..d184b5691 100644 --- a/crates/ra_ide/src/snapshots/highlight_strings.html +++ b/crates/ra_ide/src/snapshots/highlight_strings.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/snapshots/highlight_unsafe.html b/crates/ra_ide/src/snapshots/highlight_unsafe.html index 73438fbb4..6936e949f 100644 --- a/crates/ra_ide/src/snapshots/highlight_unsafe.html +++ b/crates/ra_ide/src/snapshots/highlight_unsafe.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 0c4f0a018..8d0b38f95 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index a74a70069..9516c7441 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html | |||
@@ -5,6 +5,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
5 | 5 | ||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | 6 | .lifetime { color: #DFAF8F; font-style: italic; } |
7 | .comment { color: #7F9F7F; } | 7 | .comment { color: #7F9F7F; } |
8 | .documentation { color: #629755; } | ||
9 | .injected { opacity: 0.65 ; } | ||
8 | .struct, .enum { color: #7CB8BB; } | 10 | .struct, .enum { color: #7CB8BB; } |
9 | .enum_variant { color: #BDE0F3; } | 11 | .enum_variant { color: #BDE0F3; } |
10 | .string_literal { color: #CC9393; } | 12 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 448645bdc..028b55902 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -236,7 +236,7 @@ pub(crate) fn highlight( | |||
236 | }); | 236 | }); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | stack.pop_and_inject(false); | 239 | stack.pop_and_inject(None); |
240 | } | 240 | } |
241 | } else if let Some(string) = | 241 | } else if let Some(string) = |
242 | element_to_highlight.as_token().cloned().and_then(ast::RawString::cast) | 242 | element_to_highlight.as_token().cloned().and_then(ast::RawString::cast) |
@@ -324,16 +324,27 @@ impl HighlightedRangeStack { | |||
324 | cloned | 324 | cloned |
325 | } | 325 | } |
326 | 326 | ||
327 | /// Remove the `HighlightRange` of `parent` that's currently covered by `child`. | ||
328 | fn intersect_partial(parent: &mut HighlightedRange, child: &HighlightedRange) { | ||
329 | assert!( | ||
330 | parent.range.start() <= child.range.start() | ||
331 | && parent.range.end() >= child.range.start() | ||
332 | && child.range.end() > parent.range.end() | ||
333 | ); | ||
334 | |||
335 | parent.range = TextRange::new(parent.range.start(), child.range.start()); | ||
336 | } | ||
337 | |||
327 | /// Similar to `pop`, but can modify arbitrary prior ranges (where `pop`) | 338 | /// Similar to `pop`, but can modify arbitrary prior ranges (where `pop`) |
328 | /// can only modify the last range currently on the stack. | 339 | /// can only modify the last range currently on the stack. |
329 | /// Can be used to do injections that span multiple ranges, like the | 340 | /// Can be used to do injections that span multiple ranges, like the |
330 | /// doctest injection below. | 341 | /// doctest injection below. |
331 | /// If `delete` is set to true, the parent range is deleted instead of | 342 | /// If `overwrite_parent` is non-optional, the highlighting of the parent range |
332 | /// intersected. | 343 | /// is overwritten with the argument. |
333 | /// | 344 | /// |
334 | /// Note that `pop` can be simulated by `pop_and_inject(false)` but the | 345 | /// Note that `pop` can be simulated by `pop_and_inject(false)` but the |
335 | /// latter is computationally more expensive. | 346 | /// latter is computationally more expensive. |
336 | fn pop_and_inject(&mut self, delete: bool) { | 347 | fn pop_and_inject(&mut self, overwrite_parent: Option<Highlight>) { |
337 | let mut children = self.stack.pop().unwrap(); | 348 | let mut children = self.stack.pop().unwrap(); |
338 | let prev = self.stack.last_mut().unwrap(); | 349 | let prev = self.stack.last_mut().unwrap(); |
339 | children.sort_by_key(|range| range.range.start()); | 350 | children.sort_by_key(|range| range.range.start()); |
@@ -343,26 +354,45 @@ impl HighlightedRangeStack { | |||
343 | if let Some(idx) = | 354 | if let Some(idx) = |
344 | prev.iter().position(|parent| parent.range.contains_range(child.range)) | 355 | prev.iter().position(|parent| parent.range.contains_range(child.range)) |
345 | { | 356 | { |
357 | if let Some(tag) = overwrite_parent { | ||
358 | prev[idx].highlight = tag; | ||
359 | } | ||
360 | |||
346 | let cloned = Self::intersect(&mut prev[idx], &child); | 361 | let cloned = Self::intersect(&mut prev[idx], &child); |
347 | let insert_idx = if delete || prev[idx].range.is_empty() { | 362 | let insert_idx = if prev[idx].range.is_empty() { |
348 | prev.remove(idx); | 363 | prev.remove(idx); |
349 | idx | 364 | idx |
350 | } else { | 365 | } else { |
351 | idx + 1 | 366 | idx + 1 |
352 | }; | 367 | }; |
353 | prev.insert(insert_idx, child); | 368 | prev.insert(insert_idx, child); |
354 | if !delete && !cloned.range.is_empty() { | 369 | if !cloned.range.is_empty() { |
355 | prev.insert(insert_idx + 1, cloned); | 370 | prev.insert(insert_idx + 1, cloned); |
356 | } | 371 | } |
357 | } else if let Some(_idx) = | ||
358 | prev.iter().position(|parent| parent.range.contains(child.range.start())) | ||
359 | { | ||
360 | unreachable!("child range should be completely contained in parent range"); | ||
361 | } else { | 372 | } else { |
362 | let idx = prev | 373 | let maybe_idx = |
363 | .binary_search_by_key(&child.range.start(), |range| range.range.start()) | 374 | prev.iter().position(|parent| parent.range.contains(child.range.start())); |
364 | .unwrap_or_else(|x| x); | 375 | match (overwrite_parent, maybe_idx) { |
365 | prev.insert(idx, child); | 376 | (Some(_), Some(idx)) => { |
377 | Self::intersect_partial(&mut prev[idx], &child); | ||
378 | let insert_idx = if prev[idx].range.is_empty() { | ||
379 | prev.remove(idx); | ||
380 | idx | ||
381 | } else { | ||
382 | idx + 1 | ||
383 | }; | ||
384 | prev.insert(insert_idx, child); | ||
385 | } | ||
386 | (_, None) => { | ||
387 | let idx = prev | ||
388 | .binary_search_by_key(&child.range.start(), |range| range.range.start()) | ||
389 | .unwrap_or_else(|x| x); | ||
390 | prev.insert(idx, child); | ||
391 | } | ||
392 | _ => { | ||
393 | unreachable!("child range should be completely contained in parent range"); | ||
394 | } | ||
395 | } | ||
366 | } | 396 | } |
367 | } | 397 | } |
368 | } | 398 | } |
@@ -516,11 +546,9 @@ fn highlight_element( | |||
516 | let ty = sema.type_of_expr(&expr)?; | 546 | let ty = sema.type_of_expr(&expr)?; |
517 | if !ty.is_raw_ptr() { | 547 | if !ty.is_raw_ptr() { |
518 | return None; | 548 | return None; |
549 | } else { | ||
550 | HighlightTag::Operator | HighlightModifier::Unsafe | ||
519 | } | 551 | } |
520 | |||
521 | let mut h = Highlight::new(HighlightTag::Operator); | ||
522 | h |= HighlightModifier::Unsafe; | ||
523 | h | ||
524 | } | 552 | } |
525 | T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { | 553 | T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => { |
526 | Highlight::new(HighlightTag::Macro) | 554 | Highlight::new(HighlightTag::Macro) |
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 99b6b25ab..0c74f7370 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs | |||
@@ -64,6 +64,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
64 | 64 | ||
65 | .lifetime { color: #DFAF8F; font-style: italic; } | 65 | .lifetime { color: #DFAF8F; font-style: italic; } |
66 | .comment { color: #7F9F7F; } | 66 | .comment { color: #7F9F7F; } |
67 | .documentation { color: #629755; } | ||
68 | .injected { opacity: 0.65 ; } | ||
67 | .struct, .enum { color: #7CB8BB; } | 69 | .struct, .enum { color: #7CB8BB; } |
68 | .enum_variant { color: #BDE0F3; } | 70 | .enum_variant { color: #BDE0F3; } |
69 | .string_literal { color: #CC9393; } | 71 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 9d82b4009..181c21256 100644 --- a/crates/ra_ide/src/syntax_highlighting/injection.rs +++ b/crates/ra_ide/src/syntax_highlighting/injection.rs | |||
@@ -8,8 +8,8 @@ use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; | |||
8 | use stdx::SepBy; | 8 | use stdx::SepBy; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | call_info::ActiveParameter, Analysis, HighlightModifier, HighlightTag, HighlightedRange, | 11 | call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, |
12 | RootDatabase, | 12 | HighlightedRange, RootDatabase, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | use super::HighlightedRangeStack; | 15 | use super::HighlightedRangeStack; |
@@ -172,6 +172,7 @@ pub(super) fn highlight_doc_comment( | |||
172 | h.range.end() + end_offset.unwrap_or(start_offset) - h.range.start(), | 172 | h.range.end() + end_offset.unwrap_or(start_offset) - h.range.start(), |
173 | ); | 173 | ); |
174 | 174 | ||
175 | h.highlight |= HighlightModifier::Injected; | ||
175 | stack.add(h); | 176 | stack.add(h); |
176 | } | 177 | } |
177 | } | 178 | } |
@@ -181,6 +182,7 @@ pub(super) fn highlight_doc_comment( | |||
181 | for comment in new_comments { | 182 | for comment in new_comments { |
182 | stack.add(comment); | 183 | stack.add(comment); |
183 | } | 184 | } |
184 | stack.pop_and_inject(false); | 185 | stack.pop_and_inject(None); |
185 | stack.pop_and_inject(true); | 186 | stack |
187 | .pop_and_inject(Some(Highlight::from(HighlightTag::Generic) | HighlightModifier::Injected)); | ||
186 | } | 188 | } |
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 93bbb4b4d..e8e251cfc 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs | |||
@@ -27,6 +27,7 @@ pub enum HighlightTag { | |||
27 | Field, | 27 | Field, |
28 | FormatSpecifier, | 28 | FormatSpecifier, |
29 | Function, | 29 | Function, |
30 | Generic, | ||
30 | Keyword, | 31 | Keyword, |
31 | Lifetime, | 32 | Lifetime, |
32 | Macro, | 33 | Macro, |
@@ -57,6 +58,7 @@ pub enum HighlightModifier { | |||
57 | /// not. | 58 | /// not. |
58 | Definition, | 59 | Definition, |
59 | Documentation, | 60 | Documentation, |
61 | Injected, | ||
60 | Mutable, | 62 | Mutable, |
61 | Unsafe, | 63 | Unsafe, |
62 | } | 64 | } |
@@ -77,6 +79,7 @@ impl HighlightTag { | |||
77 | HighlightTag::Field => "field", | 79 | HighlightTag::Field => "field", |
78 | HighlightTag::FormatSpecifier => "format_specifier", | 80 | HighlightTag::FormatSpecifier => "format_specifier", |
79 | HighlightTag::Function => "function", | 81 | HighlightTag::Function => "function", |
82 | HighlightTag::Generic => "generic", | ||
80 | HighlightTag::Keyword => "keyword", | 83 | HighlightTag::Keyword => "keyword", |
81 | HighlightTag::Lifetime => "lifetime", | 84 | HighlightTag::Lifetime => "lifetime", |
82 | HighlightTag::Macro => "macro", | 85 | HighlightTag::Macro => "macro", |
@@ -110,6 +113,7 @@ impl HighlightModifier { | |||
110 | HighlightModifier::ControlFlow, | 113 | HighlightModifier::ControlFlow, |
111 | HighlightModifier::Definition, | 114 | HighlightModifier::Definition, |
112 | HighlightModifier::Documentation, | 115 | HighlightModifier::Documentation, |
116 | HighlightModifier::Injected, | ||
113 | HighlightModifier::Mutable, | 117 | HighlightModifier::Mutable, |
114 | HighlightModifier::Unsafe, | 118 | HighlightModifier::Unsafe, |
115 | ]; | 119 | ]; |
@@ -120,6 +124,7 @@ impl HighlightModifier { | |||
120 | HighlightModifier::ControlFlow => "control", | 124 | HighlightModifier::ControlFlow => "control", |
121 | HighlightModifier::Definition => "declaration", | 125 | HighlightModifier::Definition => "declaration", |
122 | HighlightModifier::Documentation => "documentation", | 126 | HighlightModifier::Documentation => "documentation", |
127 | HighlightModifier::Injected => "injected", | ||
123 | HighlightModifier::Mutable => "mutable", | 128 | HighlightModifier::Mutable => "mutable", |
124 | HighlightModifier::Unsafe => "unsafe", | 129 | HighlightModifier::Unsafe => "unsafe", |
125 | } | 130 | } |
diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 2ea63d33b..10fe40cb5 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs | |||
@@ -39,13 +39,14 @@ define_semantic_token_types![ | |||
39 | (BOOLEAN, "boolean"), | 39 | (BOOLEAN, "boolean"), |
40 | (BUILTIN_TYPE, "builtinType"), | 40 | (BUILTIN_TYPE, "builtinType"), |
41 | (ENUM_MEMBER, "enumMember"), | 41 | (ENUM_MEMBER, "enumMember"), |
42 | (ESCAPE_SEQUENCE, "escapeSequence"), | ||
43 | (FORMAT_SPECIFIER, "formatSpecifier"), | ||
44 | (GENERIC, "generic"), | ||
42 | (LIFETIME, "lifetime"), | 45 | (LIFETIME, "lifetime"), |
43 | (SELF_KEYWORD, "selfKeyword"), | 46 | (SELF_KEYWORD, "selfKeyword"), |
44 | (TYPE_ALIAS, "typeAlias"), | 47 | (TYPE_ALIAS, "typeAlias"), |
45 | (UNION, "union"), | 48 | (UNION, "union"), |
46 | (UNRESOLVED_REFERENCE, "unresolvedReference"), | 49 | (UNRESOLVED_REFERENCE, "unresolvedReference"), |
47 | (FORMAT_SPECIFIER, "formatSpecifier"), | ||
48 | (ESCAPE_SEQUENCE, "escapeSequence"), | ||
49 | ]; | 50 | ]; |
50 | 51 | ||
51 | macro_rules! define_semantic_token_modifiers { | 52 | macro_rules! define_semantic_token_modifiers { |
@@ -68,6 +69,7 @@ macro_rules! define_semantic_token_modifiers { | |||
68 | define_semantic_token_modifiers![ | 69 | define_semantic_token_modifiers![ |
69 | (CONSTANT, "constant"), | 70 | (CONSTANT, "constant"), |
70 | (CONTROL_FLOW, "controlFlow"), | 71 | (CONTROL_FLOW, "controlFlow"), |
72 | (INJECTED, "injected"), | ||
71 | (MUTABLE, "mutable"), | 73 | (MUTABLE, "mutable"), |
72 | (UNSAFE, "unsafe"), | 74 | (UNSAFE, "unsafe"), |
73 | (ATTRIBUTE_MODIFIER, "attribute"), | 75 | (ATTRIBUTE_MODIFIER, "attribute"), |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 7b45b169d..da9887a9a 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -295,6 +295,7 @@ fn semantic_token_type_and_modifiers( | |||
295 | HighlightTag::SelfType => lsp_types::SemanticTokenType::TYPE, | 295 | HighlightTag::SelfType => lsp_types::SemanticTokenType::TYPE, |
296 | HighlightTag::Field => lsp_types::SemanticTokenType::PROPERTY, | 296 | HighlightTag::Field => lsp_types::SemanticTokenType::PROPERTY, |
297 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, | 297 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, |
298 | HighlightTag::Generic => semantic_tokens::GENERIC, | ||
298 | HighlightTag::Module => lsp_types::SemanticTokenType::NAMESPACE, | 299 | HighlightTag::Module => lsp_types::SemanticTokenType::NAMESPACE, |
299 | HighlightTag::Constant => { | 300 | HighlightTag::Constant => { |
300 | mods |= semantic_tokens::CONSTANT; | 301 | mods |= semantic_tokens::CONSTANT; |
@@ -331,6 +332,7 @@ fn semantic_token_type_and_modifiers( | |||
331 | HighlightModifier::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER, | 332 | HighlightModifier::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER, |
332 | HighlightModifier::Definition => lsp_types::SemanticTokenModifier::DECLARATION, | 333 | HighlightModifier::Definition => lsp_types::SemanticTokenModifier::DECLARATION, |
333 | HighlightModifier::Documentation => lsp_types::SemanticTokenModifier::DOCUMENTATION, | 334 | HighlightModifier::Documentation => lsp_types::SemanticTokenModifier::DOCUMENTATION, |
335 | HighlightModifier::Injected => semantic_tokens::INJECTED, | ||
334 | HighlightModifier::ControlFlow => semantic_tokens::CONTROL_FLOW, | 336 | HighlightModifier::ControlFlow => semantic_tokens::CONTROL_FLOW, |
335 | HighlightModifier::Mutable => semantic_tokens::MUTABLE, | 337 | HighlightModifier::Mutable => semantic_tokens::MUTABLE, |
336 | HighlightModifier::Unsafe => semantic_tokens::UNSAFE, | 338 | HighlightModifier::Unsafe => semantic_tokens::UNSAFE, |