mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
feature: move linked_projects
discovery to the rust-analyzer server
This commit is contained in:
parent
cf156a7a43
commit
db43a5a6e9
22 changed files with 877 additions and 169 deletions
|
@ -276,6 +276,16 @@ impl ProjectJson {
|
|||
self.manifest.as_ref()
|
||||
}
|
||||
|
||||
pub fn crate_by_buildfile(&self, path: &AbsPath) -> Option<Build> {
|
||||
// this is fast enough for now, but it's unfortunate that this is O(crates).
|
||||
let path: &std::path::Path = path.as_ref();
|
||||
self.crates
|
||||
.iter()
|
||||
.filter(|krate| krate.is_workspace_member)
|
||||
.filter_map(|krate| krate.build.clone())
|
||||
.find(|build| build.build_file.as_std_path() == path)
|
||||
}
|
||||
|
||||
/// Returns the path to the project's manifest or root folder, if no manifest exists.
|
||||
pub fn manifest_or_root(&self) -> &AbsPath {
|
||||
self.manifest.as_ref().map_or(&self.project_root, |manifest| manifest.as_ref())
|
||||
|
@ -286,7 +296,7 @@ impl ProjectJson {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
pub struct ProjectJsonData {
|
||||
sysroot: Option<Utf8PathBuf>,
|
||||
sysroot_src: Option<Utf8PathBuf>,
|
||||
|
@ -295,7 +305,7 @@ pub struct ProjectJsonData {
|
|||
runnables: Vec<RunnableData>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
struct CrateData {
|
||||
display_name: Option<String>,
|
||||
root_module: Utf8PathBuf,
|
||||
|
@ -319,7 +329,7 @@ struct CrateData {
|
|||
build: Option<BuildData>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename = "edition")]
|
||||
enum EditionData {
|
||||
#[serde(rename = "2015")]
|
||||
|
@ -332,7 +342,7 @@ enum EditionData {
|
|||
Edition2024,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub struct BuildData {
|
||||
label: String,
|
||||
build_file: Utf8PathBuf,
|
||||
|
@ -419,7 +429,7 @@ pub(crate) struct Dep {
|
|||
pub(crate) name: CrateName,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
struct CrateSource {
|
||||
include_dirs: Vec<Utf8PathBuf>,
|
||||
exclude_dirs: Vec<Utf8PathBuf>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue