4903: Add highlighting support for doc comments r=matklad a=Nashenas88

The language server protocol includes a semantic modifier for documentation. This change exports that modifier for doc comments so users can choose to highlight them differently compared to regular comments.

Example:
<img width="375" alt="Screen Shot 2020-06-16 at 10 34 14 AM" src="https://user-images.githubusercontent.com/1673130/84788271-f6599580-afbc-11ea-96e5-7a0215da620b.png">

CC @woody77 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-06-18 13:23:14 +00:00 committed by GitHub
commit f7f627d342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 41 deletions

View file

@ -489,7 +489,14 @@ fn highlight_element(
}
// Simple token-based highlighting
COMMENT => HighlightTag::Comment.into(),
COMMENT => {
let comment = element.into_token().and_then(ast::Comment::cast)?;
let h = HighlightTag::Comment;
match comment.kind().doc {
Some(_) => h | HighlightModifier::Documentation,
None => h.into(),
}
}
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(),
ATTR => HighlightTag::Attribute.into(),
INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),