More symbol usage

This commit is contained in:
Lukas Wirth 2024-07-16 12:05:16 +02:00
parent c30bdfcc84
commit df5f1777b8
50 changed files with 388 additions and 303 deletions

View file

@ -11,7 +11,8 @@ use stdx::format_to;
use url::Url;
use hir::{
db::HirDatabase, Adt, AsAssocItem, AssocItem, AssocItemContainer, DescendPreference, HasAttrs,
db::HirDatabase, sym, Adt, AsAssocItem, AssocItem, AssocItemContainer, DescendPreference,
HasAttrs,
};
use ide_db::{
base_db::{CrateOrigin, LangCrateOrigin, ReleaseChannel, SourceDatabase},
@ -593,12 +594,14 @@ fn filename_and_frag_for_def(
},
Definition::Module(m) => match m.name(db) {
// `#[doc(keyword = "...")]` is internal used only by rust compiler
Some(name) => match m.attrs(db).by_key("doc").find_string_value_in_tt("keyword") {
Some(kw) => {
format!("keyword.{}.html", kw.trim_matches('"'))
Some(name) => {
match m.attrs(db).by_key(&sym::doc).find_string_value_in_tt(&sym::keyword) {
Some(kw) => {
format!("keyword.{}.html", kw)
}
None => format!("{}/index.html", name.display(db.upcast())),
}
None => format!("{}/index.html", name.display(db.upcast())),
},
}
None => String::from("index.html"),
},
Definition::Trait(t) => format!("trait.{}.html", t.name(db).display(db.upcast())),