diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html
index 13a5d1b12a2..f1e007b09b2 100644
--- a/crates/ra_ide/src/snapshots/highlight_doctest.html
+++ b/crates/ra_ide/src/snapshots/highlight_doctest.html
@@ -38,48 +38,48 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
impl Foo {
pub const bar: bool = true;
-
-
-
-
-
- #![allow(unused_mut)]
- let mut foo: Foo = Foo::new();
-
+
+
+
+
+
+ #![allow(unused_mut)]
+ let mut foo: Foo = Foo::new();
+
pub const fn new() -> Foo {
Foo { bar: true }
}
-
-
-
-
-
- use x::y;
-
- let foo = Foo::new();
-
-
- assert!(foo.bar());
-
- let bar = foo.bar || Foo::bar;
-
-
-
- let multi_line_string = "Foo
- bar
- ";
-
-
-
-
- let foobar = Foo::new().bar();
-
-
-
-
-
+
+
+
+
+
+ use x::y;
+
+ let foo = Foo::new();
+
+
+ assert!(foo.bar());
+
+ let bar = foo.bar || Foo::bar;
+
+
+
+ let multi_line_string = "Foo
+ bar
+ ";
+
+
+
+
+ let foobar = Foo::new().bar();
+
+
+
+
+
pub fn foo(&self) -> bool {
true
}
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 5a4de450c6d..68dff45b7f5 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -475,7 +475,14 @@ fn highlight_element(
}
// Simple token-based highlighting
- COMMENT => HighlightTag::Comment.into(),
+ COMMENT => {
+ let comment = element.into_token().and_then(ast::Comment::cast)?;
+ if comment.kind().doc.is_some() {
+ Highlight::from(HighlightTag::Comment) | HighlightModifier::Documentation
+ } else {
+ HighlightTag::Comment.into()
+ }
+ }
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(),
ATTR => HighlightTag::Attribute.into(),
INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs
index 929a5cc5c0a..40436c5a225 100644
--- a/crates/ra_ide/src/syntax_highlighting/injection.rs
+++ b/crates/ra_ide/src/syntax_highlighting/injection.rs
@@ -7,7 +7,10 @@ use hir::Semantics;
use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
use stdx::SepBy;
-use crate::{call_info::ActiveParameter, Analysis, HighlightTag, HighlightedRange, RootDatabase};
+use crate::{
+ call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag,
+ HighlightedRange, RootDatabase,
+};
use super::HighlightedRangeStack;
@@ -118,7 +121,8 @@ pub(super) fn extract_doc_comments(
range.start(),
range.start() + TextSize::try_from(pos).unwrap(),
),
- highlight: HighlightTag::Comment.into(),
+ highlight: Highlight::from(HighlightTag::Comment)
+ | HighlightModifier::Documentation,
binding_hash: None,
});
line_start += range.len() - TextSize::try_from(pos).unwrap();
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index 94f466966a3..f593ecad815 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -55,6 +55,7 @@ pub enum HighlightModifier {
/// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
/// not.
Definition,
+ Documentation,
Mutable,
Unsafe,
}
@@ -106,6 +107,7 @@ impl HighlightModifier {
HighlightModifier::Attribute,
HighlightModifier::ControlFlow,
HighlightModifier::Definition,
+ HighlightModifier::Documentation,
HighlightModifier::Mutable,
HighlightModifier::Unsafe,
];
@@ -115,6 +117,7 @@ impl HighlightModifier {
HighlightModifier::Attribute => "attribute",
HighlightModifier::ControlFlow => "control",
HighlightModifier::Definition => "declaration",
+ HighlightModifier::Documentation => "documentation",
HighlightModifier::Mutable => "mutable",
HighlightModifier::Unsafe => "unsafe",
}
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 2851b4d3132..84d6f5155e7 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -330,6 +330,7 @@ fn semantic_token_type_and_modifiers(
let modifier = match modifier {
HighlightModifier::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER,
HighlightModifier::Definition => lsp_types::SemanticTokenModifier::DECLARATION,
+ HighlightModifier::Documentation => lsp_types::SemanticTokenModifier::DOCUMENTATION,
HighlightModifier::ControlFlow => semantic_tokens::CONTROL_FLOW,
HighlightModifier::Mutable => semantic_tokens::MUTABLE,
HighlightModifier::Unsafe => semantic_tokens::UNSAFE,