Re-implement rust string highlighting via tool attribute

This commit is contained in:
Lukas Wirth 2025-01-10 13:49:35 +01:00
parent 897f7e579e
commit bf669dab84
72 changed files with 386 additions and 173 deletions

View file

@ -990,7 +990,7 @@ impl t for foo {
fn test_injection() {
check_highlighting(
r##"
fn fixture(ra_fixture: &str) {}
fn fixture(#[rust_analyzer::rust_fixture] ra_fixture: &str) {}
fn main() {
fixture(r#"
@ -1188,7 +1188,11 @@ fn foo(x: &fn(&dyn Trait)) {}
/// Highlights the code given by the `ra_fixture` argument, renders the
/// result as HTML, and compares it with the HTML file given as `snapshot`.
/// Note that the `snapshot` file is overwritten by the rendered HTML.
fn check_highlighting(ra_fixture: &str, expect: ExpectFile, rainbow: bool) {
fn check_highlighting(
#[rust_analyzer::rust_fixture] ra_fixture: &str,
expect: ExpectFile,
rainbow: bool,
) {
let (analysis, file_id) = fixture::file(ra_fixture.trim());
let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap();
expect.assert_eq(actual_html)