mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
JFF, ra_fixture arg name for a code highlighting
This commit is contained in:
parent
7e9c7ac4ee
commit
cd45c73b66
1 changed files with 11 additions and 9 deletions
|
@ -245,8 +245,8 @@ impl FixtureMeta {
|
||||||
/// line 2
|
/// line 2
|
||||||
/// // - other meta
|
/// // - other meta
|
||||||
/// ```
|
/// ```
|
||||||
pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
|
pub fn parse_fixture(ra_fixture: &str) -> Vec<FixtureEntry> {
|
||||||
let fixture = indent_first_line(fixture);
|
let fixture = indent_first_line(ra_fixture);
|
||||||
let margin = fixture_margin(&fixture);
|
let margin = fixture_margin(&fixture);
|
||||||
|
|
||||||
let mut lines = fixture
|
let mut lines = fixture
|
||||||
|
@ -418,14 +418,16 @@ struct Bar;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_fixture_gets_full_meta() {
|
fn parse_fixture_gets_full_meta() {
|
||||||
let fixture = r"
|
let parsed = parse_fixture(
|
||||||
|
r"
|
||||||
//- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo
|
//- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b,atom env:OUTDIR=path/to,OTHER=foo
|
||||||
";
|
mod m;
|
||||||
let parsed = parse_fixture(fixture);
|
",
|
||||||
|
);
|
||||||
assert_eq!(1, parsed.len());
|
assert_eq!(1, parsed.len());
|
||||||
|
|
||||||
let parsed = &parsed[0];
|
let parsed = &parsed[0];
|
||||||
assert_eq!("\n", parsed.text);
|
assert_eq!("mod m;\n\n", parsed.text);
|
||||||
|
|
||||||
let meta = &parsed.meta;
|
let meta = &parsed.meta;
|
||||||
assert_eq!("foo", meta.crate_name().unwrap());
|
assert_eq!("foo", meta.crate_name().unwrap());
|
||||||
|
@ -435,12 +437,12 @@ fn parse_fixture_gets_full_meta() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Same as `parse_fixture`, except it allow empty fixture
|
/// Same as `parse_fixture`, except it allow empty fixture
|
||||||
pub fn parse_single_fixture(fixture: &str) -> Option<FixtureEntry> {
|
pub fn parse_single_fixture(ra_fixture: &str) -> Option<FixtureEntry> {
|
||||||
if !fixture.lines().any(|it| it.trim_start().starts_with("//-")) {
|
if !ra_fixture.lines().any(|it| it.trim_start().starts_with("//-")) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let fixtures = parse_fixture(fixture);
|
let fixtures = parse_fixture(ra_fixture);
|
||||||
if fixtures.len() > 1 {
|
if fixtures.len() > 1 {
|
||||||
panic!("too many fixtures");
|
panic!("too many fixtures");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue