aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-23 14:17:53 +0100
committerPaul Daniel Faria <[email protected]>2020-06-23 17:13:50 +0100
commit2a56323537442958008d0fddd78e33df425b11a9 (patch)
treeee3a7043c21df2aab8be6b7bb2ab83dd6fe4b84f /crates/ra_ide/src/syntax_highlighting
parentd8230acd84dc931f72b9dd32b8fbc2aa887d8b4b (diff)
Update injection mechanism and stop injecting through highlight element, switch to more general new highlight tag, generic
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/html.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting/injection.rs12
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs4
3 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs
index 2a27c81dd..0c74f7370 100644
--- a/crates/ra_ide/src/syntax_highlighting/html.rs
+++ b/crates/ra_ide/src/syntax_highlighting/html.rs
@@ -19,7 +19,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
19 ) 19 )
20 } 20 }
21 21
22 let ranges = highlight(db, file_id, None, false, false); 22 let ranges = highlight(db, file_id, None, false);
23 let text = parse.tree().syntax().to_string(); 23 let text = parse.tree().syntax().to_string();
24 let mut prev_pos = TextSize::from(0); 24 let mut prev_pos = TextSize::from(0);
25 let mut buf = String::new(); 25 let mut buf = String::new();
diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs
index 8c724af5b..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};
8use stdx::SepBy; 8use stdx::SepBy;
9 9
10use crate::{ 10use 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
15use super::HighlightedRangeStack; 15use super::HighlightedRangeStack;
@@ -150,8 +150,7 @@ pub(super) fn highlight_doc_comment(
150 let (analysis, tmp_file_id) = Analysis::from_single_file(text); 150 let (analysis, tmp_file_id) = Analysis::from_single_file(text);
151 151
152 stack.push(); 152 stack.push();
153 for mut h in analysis.with_db(|db| super::highlight(db, tmp_file_id, None, true, true)).unwrap() 153 for mut h in analysis.with_db(|db| super::highlight(db, tmp_file_id, None, true)).unwrap() {
154 {
155 // Determine start offset and end offset in case of multi-line ranges 154 // Determine start offset and end offset in case of multi-line ranges
156 let mut start_offset = None; 155 let mut start_offset = None;
157 let mut end_offset = None; 156 let mut end_offset = None;
@@ -183,6 +182,7 @@ pub(super) fn highlight_doc_comment(
183 for comment in new_comments { 182 for comment in new_comments {
184 stack.add(comment); 183 stack.add(comment);
185 } 184 }
186 stack.pop_and_inject(false); 185 stack.pop_and_inject(None);
187 stack.pop_and_inject(true); 186 stack
187 .pop_and_inject(Some(Highlight::from(HighlightTag::Generic) | HighlightModifier::Injected));
188} 188}
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index 7f8e91e8d..e8e251cfc 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -27,13 +27,13 @@ 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,
33 Module, 34 Module,
34 NumericLiteral, 35 NumericLiteral,
35 Operator, 36 Operator,
36 Punctuation,
37 SelfKeyword, 37 SelfKeyword,
38 SelfType, 38 SelfType,
39 Static, 39 Static,
@@ -79,13 +79,13 @@ impl HighlightTag {
79 HighlightTag::Field => "field", 79 HighlightTag::Field => "field",
80 HighlightTag::FormatSpecifier => "format_specifier", 80 HighlightTag::FormatSpecifier => "format_specifier",
81 HighlightTag::Function => "function", 81 HighlightTag::Function => "function",
82 HighlightTag::Generic => "generic",
82 HighlightTag::Keyword => "keyword", 83 HighlightTag::Keyword => "keyword",
83 HighlightTag::Lifetime => "lifetime", 84 HighlightTag::Lifetime => "lifetime",
84 HighlightTag::Macro => "macro", 85 HighlightTag::Macro => "macro",
85 HighlightTag::Module => "module", 86 HighlightTag::Module => "module",
86 HighlightTag::NumericLiteral => "numeric_literal", 87 HighlightTag::NumericLiteral => "numeric_literal",
87 HighlightTag::Operator => "operator", 88 HighlightTag::Operator => "operator",
88 HighlightTag::Punctuation => "punctuation",
89 HighlightTag::SelfKeyword => "self_keyword", 89 HighlightTag::SelfKeyword => "self_keyword",
90 HighlightTag::SelfType => "self_type", 90 HighlightTag::SelfType => "self_type",
91 HighlightTag::Static => "static", 91 HighlightTag::Static => "static",