mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Remove temporary FixtureEntry parsed_meta field.
This commit is contained in:
parent
d901e0e709
commit
256fb7556e
4 changed files with 10 additions and 11 deletions
|
@ -99,7 +99,7 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId
|
|||
let fixture = parse_single_fixture(ra_fixture);
|
||||
|
||||
let crate_graph = if let Some(entry) = fixture {
|
||||
let meta = match ParsedMeta::from(&entry.parsed_meta) {
|
||||
let meta = match ParsedMeta::from(&entry.meta) {
|
||||
ParsedMeta::File(it) => it,
|
||||
_ => panic!("with_single_file only support file meta"),
|
||||
};
|
||||
|
@ -156,7 +156,7 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit
|
|||
let mut file_position = None;
|
||||
|
||||
for entry in fixture.iter() {
|
||||
let meta = match ParsedMeta::from(&entry.parsed_meta) {
|
||||
let meta = match ParsedMeta::from(&entry.meta) {
|
||||
ParsedMeta::Root { path } => {
|
||||
let source_root = std::mem::replace(&mut source_root, SourceRoot::new_local());
|
||||
db.set_source_root(source_root_id, Arc::new(source_root));
|
||||
|
|
|
@ -35,7 +35,7 @@ impl MockAnalysis {
|
|||
pub fn with_files(fixture: &str) -> MockAnalysis {
|
||||
let mut res = MockAnalysis::new();
|
||||
for entry in parse_fixture(fixture) {
|
||||
res.add_file(&entry.meta, &entry.text);
|
||||
res.add_file(entry.meta.path().as_str(), &entry.text);
|
||||
}
|
||||
res
|
||||
}
|
||||
|
@ -48,9 +48,10 @@ impl MockAnalysis {
|
|||
for entry in parse_fixture(fixture) {
|
||||
if entry.text.contains(CURSOR_MARKER) {
|
||||
assert!(position.is_none(), "only one marker (<|>) per fixture is allowed");
|
||||
position = Some(res.add_file_with_position(&entry.meta, &entry.text));
|
||||
position =
|
||||
Some(res.add_file_with_position(&entry.meta.path().as_str(), &entry.text));
|
||||
} else {
|
||||
res.add_file(&entry.meta, &entry.text);
|
||||
res.add_file(&entry.meta.path().as_str(), &entry.text);
|
||||
}
|
||||
}
|
||||
let position = position.expect("expected a marker (<|>)");
|
||||
|
|
|
@ -68,7 +68,7 @@ impl<'a> Project<'a> {
|
|||
let mut paths = vec![];
|
||||
|
||||
for entry in parse_fixture(self.fixture) {
|
||||
let path = tmp_dir.path().join(entry.meta);
|
||||
let path = tmp_dir.path().join(entry.meta.path().as_str());
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
fs::write(path.as_path(), entry.text.as_bytes()).unwrap();
|
||||
paths.push((path, entry.text));
|
||||
|
|
|
@ -161,10 +161,8 @@ pub fn add_cursor(text: &str, offset: TextSize) -> String {
|
|||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct FixtureEntry {
|
||||
pub meta: String,
|
||||
pub meta: FixtureMeta,
|
||||
pub text: String,
|
||||
|
||||
pub parsed_meta: FixtureMeta,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
@ -231,8 +229,8 @@ The offending line: {:?}"#,
|
|||
for line in lines.by_ref() {
|
||||
if line.starts_with("//-") {
|
||||
let meta = line["//-".len()..].trim().to_string();
|
||||
let parsed_meta = parse_meta(&meta);
|
||||
res.push(FixtureEntry { meta, parsed_meta, text: String::new() })
|
||||
let meta = parse_meta(&meta);
|
||||
res.push(FixtureEntry { meta, text: String::new() })
|
||||
} else if let Some(entry) = res.last_mut() {
|
||||
entry.text.push_str(line);
|
||||
entry.text.push('\n');
|
||||
|
|
Loading…
Reference in a new issue