Propagating sysroot down + Refactoring

This commit is contained in:
Ddystopia 2023-04-27 18:05:04 +02:00
parent 67e58c5ba6
commit 4ac39f0c98
No known key found for this signature in database
GPG key ID: 109875EC11535212
4 changed files with 66 additions and 35 deletions

View file

@ -20,9 +20,10 @@ fn check_external_docs(
target_dir: Option<&OsStr>,
expect_web_url: Option<Expect>,
expect_local_url: Option<Expect>,
sysroot: Option<&OsStr>,
) {
let (analysis, position) = fixture::position(ra_fixture);
let links = analysis.external_docs(position, target_dir).unwrap();
let links = analysis.external_docs(position, target_dir, sysroot).unwrap();
let web_url = links.web_url;
let local_url = links.local_url;
@ -128,7 +129,8 @@ let x: u3$02 = 0;
"#,
Some(&OsStr::new("/home/user/project")),
Some(expect![[r#"https://doc.rust-lang.org/nightly/core/primitive.u32.html"#]]),
None,
Some(expect![[r#"file:///sysroot/share/doc/rust/html/core/primitive.u32.html"#]]),
Some(&OsStr::new("/sysroot")),
);
}
@ -144,6 +146,7 @@ pub struct Foo;
Some(&OsStr::new("/home/user/project")),
Some(expect![[r#"https://docs.rs/foo/*/foo/index.html"#]]),
Some(expect![[r#"file:///home/user/project/doc/foo/index.html"#]]),
Some(&OsStr::new("/sysroot")),
);
}
@ -156,7 +159,8 @@ use self$0;
"#,
Some(&OsStr::new("/home/user/project")),
Some(expect!["https://doc.rust-lang.org/stable/std/index.html"]),
None,
Some(expect!["file:///sysroot/share/doc/rust/html/std/index.html"]),
Some(&OsStr::new("/sysroot")),
);
}
@ -170,6 +174,7 @@ pub struct Fo$0o;
Some(&OsStr::new("/home/user/project")),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///home/user/project/doc/foo/struct.Foo.html"#]]),
Some(&OsStr::new("/sysroot")),
);
}
@ -183,6 +188,7 @@ pub struct Fo$0o;
Some(&OsStr::new(r"C:\Users\user\project")),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///C:/Users/user/project/doc/foo/struct.Foo.html"#]]),
Some(&OsStr::new("/sysroot")),
);
}
@ -196,6 +202,7 @@ pub struct Fo$0o;
Some(&OsStr::new(r"C:/Users/user/project")),
Some(expect![[r#"https://docs.rs/foo/*/foo/struct.Foo.html"#]]),
Some(expect![[r#"file:///C:/Users/user/project/doc/foo/struct.Foo.html"#]]),
Some(&OsStr::new("/sysroot")),
);
}
@ -211,6 +218,7 @@ pub struct Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#structfield.field"##]]),
None,
None,
);
}
@ -224,6 +232,7 @@ pub fn fo$0o() {}
None,
Some(expect![[r#"https://docs.rs/foo/*/foo/fn.foo.html"#]]),
None,
None,
);
}
@ -240,6 +249,7 @@ impl Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#method.method"##]]),
None,
None,
);
check_external_docs(
r#"
@ -252,6 +262,7 @@ impl Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#associatedconstant.CONST"##]]),
None,
None,
);
}
@ -271,6 +282,7 @@ impl Trait for Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#method.method"##]]),
None,
None,
);
check_external_docs(
r#"
@ -286,6 +298,7 @@ impl Trait for Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#associatedconstant.CONST"##]]),
None,
None,
);
check_external_docs(
r#"
@ -301,6 +314,7 @@ impl Trait for Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/struct.Foo.html#associatedtype.Type"##]]),
None,
None,
);
}
@ -316,6 +330,7 @@ pub trait Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/trait.Foo.html#tymethod.method"##]]),
None,
None,
);
check_external_docs(
r#"
@ -327,6 +342,7 @@ pub trait Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/trait.Foo.html#associatedconstant.CONST"##]]),
None,
None,
);
check_external_docs(
r#"
@ -338,6 +354,7 @@ pub trait Foo {
None,
Some(expect![[r##"https://docs.rs/foo/*/foo/trait.Foo.html#associatedtype.Type"##]]),
None,
None,
);
}
@ -351,6 +368,7 @@ trait Trait$0 {}
None,
Some(expect![[r#"https://docs.rs/foo/*/foo/trait.Trait.html"#]]),
None,
None,
)
}
@ -366,6 +384,7 @@ pub mod foo {
None,
Some(expect![[r#"https://docs.rs/foo/*/foo/foo/bar/index.html"#]]),
None,
None,
)
}
@ -389,6 +408,7 @@ fn foo() {
None,
Some(expect![[r#"https://docs.rs/foo/*/foo/wrapper/module/struct.Item.html"#]]),
None,
None,
)
}