From aae26bc5b864971ef54f4d95d5ed89a6436334e2 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 20:17:26 -0400 Subject: Add highlighting support for doc comments --- crates/ra_ide/src/syntax_highlighting/injection.rs | 8 ++++++-- crates/ra_ide/src/syntax_highlighting/tags.rs | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src/syntax_highlighting') diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 929a5cc5c..40436c5a2 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 94f466966..f593ecad8 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", } -- cgit v1.2.3