mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Move highlight configuration from protocol into the feature
This commit is contained in:
parent
afc8cfb4d1
commit
9a201873b8
8 changed files with 119 additions and 86 deletions
|
@ -4,7 +4,16 @@ use expect_test::{expect_file, ExpectFile};
|
|||
use ide_db::SymbolKind;
|
||||
use test_utils::{bench, bench_fixture, skip_slow_tests, AssertLinear};
|
||||
|
||||
use crate::{fixture, FileRange, HlTag, TextRange};
|
||||
use crate::{fixture, FileRange, HighlightConfig, HlTag, TextRange};
|
||||
|
||||
const HL_CONFIG: HighlightConfig = HighlightConfig {
|
||||
strings: true,
|
||||
punctuation: true,
|
||||
specialize_punctuation: true,
|
||||
specialize_operator: true,
|
||||
operator: true,
|
||||
syntactic_name_ref_highlighting: false,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn attributes() {
|
||||
|
@ -996,7 +1005,10 @@ struct Foo {
|
|||
|
||||
// The "x"
|
||||
let highlights = &analysis
|
||||
.highlight_range(FileRange { file_id, range: TextRange::at(45.into(), 1.into()) })
|
||||
.highlight_range(
|
||||
HL_CONFIG,
|
||||
FileRange { file_id, range: TextRange::at(45.into(), 1.into()) },
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(&highlights[0].highlight.to_string(), "field.declaration.public");
|
||||
|
@ -1011,7 +1023,7 @@ macro_rules! test {}
|
|||
}"#
|
||||
.trim(),
|
||||
);
|
||||
let _ = analysis.highlight(file_id).unwrap();
|
||||
let _ = analysis.highlight(HL_CONFIG, file_id).unwrap();
|
||||
}
|
||||
|
||||
/// Highlights the code given by the `ra_fixture` argument, renders the
|
||||
|
@ -1035,7 +1047,7 @@ fn benchmark_syntax_highlighting_long_struct() {
|
|||
let hash = {
|
||||
let _pt = bench("syntax highlighting long struct");
|
||||
analysis
|
||||
.highlight(file_id)
|
||||
.highlight(HL_CONFIG, file_id)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Struct))
|
||||
|
@ -1061,7 +1073,7 @@ fn syntax_highlighting_not_quadratic() {
|
|||
let time = Instant::now();
|
||||
|
||||
let hash = analysis
|
||||
.highlight(file_id)
|
||||
.highlight(HL_CONFIG, file_id)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Struct))
|
||||
|
@ -1086,7 +1098,7 @@ fn benchmark_syntax_highlighting_parser() {
|
|||
let hash = {
|
||||
let _pt = bench("syntax highlighting parser");
|
||||
analysis
|
||||
.highlight(file_id)
|
||||
.highlight(HL_CONFIG, file_id)
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Function))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue