Auto merge of #15632 - emilio:scip-build-rs, r=lnicola
scip: Use load_workspace_at. This honors the build script config, and is also simpler.
This commit is contained in:
commit
cdaadb6138
@ -11,10 +11,9 @@
|
|||||||
TokenStaticData,
|
TokenStaticData,
|
||||||
};
|
};
|
||||||
use ide_db::LineIndexDatabase;
|
use ide_db::LineIndexDatabase;
|
||||||
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
|
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
|
||||||
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
|
use project_model::{CargoConfig, RustLibSource};
|
||||||
use scip::types as scip_types;
|
use scip::types as scip_types;
|
||||||
use std::env;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::flags,
|
cli::flags,
|
||||||
@ -34,14 +33,13 @@ pub fn run(self) -> anyhow::Result<()> {
|
|||||||
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
|
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
|
||||||
prefill_caches: true,
|
prefill_caches: true,
|
||||||
};
|
};
|
||||||
let path = vfs::AbsPathBuf::assert(env::current_dir()?.join(&self.path));
|
let root = vfs::AbsPathBuf::assert(std::env::current_dir()?.join(&self.path)).normalize();
|
||||||
let rootpath = path.normalize();
|
let (host, vfs, _) = load_workspace_at(
|
||||||
let manifest = ProjectManifest::discover_single(&path)?;
|
root.as_path().as_ref(),
|
||||||
|
&cargo_config,
|
||||||
let workspace = ProjectWorkspace::load(manifest, &cargo_config, no_progress)?;
|
&load_cargo_config,
|
||||||
|
&no_progress,
|
||||||
let (host, vfs, _) =
|
)?;
|
||||||
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
|
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
let analysis = host.analysis();
|
let analysis = host.analysis();
|
||||||
|
|
||||||
@ -58,8 +56,7 @@ pub fn run(self) -> anyhow::Result<()> {
|
|||||||
.into(),
|
.into(),
|
||||||
project_root: format!(
|
project_root: format!(
|
||||||
"file://{}",
|
"file://{}",
|
||||||
path.normalize()
|
root.as_os_str()
|
||||||
.as_os_str()
|
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or(anyhow::format_err!("Unable to normalize project_root path"))?
|
.ok_or(anyhow::format_err!("Unable to normalize project_root path"))?
|
||||||
),
|
),
|
||||||
@ -80,7 +77,7 @@ pub fn run(self) -> anyhow::Result<()> {
|
|||||||
new_symbol
|
new_symbol
|
||||||
};
|
};
|
||||||
|
|
||||||
let relative_path = match get_relative_filepath(&vfs, &rootpath, file_id) {
|
let relative_path = match get_relative_filepath(&vfs, &root, file_id) {
|
||||||
Some(relative_path) => relative_path,
|
Some(relative_path) => relative_path,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user