mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
status: output all crates a file belongs to
This commit is contained in:
parent
1861654623
commit
a3d06f824b
1 changed files with 17 additions and 17 deletions
|
@ -45,10 +45,12 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option<FileId>) -> String {
|
||||||
|
|
||||||
if let Some(file_id) = file_id {
|
if let Some(file_id) = file_id {
|
||||||
format_to!(buf, "\nFile info:\n");
|
format_to!(buf, "\nFile info:\n");
|
||||||
let krate = crate::parent_module::crate_for(db, file_id).pop();
|
let crates = crate::parent_module::crate_for(db, file_id);
|
||||||
match krate {
|
if crates.is_empty() {
|
||||||
Some(krate) => {
|
format_to!(buf, "Does not belong to any crate");
|
||||||
|
}
|
||||||
let crate_graph = db.crate_graph();
|
let crate_graph = db.crate_graph();
|
||||||
|
for krate in crates {
|
||||||
let display_crate = |krate: CrateId| match &crate_graph[krate].display_name {
|
let display_crate = |krate: CrateId| match &crate_graph[krate].display_name {
|
||||||
Some(it) => format!("{}({:?})", it, krate),
|
Some(it) => format!("{}({:?})", it, krate),
|
||||||
None => format!("{:?}", krate),
|
None => format!("{:?}", krate),
|
||||||
|
@ -61,8 +63,6 @@ pub(crate) fn status(db: &RootDatabase, file_id: Option<FileId>) -> String {
|
||||||
.format(", ");
|
.format(", ");
|
||||||
format_to!(buf, "Dependencies: {}\n", deps);
|
format_to!(buf, "Dependencies: {}\n", deps);
|
||||||
}
|
}
|
||||||
None => format_to!(buf, "Does not belong to any crate"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.trim().to_string()
|
buf.trim().to_string()
|
||||||
|
|
Loading…
Reference in a new issue