Skip to content

Commit

Permalink
Auto merge of #15632 - emilio:scip-build-rs, r=lnicola
Browse files Browse the repository at this point in the history
scip: Use load_workspace_at.

This honors the build script config, and is also simpler.
  • Loading branch information
bors committed Sep 19, 2023
2 parents 258b15c + c372431 commit cdaadb6
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions crates/rust-analyzer/src/cli/scip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ use ide::{
TokenStaticData,
};
use ide_db::LineIndexDatabase;
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
use project_model::{CargoConfig, RustLibSource};
use scip::types as scip_types;
use std::env;

use crate::{
cli::flags,
Expand All @@ -34,14 +33,13 @@ impl flags::Scip {
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
prefill_caches: true,
};
let path = vfs::AbsPathBuf::assert(env::current_dir()?.join(&self.path));
let rootpath = path.normalize();
let manifest = ProjectManifest::discover_single(&path)?;

let workspace = ProjectWorkspace::load(manifest, &cargo_config, no_progress)?;

let (host, vfs, _) =
load_workspace(workspace, &cargo_config.extra_env, &load_cargo_config)?;
let root = vfs::AbsPathBuf::assert(std::env::current_dir()?.join(&self.path)).normalize();
let (host, vfs, _) = load_workspace_at(
root.as_path().as_ref(),
&cargo_config,
&load_cargo_config,
&no_progress,
)?;
let db = host.raw_database();
let analysis = host.analysis();

Expand All @@ -58,8 +56,7 @@ impl flags::Scip {
.into(),
project_root: format!(
"file://{}",
path.normalize()
.as_os_str()
root.as_os_str()
.to_str()
.ok_or(anyhow::format_err!("Unable to normalize project_root path"))?
),
Expand All @@ -80,7 +77,7 @@ impl flags::Scip {
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,
None => continue,
};
Expand Down

0 comments on commit cdaadb6

Please sign in to comment.