aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/snapshots/highlight_doctest.html76
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs9
-rw-r--r--crates/ra_ide/src/syntax_highlighting/injection.rs8
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs3
-rw-r--r--crates/rust-analyzer/src/to_proto.rs1
5 files changed, 56 insertions, 41 deletions
diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html
index 13a5d1b12..f1e007b09 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
38<span class="keyword">impl</span> <span class="struct">Foo</span> { 38<span class="keyword">impl</span> <span class="struct">Foo</span> {
39 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span>: <span class="builtin_type">bool</span> = <span class="bool_literal">true</span>; 39 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="constant declaration">bar</span>: <span class="builtin_type">bool</span> = <span class="bool_literal">true</span>;
40 40
41 <span class="comment">/// Constructs a new `Foo`.</span> 41 <span class="comment documentation">/// Constructs a new `Foo`.</span>
42 <span class="comment">///</span> 42 <span class="comment documentation">///</span>
43 <span class="comment">/// # Examples</span> 43 <span class="comment documentation">/// # Examples</span>
44 <span class="comment">///</span> 44 <span class="comment documentation">///</span>
45 <span class="comment">/// ```</span> 45 <span class="comment documentation">/// ```</span>
46 <span class="comment">/// #</span> <span class="attribute">#![</span><span class="function attribute">allow</span><span class="attribute">(unused_mut)]</span> 46 <span class="comment documentation">/// #</span> <span class="attribute">#![</span><span class="function attribute">allow</span><span class="attribute">(unused_mut)]</span>
47 <span class="comment">/// </span><span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span>: <span class="struct">Foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>(); 47 <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span>: <span class="struct">Foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>();
48 <span class="comment">/// ```</span> 48 <span class="comment documentation">/// ```</span>
49 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -&gt; <span class="struct">Foo</span> { 49 <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -&gt; <span class="struct">Foo</span> {
50 <span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> } 50 <span class="struct">Foo</span> { <span class="field">bar</span>: <span class="bool_literal">true</span> }
51 } 51 }
52 52
53 <span class="comment">/// `bar` method on `Foo`.</span> 53 <span class="comment documentation">/// `bar` method on `Foo`.</span>
54 <span class="comment">///</span> 54 <span class="comment documentation">///</span>
55 <span class="comment">/// # Examples</span> 55 <span class="comment documentation">/// # Examples</span>
56 <span class="comment">///</span> 56 <span class="comment documentation">///</span>
57 <span class="comment">/// ```</span> 57 <span class="comment documentation">/// ```</span>
58 <span class="comment">/// </span><span class="keyword">use</span> <span class="module">x</span>::<span class="module">y</span>; 58 <span class="comment documentation">/// </span><span class="keyword">use</span> <span class="module">x</span>::<span class="module">y</span>;
59 <span class="comment">///</span> 59 <span class="comment documentation">///</span>
60 <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>(); 60 <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">foo</span> = <span class="struct">Foo</span>::<span class="function">new</span>();
61 <span class="comment">///</span> 61 <span class="comment documentation">///</span>
62 <span class="comment">/// </span><span class="comment">// calls bar on foo</span> 62 <span class="comment documentation">/// </span><span class="comment">// calls bar on foo</span>
63 <span class="comment">/// </span><span class="macro">assert!</span>(foo.bar()); 63 <span class="comment documentation">/// </span><span class="macro">assert!</span>(foo.bar());
64 <span class="comment">///</span> 64 <span class="comment documentation">///</span>
65 <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">bar</span> = <span class="variable">foo</span>.<span class="field">bar</span> || <span class="struct">Foo</span>::<span class="constant">bar</span>; 65 <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">bar</span> = <span class="variable">foo</span>.<span class="field">bar</span> || <span class="struct">Foo</span>::<span class="constant">bar</span>;
66 <span class="comment">///</span> 66 <span class="comment documentation">///</span>
67 <span class="comment">/// </span><span class="comment">/* multi-line 67 <span class="comment documentation">/// </span><span class="comment">/* multi-line
68 </span><span class="comment">/// </span><span class="comment"> comment */</span> 68 </span><span class="comment documentation">/// </span><span class="comment"> comment */</span>
69 <span class="comment">///</span> 69 <span class="comment documentation">///</span>
70 <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">multi_line_string</span> = <span class="string_literal">"Foo 70 <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">multi_line_string</span> = <span class="string_literal">"Foo
71 </span><span class="comment">/// </span><span class="string_literal"> bar 71 </span><span class="comment documentation">/// </span><span class="string_literal"> bar
72 </span><span class="comment">/// </span><span class="string_literal"> "</span>; 72 </span><span class="comment documentation">/// </span><span class="string_literal"> "</span>;
73 <span class="comment">///</span> 73 <span class="comment documentation">///</span>
74 <span class="comment">/// ```</span> 74 <span class="comment documentation">/// ```</span>
75 <span class="comment">///</span> 75 <span class="comment documentation">///</span>
76 <span class="comment">/// ```rust,no_run</span> 76 <span class="comment documentation">/// ```rust,no_run</span>
77 <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">foobar</span> = <span class="struct">Foo</span>::<span class="function">new</span>().<span class="function">bar</span>(); 77 <span class="comment documentation">/// </span><span class="keyword">let</span> <span class="variable declaration">foobar</span> = <span class="struct">Foo</span>::<span class="function">new</span>().<span class="function">bar</span>();
78 <span class="comment">/// ```</span> 78 <span class="comment documentation">/// ```</span>
79 <span class="comment">///</span> 79 <span class="comment documentation">///</span>
80 <span class="comment">/// ```sh</span> 80 <span class="comment documentation">/// ```sh</span>
81 <span class="comment">/// echo 1</span> 81 <span class="comment documentation">/// echo 1</span>
82 <span class="comment">/// ```</span> 82 <span class="comment documentation">/// ```</span>
83 <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> { 83 <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="bool_literal">true</span> 84 <span class="bool_literal">true</span>
85 } 85 }
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 5a4de450c..68dff45b7 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -475,7 +475,14 @@ fn highlight_element(
475 } 475 }
476 476
477 // Simple token-based highlighting 477 // Simple token-based highlighting
478 COMMENT => HighlightTag::Comment.into(), 478 COMMENT => {
479 let comment = element.into_token().and_then(ast::Comment::cast)?;
480 if comment.kind().doc.is_some() {
481 Highlight::from(HighlightTag::Comment) | HighlightModifier::Documentation
482 } else {
483 HighlightTag::Comment.into()
484 }
485 }
479 STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(), 486 STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(),
480 ATTR => HighlightTag::Attribute.into(), 487 ATTR => HighlightTag::Attribute.into(),
481 INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), 488 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 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;
7use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; 7use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
8use stdx::SepBy; 8use stdx::SepBy;
9 9
10use crate::{call_info::ActiveParameter, Analysis, HighlightTag, HighlightedRange, RootDatabase}; 10use crate::{
11 call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag,
12 HighlightedRange, RootDatabase,
13};
11 14
12use super::HighlightedRangeStack; 15use super::HighlightedRangeStack;
13 16
@@ -118,7 +121,8 @@ pub(super) fn extract_doc_comments(
118 range.start(), 121 range.start(),
119 range.start() + TextSize::try_from(pos).unwrap(), 122 range.start() + TextSize::try_from(pos).unwrap(),
120 ), 123 ),
121 highlight: HighlightTag::Comment.into(), 124 highlight: Highlight::from(HighlightTag::Comment)
125 | HighlightModifier::Documentation,
122 binding_hash: None, 126 binding_hash: None,
123 }); 127 });
124 line_start += range.len() - TextSize::try_from(pos).unwrap(); 128 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 {
55 /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is 55 /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
56 /// not. 56 /// not.
57 Definition, 57 Definition,
58 Documentation,
58 Mutable, 59 Mutable,
59 Unsafe, 60 Unsafe,
60} 61}
@@ -106,6 +107,7 @@ impl HighlightModifier {
106 HighlightModifier::Attribute, 107 HighlightModifier::Attribute,
107 HighlightModifier::ControlFlow, 108 HighlightModifier::ControlFlow,
108 HighlightModifier::Definition, 109 HighlightModifier::Definition,
110 HighlightModifier::Documentation,
109 HighlightModifier::Mutable, 111 HighlightModifier::Mutable,
110 HighlightModifier::Unsafe, 112 HighlightModifier::Unsafe,
111 ]; 113 ];
@@ -115,6 +117,7 @@ impl HighlightModifier {
115 HighlightModifier::Attribute => "attribute", 117 HighlightModifier::Attribute => "attribute",
116 HighlightModifier::ControlFlow => "control", 118 HighlightModifier::ControlFlow => "control",
117 HighlightModifier::Definition => "declaration", 119 HighlightModifier::Definition => "declaration",
120 HighlightModifier::Documentation => "documentation",
118 HighlightModifier::Mutable => "mutable", 121 HighlightModifier::Mutable => "mutable",
119 HighlightModifier::Unsafe => "unsafe", 122 HighlightModifier::Unsafe => "unsafe",
120 } 123 }
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 2851b4d31..84d6f5155 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(
330 let modifier = match modifier { 330 let modifier = match modifier {
331 HighlightModifier::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER, 331 HighlightModifier::Attribute => semantic_tokens::ATTRIBUTE_MODIFIER,
332 HighlightModifier::Definition => lsp_types::SemanticTokenModifier::DECLARATION, 332 HighlightModifier::Definition => lsp_types::SemanticTokenModifier::DECLARATION,
333 HighlightModifier::Documentation => lsp_types::SemanticTokenModifier::DOCUMENTATION,
333 HighlightModifier::ControlFlow => semantic_tokens::CONTROL_FLOW, 334 HighlightModifier::ControlFlow => semantic_tokens::CONTROL_FLOW,
334 HighlightModifier::Mutable => semantic_tokens::MUTABLE, 335 HighlightModifier::Mutable => semantic_tokens::MUTABLE,
335 HighlightModifier::Unsafe => semantic_tokens::UNSAFE, 336 HighlightModifier::Unsafe => semantic_tokens::UNSAFE,