diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-24 06:22:23 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-24 06:22:23 +0100 |
commit | c544f9a137bd675fd6e9cc4c244ff4366ededb50 (patch) | |
tree | dbf501f61f5e77234901aff49ebd2a0bbf5ae4cd /crates/ra_ide/src/syntax_highlighting | |
parent | 471d44e72c54882cff2e00c662ee74d8c7c94234 (diff) | |
parent | 0d87eee3a9d3950cd02a80bf3974b4b165c5a76c (diff) |
Merge #4940
4940: Add support for marking doctest items as distinct from normal code r=ltentrup a=Nashenas88
This adds `HighlightTag::Generic | HighlightModifier::Injected` as the default highlight for all elements within a doctest. Please feel free to suggest that a new tag be created or a different one used.

Fixes #4929
Fixes #4939
Co-authored-by: Paul Daniel Faria <[email protected]>
Co-authored-by: Paul Daniel Faria <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/html.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/injection.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 99b6b25ab..0c74f7370 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs | |||
@@ -64,6 +64,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd | |||
64 | 64 | ||
65 | .lifetime { color: #DFAF8F; font-style: italic; } | 65 | .lifetime { color: #DFAF8F; font-style: italic; } |
66 | .comment { color: #7F9F7F; } | 66 | .comment { color: #7F9F7F; } |
67 | .documentation { color: #629755; } | ||
68 | .injected { opacity: 0.65 ; } | ||
67 | .struct, .enum { color: #7CB8BB; } | 69 | .struct, .enum { color: #7CB8BB; } |
68 | .enum_variant { color: #BDE0F3; } | 70 | .enum_variant { color: #BDE0F3; } |
69 | .string_literal { color: #CC9393; } | 71 | .string_literal { color: #CC9393; } |
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 9d82b4009..181c21256 100644 --- a/crates/ra_ide/src/syntax_highlighting/injection.rs +++ b/crates/ra_ide/src/syntax_highlighting/injection.rs | |||
@@ -8,8 +8,8 @@ use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; | |||
8 | use stdx::SepBy; | 8 | use stdx::SepBy; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | call_info::ActiveParameter, Analysis, HighlightModifier, HighlightTag, HighlightedRange, | 11 | call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, |
12 | RootDatabase, | 12 | HighlightedRange, RootDatabase, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | use super::HighlightedRangeStack; | 15 | use super::HighlightedRangeStack; |
@@ -172,6 +172,7 @@ pub(super) fn highlight_doc_comment( | |||
172 | h.range.end() + end_offset.unwrap_or(start_offset) - h.range.start(), | 172 | h.range.end() + end_offset.unwrap_or(start_offset) - h.range.start(), |
173 | ); | 173 | ); |
174 | 174 | ||
175 | h.highlight |= HighlightModifier::Injected; | ||
175 | stack.add(h); | 176 | stack.add(h); |
176 | } | 177 | } |
177 | } | 178 | } |
@@ -181,6 +182,7 @@ pub(super) fn highlight_doc_comment( | |||
181 | for comment in new_comments { | 182 | for comment in new_comments { |
182 | stack.add(comment); | 183 | stack.add(comment); |
183 | } | 184 | } |
184 | stack.pop_and_inject(false); | 185 | stack.pop_and_inject(None); |
185 | stack.pop_and_inject(true); | 186 | stack |
187 | .pop_and_inject(Some(Highlight::from(HighlightTag::Generic) | HighlightModifier::Injected)); | ||
186 | } | 188 | } |
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 93bbb4b4d..e8e251cfc 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs | |||
@@ -27,6 +27,7 @@ pub enum HighlightTag { | |||
27 | Field, | 27 | Field, |
28 | FormatSpecifier, | 28 | FormatSpecifier, |
29 | Function, | 29 | Function, |
30 | Generic, | ||
30 | Keyword, | 31 | Keyword, |
31 | Lifetime, | 32 | Lifetime, |
32 | Macro, | 33 | Macro, |
@@ -57,6 +58,7 @@ pub enum HighlightModifier { | |||
57 | /// not. | 58 | /// not. |
58 | Definition, | 59 | Definition, |
59 | Documentation, | 60 | Documentation, |
61 | Injected, | ||
60 | Mutable, | 62 | Mutable, |
61 | Unsafe, | 63 | Unsafe, |
62 | } | 64 | } |
@@ -77,6 +79,7 @@ impl HighlightTag { | |||
77 | HighlightTag::Field => "field", | 79 | HighlightTag::Field => "field", |
78 | HighlightTag::FormatSpecifier => "format_specifier", | 80 | HighlightTag::FormatSpecifier => "format_specifier", |
79 | HighlightTag::Function => "function", | 81 | HighlightTag::Function => "function", |
82 | HighlightTag::Generic => "generic", | ||
80 | HighlightTag::Keyword => "keyword", | 83 | HighlightTag::Keyword => "keyword", |
81 | HighlightTag::Lifetime => "lifetime", | 84 | HighlightTag::Lifetime => "lifetime", |
82 | HighlightTag::Macro => "macro", | 85 | HighlightTag::Macro => "macro", |
@@ -110,6 +113,7 @@ impl HighlightModifier { | |||
110 | HighlightModifier::ControlFlow, | 113 | HighlightModifier::ControlFlow, |
111 | HighlightModifier::Definition, | 114 | HighlightModifier::Definition, |
112 | HighlightModifier::Documentation, | 115 | HighlightModifier::Documentation, |
116 | HighlightModifier::Injected, | ||
113 | HighlightModifier::Mutable, | 117 | HighlightModifier::Mutable, |
114 | HighlightModifier::Unsafe, | 118 | HighlightModifier::Unsafe, |
115 | ]; | 119 | ]; |
@@ -120,6 +124,7 @@ impl HighlightModifier { | |||
120 | HighlightModifier::ControlFlow => "control", | 124 | HighlightModifier::ControlFlow => "control", |
121 | HighlightModifier::Definition => "declaration", | 125 | HighlightModifier::Definition => "declaration", |
122 | HighlightModifier::Documentation => "documentation", | 126 | HighlightModifier::Documentation => "documentation", |
127 | HighlightModifier::Injected => "injected", | ||
123 | HighlightModifier::Mutable => "mutable", | 128 | HighlightModifier::Mutable => "mutable", |
124 | HighlightModifier::Unsafe => "unsafe", | 129 | HighlightModifier::Unsafe => "unsafe", |
125 | } | 130 | } |