mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
thread info about dep names
This commit is contained in:
parent
ca7e5905c1
commit
961cae7e53
@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::{FxHashSet, FxHashMap};
|
||||||
use rustc_hash::FxHashSet;
|
use ra_syntax::SmolStr;
|
||||||
use salsa;
|
use salsa;
|
||||||
|
|
||||||
use crate::file_resolver::FileResolverImp;
|
use crate::file_resolver::FileResolverImp;
|
||||||
@ -31,14 +31,15 @@ impl CrateData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_dep(&mut self, dep: CrateId) {
|
fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) {
|
||||||
self.dependencies.push(Dependency { crate_id: dep })
|
self.dependencies.push(Dependency { name, crate_id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Dependency {
|
pub struct Dependency {
|
||||||
crate_id: CrateId,
|
crate_id: CrateId,
|
||||||
|
name: SmolStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dependency {
|
impl Dependency {
|
||||||
@ -57,8 +58,8 @@ impl CrateGraph {
|
|||||||
//FIXME: check that we don't have cycles here.
|
//FIXME: check that we don't have cycles here.
|
||||||
// Just a simple depth first search from `to` should work,
|
// Just a simple depth first search from `to` should work,
|
||||||
// the graph is small.
|
// the graph is small.
|
||||||
pub fn add_dep(&mut self, from: CrateId, to: CrateId) {
|
pub fn add_dep(&mut self, from: CrateId, name: SmolStr, to: CrateId) {
|
||||||
self.arena.get_mut(&from).unwrap().add_dep(to)
|
self.arena.get_mut(&from).unwrap().add_dep(name, to)
|
||||||
}
|
}
|
||||||
pub fn crate_root(&self, crate_id: CrateId) -> FileId {
|
pub fn crate_root(&self, crate_id: CrateId) -> FileId {
|
||||||
self.arena[&crate_id].file_id
|
self.arena[&crate_id].file_id
|
||||||
|
@ -34,7 +34,13 @@ struct PackageData {
|
|||||||
manifest: PathBuf,
|
manifest: PathBuf,
|
||||||
targets: Vec<Target>,
|
targets: Vec<Target>,
|
||||||
is_member: bool,
|
is_member: bool,
|
||||||
dependencies: Vec<Package>,
|
dependencies: Vec<PackageDependency>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct PackageDependency {
|
||||||
|
pub pkg: Package,
|
||||||
|
pub name: SmolStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -68,8 +74,11 @@ impl Package {
|
|||||||
pub fn is_member(self, ws: &CargoWorkspace) -> bool {
|
pub fn is_member(self, ws: &CargoWorkspace) -> bool {
|
||||||
ws.pkg(self).is_member
|
ws.pkg(self).is_member
|
||||||
}
|
}
|
||||||
pub fn dependencies<'a>(self, ws: &'a CargoWorkspace) -> impl Iterator<Item = Package> + 'a {
|
pub fn dependencies<'a>(
|
||||||
ws.pkg(self).dependencies.iter().cloned()
|
self,
|
||||||
|
ws: &'a CargoWorkspace,
|
||||||
|
) -> impl Iterator<Item = &'a PackageDependency> + 'a {
|
||||||
|
ws.pkg(self).dependencies.iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +144,9 @@ impl CargoWorkspace {
|
|||||||
let source = pkg_by_id[&node.id];
|
let source = pkg_by_id[&node.id];
|
||||||
for id in node.dependencies {
|
for id in node.dependencies {
|
||||||
let target = pkg_by_id[&id];
|
let target = pkg_by_id[&id];
|
||||||
packages[source.0].dependencies.push(target);
|
let name: SmolStr = packages[target.0].name.replace('-', "_").into();
|
||||||
|
let dep = PackageDependency { name, pkg: target };
|
||||||
|
packages[source.0].dependencies.push(dep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,9 +162,9 @@ impl ServerWorldState {
|
|||||||
}
|
}
|
||||||
for pkg in ws.packages() {
|
for pkg in ws.packages() {
|
||||||
for dep in pkg.dependencies(ws) {
|
for dep in pkg.dependencies(ws) {
|
||||||
if let Some(&to) = pkg_to_lib_crate.get(&dep) {
|
if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) {
|
||||||
for &from in pkg_crates.get(&pkg).into_iter().flatten() {
|
for &from in pkg_crates.get(&pkg).into_iter().flatten() {
|
||||||
crate_graph.add_dep(from, to);
|
crate_graph.add_dep(from, dep.name.clone(), to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user