Rename declaration_name -> display_name

Declaration names sounds like a name of declaration -- something you
can use for analysis. It empathically isn't, and is just a label
displayed in various UI. It's important not to confuse the two, least
we accidentally mix semantics with UI (I believe, there's already a
case of this in the FamousDefs at least).
This commit is contained in:
Aleksey Kladov 2020-10-20 15:38:11 +02:00
parent be762ccccd
commit af4e75533f
11 changed files with 28 additions and 35 deletions

View file

@ -130,7 +130,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
let module = definition.module(db)?;
let krate = module.krate();
let import_map = db.import_map(krate.into());
let base = once(krate.declaration_name(db)?.to_string())
let base = once(krate.display_name(db)?.to_string())
.chain(import_map.path_of(ns)?.segments.iter().map(|name| name.to_string()))
.join("/");
@ -188,7 +188,7 @@ fn rewrite_intra_doc_link(
let krate = resolved.module(db)?.krate();
let canonical_path = resolved.canonical_path(db)?;
let new_target = get_doc_url(db, &krate)?
.join(&format!("{}/", krate.declaration_name(db)?))
.join(&format!("{}/", krate.display_name(db)?))
.ok()?
.join(&canonical_path.replace("::", "/"))
.ok()?
@ -208,7 +208,7 @@ fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<S
let module = def.module(db)?;
let krate = module.krate();
let canonical_path = def.canonical_path(db)?;
let base = format!("{}/{}", krate.declaration_name(db)?, canonical_path.replace("::", "/"));
let base = format!("{}/{}", krate.display_name(db)?, canonical_path.replace("::", "/"));
get_doc_url(db, &krate)
.and_then(|url| url.join(&base).ok())
@ -357,7 +357,7 @@ fn get_doc_url(db: &RootDatabase, krate: &Crate) -> Option<Url> {
//
// FIXME: clicking on the link should just open the file in the editor,
// instead of falling back to external urls.
Some(format!("https://docs.rs/{}/*/", krate.declaration_name(db)?))
Some(format!("https://docs.rs/{}/*/", krate.display_name(db)?))
})
.and_then(|s| Url::parse(&s).ok())
}