aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-21 13:05:16 +0100
committerGitHub <[email protected]>2020-06-21 13:05:16 +0100
commit50dad50188f9eef5b10b2908351e668e8ba8a0c5 (patch)
treeb64a253eb9c8ba1e45d46f9c3f34261d03ef1659 /crates
parentfe254857e6ab9a9881e7351429fcd4e152aa9d0d (diff)
parentdf5b37cb612664985f1ba0a24280621809bd5533 (diff)
Merge #4959
4959: Syntax highlighting for documentation comments on macro definitions r=matklad a=ltentrup Two minor changes with regards to syntax highlighting of comments attached to macro definitions. Before <img width="290" alt="Bildschirmfoto 2020-06-20 um 00 05 19" src="https://user-images.githubusercontent.com/201808/85182705-c561b500-b289-11ea-944e-0bdf6508a44f.png"> After <img width="288" alt="Bildschirmfoto 2020-06-20 um 00 03 36" src="https://user-images.githubusercontent.com/201808/85182727-d90d1b80-b289-11ea-9d2d-234731f19302.png"> Fixes #4949 Co-authored-by: Leander Tentrup <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/snapshots/highlight_doctest.html9
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs3
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs9
3 files changed, 19 insertions, 2 deletions
diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html
index f61c0daa5..63199cdbe 100644
--- a/crates/ra_ide/src/snapshots/highlight_doctest.html
+++ b/crates/ra_ide/src/snapshots/highlight_doctest.html
@@ -84,4 +84,13 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
84 <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span>(&<span class="self_keyword">self</span>) -&gt; <span class="builtin_type">bool</span> { 84 <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span>(&<span class="self_keyword">self</span>) -&gt; <span class="builtin_type">bool</span> {
85 <span class="bool_literal">true</span> 85 <span class="bool_literal">true</span>
86 } 86 }
87}
88
89<span class="comment documentation">/// ```</span>
90<span class="comment documentation">/// </span><span class="macro">noop!</span>(<span class="numeric_literal">1</span>);
91<span class="comment documentation">/// ```</span>
92<span class="macro">macro_rules!</span> <span class="macro declaration">noop</span> {
93 ($expr:expr) =&gt; {
94 $expr
95 }
87}</code></pre> \ No newline at end of file 96}</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 f8f790e59..448645bdc 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -121,7 +121,6 @@ pub(crate) fn highlight(
121 assert!(current_macro_call == Some(mc)); 121 assert!(current_macro_call == Some(mc));
122 current_macro_call = None; 122 current_macro_call = None;
123 format_string = None; 123 format_string = None;
124 continue;
125 } 124 }
126 _ => (), 125 _ => (),
127 } 126 }
@@ -150,7 +149,7 @@ pub(crate) fn highlight(
150 149
151 let range = element.text_range(); 150 let range = element.text_range();
152 151
153 let element_to_highlight = if current_macro_call.is_some() { 152 let element_to_highlight = if current_macro_call.is_some() && element.kind() != COMMENT {
154 // Inside a macro -- expand it first 153 // Inside a macro -- expand it first
155 let token = match element.clone().into_token() { 154 let token = match element.clone().into_token() {
156 Some(it) if it.parent().kind() == TOKEN_TREE => it, 155 Some(it) if it.parent().kind() == TOKEN_TREE => it,
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index b4d56a7a0..93a276ffe 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -344,6 +344,15 @@ impl Foo {
344 true 344 true
345 } 345 }
346} 346}
347
348/// ```
349/// noop!(1);
350/// ```
351macro_rules! noop {
352 ($expr:expr) => {
353 $expr
354 }
355}
347"# 356"#
348 .trim(), 357 .trim(),
349 "crates/ra_ide/src/snapshots/highlight_doctest.html", 358 "crates/ra_ide/src/snapshots/highlight_doctest.html",