@@ -44,7 +44,7 @@ pub struct HlRange {
44
44
}
45
45
46
46
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
47
- pub struct HighlightConfig {
47
+ pub struct HighlightConfig < ' a > {
48
48
/// Whether to highlight strings
49
49
pub strings : bool ,
50
50
/// Whether to highlight punctuation
@@ -61,6 +61,12 @@ pub struct HighlightConfig {
61
61
pub macro_bang : bool ,
62
62
/// Whether to highlight unresolved things be their syntax
63
63
pub syntactic_name_ref_highlighting : bool ,
64
+ /// This is a bit of a special field, it's not really a config, rather it's a way to pass information to highlight.
65
+ ///
66
+ /// Fixture highlighting requires the presence of a `minicore.rs` file. If such file is believed to be found in
67
+ /// the workspace (based on the path), this field stores its contents. Otherwise, highlighting will use the `minicore`
68
+ /// that was baked into the rust-analyzer binary.
69
+ pub minicore : Option < & ' a str > ,
64
70
}
65
71
66
72
// Feature: Semantic Syntax Highlighting
@@ -188,7 +194,7 @@ pub struct HighlightConfig {
188
194
// 
189
195
pub ( crate ) fn highlight (
190
196
db : & RootDatabase ,
191
- config : HighlightConfig ,
197
+ config : & HighlightConfig < ' _ > ,
192
198
file_id : FileId ,
193
199
range_to_highlight : Option < TextRange > ,
194
200
) -> Vec < HlRange > {
@@ -223,7 +229,7 @@ pub(crate) fn highlight(
223
229
fn traverse (
224
230
hl : & mut Highlights ,
225
231
sema : & Semantics < ' _ , RootDatabase > ,
226
- config : HighlightConfig ,
232
+ config : & HighlightConfig < ' _ > ,
227
233
InRealFile { file_id, value : root } : InRealFile < & SyntaxNode > ,
228
234
krate : Option < hir:: Crate > ,
229
235
range_to_highlight : TextRange ,
@@ -488,7 +494,7 @@ fn traverse(
488
494
fn string_injections (
489
495
hl : & mut Highlights ,
490
496
sema : & Semantics < ' _ , RootDatabase > ,
491
- config : HighlightConfig ,
497
+ config : & HighlightConfig < ' _ > ,
492
498
file_id : EditionedFileId ,
493
499
krate : Option < hir:: Crate > ,
494
500
token : SyntaxToken ,
@@ -585,7 +591,7 @@ fn descend_token(
585
591
} )
586
592
}
587
593
588
- fn filter_by_config ( highlight : & mut Highlight , config : HighlightConfig ) -> bool {
594
+ fn filter_by_config ( highlight : & mut Highlight , config : & HighlightConfig < ' _ > ) -> bool {
589
595
match & mut highlight. tag {
590
596
HlTag :: StringLiteral if !config. strings => return false ,
591
597
// If punctuation is disabled, make the macro bang part of the macro call again.
0 commit comments