From df5b37cb612664985f1ba0a24280621809bd5533 Mon Sep 17 00:00:00 2001 From: Leander Tentrup Date: Sat, 20 Jun 2020 00:02:42 +0200 Subject: Syntax highlighting for documentation comments on macro definitions --- crates/ra_ide/src/snapshots/highlight_doctest.html | 9 +++++++++ crates/ra_ide/src/syntax_highlighting.rs | 3 +-- crates/ra_ide/src/syntax_highlighting/tests.rs | 9 +++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'crates') 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 pub fn foo(&self) -> bool { true } +} + +/// ``` +/// noop!(1); +/// ``` +macro_rules! noop { + ($expr:expr) => { + $expr + } } \ 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( assert!(current_macro_call == Some(mc)); current_macro_call = None; format_string = None; - continue; } _ => (), } @@ -150,7 +149,7 @@ pub(crate) fn highlight( let range = element.text_range(); - let element_to_highlight = if current_macro_call.is_some() { + let element_to_highlight = if current_macro_call.is_some() && element.kind() != COMMENT { // Inside a macro -- expand it first let token = match element.clone().into_token() { 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 { true } } + +/// ``` +/// noop!(1); +/// ``` +macro_rules! noop { + ($expr:expr) => { + $expr + } +} "# .trim(), "crates/ra_ide/src/snapshots/highlight_doctest.html", -- cgit v1.2.3