Drop rarely used fixture functionality
This commit is contained in:
parent
f304874c8c
commit
6996ec860b
@ -114,7 +114,6 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId
|
|||||||
let crate_graph = if let Some(entry) = fixture {
|
let crate_graph = if let Some(entry) = fixture {
|
||||||
let meta = match ParsedMeta::from(&entry.meta) {
|
let meta = match ParsedMeta::from(&entry.meta) {
|
||||||
ParsedMeta::File(it) => it,
|
ParsedMeta::File(it) => it,
|
||||||
_ => panic!("with_single_file only support file meta"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut crate_graph = CrateGraph::default();
|
let mut crate_graph = CrateGraph::default();
|
||||||
@ -159,21 +158,14 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit
|
|||||||
let mut default_crate_root: Option<FileId> = None;
|
let mut default_crate_root: Option<FileId> = None;
|
||||||
|
|
||||||
let mut file_set = FileSet::default();
|
let mut file_set = FileSet::default();
|
||||||
let mut source_root_id = WORKSPACE;
|
let source_root_id = WORKSPACE;
|
||||||
let mut source_root_prefix = "/".to_string();
|
let source_root_prefix = "/".to_string();
|
||||||
let mut file_id = FileId(0);
|
let mut file_id = FileId(0);
|
||||||
|
|
||||||
let mut file_position = None;
|
let mut file_position = None;
|
||||||
|
|
||||||
for entry in fixture.iter() {
|
for entry in fixture.iter() {
|
||||||
let meta = match ParsedMeta::from(&entry.meta) {
|
let meta = match ParsedMeta::from(&entry.meta) {
|
||||||
ParsedMeta::Root { path } => {
|
|
||||||
let file_set = std::mem::replace(&mut file_set, FileSet::default());
|
|
||||||
db.set_source_root(source_root_id, Arc::new(SourceRoot::new_local(file_set)));
|
|
||||||
source_root_id.0 += 1;
|
|
||||||
source_root_prefix = path;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ParsedMeta::File(it) => it,
|
ParsedMeta::File(it) => it,
|
||||||
};
|
};
|
||||||
assert!(meta.path.starts_with(&source_root_prefix));
|
assert!(meta.path.starts_with(&source_root_prefix));
|
||||||
@ -239,7 +231,6 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option<FilePosit
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ParsedMeta {
|
enum ParsedMeta {
|
||||||
Root { path: String },
|
|
||||||
File(FileMeta),
|
File(FileMeta),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +246,6 @@ struct FileMeta {
|
|||||||
impl From<&FixtureMeta> for ParsedMeta {
|
impl From<&FixtureMeta> for ParsedMeta {
|
||||||
fn from(meta: &FixtureMeta) -> Self {
|
fn from(meta: &FixtureMeta) -> Self {
|
||||||
match meta {
|
match meta {
|
||||||
FixtureMeta::Root { path } => {
|
|
||||||
// `Self::Root` causes a false warning: 'variant is never constructed: `Root` '
|
|
||||||
// see https://github.com/rust-lang/rust/issues/69018
|
|
||||||
ParsedMeta::Root { path: path.to_owned() }
|
|
||||||
}
|
|
||||||
FixtureMeta::File(f) => Self::File(FileMeta {
|
FixtureMeta::File(f) => Self::File(FileMeta {
|
||||||
path: f.path.to_owned(),
|
path: f.path.to_owned(),
|
||||||
krate: f.crate_name.to_owned(),
|
krate: f.crate_name.to_owned(),
|
||||||
|
@ -423,31 +423,6 @@ fn extern_crate_rename_2015_edition() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn import_across_source_roots() {
|
|
||||||
let map = def_map(
|
|
||||||
"
|
|
||||||
//- /main.rs crate:main deps:test_crate
|
|
||||||
use test_crate::a::b::C;
|
|
||||||
|
|
||||||
//- root /test_crate/
|
|
||||||
|
|
||||||
//- /test_crate/lib.rs crate:test_crate
|
|
||||||
pub mod a {
|
|
||||||
pub mod b {
|
|
||||||
pub struct C;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
",
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_snapshot!(map, @r###"
|
|
||||||
⋮crate
|
|
||||||
⋮C: t v
|
|
||||||
"###);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reexport_across_crates() {
|
fn reexport_across_crates() {
|
||||||
let map = def_map(
|
let map = def_map(
|
||||||
|
@ -10,7 +10,6 @@ pub struct FixtureEntry {
|
|||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum FixtureMeta {
|
pub enum FixtureMeta {
|
||||||
Root { path: String },
|
|
||||||
File(FileMeta),
|
File(FileMeta),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ pub struct FileMeta {
|
|||||||
impl FixtureMeta {
|
impl FixtureMeta {
|
||||||
pub fn path(&self) -> &str {
|
pub fn path(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
FixtureMeta::Root { path } => &path,
|
|
||||||
FixtureMeta::File(f) => &f.path,
|
FixtureMeta::File(f) => &f.path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,21 +33,18 @@ pub fn path(&self) -> &str {
|
|||||||
pub fn crate_name(&self) -> Option<&String> {
|
pub fn crate_name(&self) -> Option<&String> {
|
||||||
match self {
|
match self {
|
||||||
FixtureMeta::File(f) => f.crate_name.as_ref(),
|
FixtureMeta::File(f) => f.crate_name.as_ref(),
|
||||||
_ => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cfg_options(&self) -> Option<&CfgOptions> {
|
pub fn cfg_options(&self) -> Option<&CfgOptions> {
|
||||||
match self {
|
match self {
|
||||||
FixtureMeta::File(f) => Some(&f.cfg),
|
FixtureMeta::File(f) => Some(&f.cfg),
|
||||||
_ => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edition(&self) -> Option<&String> {
|
pub fn edition(&self) -> Option<&String> {
|
||||||
match self {
|
match self {
|
||||||
FixtureMeta::File(f) => f.edition.as_ref(),
|
FixtureMeta::File(f) => f.edition.as_ref(),
|
||||||
_ => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +58,6 @@ fn new(meta: &'a FixtureMeta) -> Self {
|
|||||||
Self {
|
Self {
|
||||||
iter: match meta {
|
iter: match meta {
|
||||||
FixtureMeta::File(f) => Some(f.env.iter()),
|
FixtureMeta::File(f) => Some(f.env.iter()),
|
||||||
_ => None,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,12 +140,6 @@ pub fn parse_fixture(ra_fixture: &str) -> Vec<FixtureEntry> {
|
|||||||
fn parse_meta(meta: &str) -> FixtureMeta {
|
fn parse_meta(meta: &str) -> FixtureMeta {
|
||||||
let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
|
let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
|
||||||
|
|
||||||
if components[0] == "root" {
|
|
||||||
let path = components[1].to_string();
|
|
||||||
assert!(path.starts_with("/") && path.ends_with("/"));
|
|
||||||
return FixtureMeta::Root { path };
|
|
||||||
}
|
|
||||||
|
|
||||||
let path = components[0].to_string();
|
let path = components[0].to_string();
|
||||||
assert!(path.starts_with("/"));
|
assert!(path.starts_with("/"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user