From 5452368fad8ee8d03d980de47604fa108111ea57 Mon Sep 17 00:00:00 2001 From: Zac Pullar-Strecker Date: Mon, 24 Aug 2020 21:50:30 +1200 Subject: Renames, comments, and dead code removal --- crates/hir/src/code_model.rs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'crates/hir/src/code_model.rs') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 9395efe4f..bd80102fa 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -43,8 +43,8 @@ use tt::{Ident, Leaf, Literal, TokenTree}; use crate::{ db::{DefDatabase, HirDatabase}, + doc_links::Resolvable, has_source::HasSource, - link_rewrite::Resolvable, HirDisplay, InFile, Name, }; @@ -234,23 +234,6 @@ impl ModuleDef { ModuleDef::BuiltinType(it) => Some(it.as_name()), } } - - pub fn resolver(&self, db: &D) -> Option { - Some(match self { - ModuleDef::Module(m) => ModuleId::from(m.clone()).resolver(db), - ModuleDef::Function(f) => FunctionId::from(f.clone()).resolver(db), - ModuleDef::Adt(adt) => AdtId::from(adt.clone()).resolver(db), - ModuleDef::EnumVariant(ev) => { - GenericDefId::from(GenericDef::from(ev.clone())).resolver(db) - } - ModuleDef::Const(c) => GenericDefId::from(GenericDef::from(c.clone())).resolver(db), - ModuleDef::Static(s) => StaticId::from(s.clone()).resolver(db), - ModuleDef::Trait(t) => TraitId::from(t.clone()).resolver(db), - ModuleDef::TypeAlias(t) => ModuleId::from(t.module(db)).resolver(db), - // FIXME: This should be a resolver relative to `std/core` - ModuleDef::BuiltinType(_t) => None?, - }) - } } pub use hir_def::{ -- cgit v1.2.3 From 452afaebe188251cd4403e56999bf8b58de4fba9 Mon Sep 17 00:00:00 2001 From: Zac Pullar-Strecker Date: Tue, 25 Aug 2020 16:40:43 +1200 Subject: Changes from review --- crates/hir/src/code_model.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'crates/hir/src/code_model.rs') diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index bd80102fa..94dd7f6f5 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -126,13 +126,16 @@ impl Crate { } /// Try to get the root URL of the documentation of a crate. - pub fn get_doc_url(self: &Crate, db: &dyn HirDatabase) -> Option { + pub fn get_html_root_url(self: &Crate, db: &dyn HirDatabase) -> Option { // Look for #![doc(html_root_url = "...")] let attrs = db.attrs(AttrDef::from(self.root_module(db)).into()); let doc_attr_q = attrs.by_key("doc"); - let doc_url = if doc_attr_q.exists() { - doc_attr_q.tt_values().map(|tt| { + if !doc_attr_q.exists() { + return None; + } + + let doc_url = doc_attr_q.tt_values().map(|tt| { let name = tt.token_trees.iter() .skip_while(|tt| !matches!(tt, TokenTree::Leaf(Leaf::Ident(Ident{text: ref ident, ..})) if ident == "html_root_url")) .skip(2) @@ -142,14 +145,9 @@ impl Crate { Some(TokenTree::Leaf(Leaf::Literal(Literal{ref text, ..}))) => Some(text), _ => None } - }).flat_map(|t| t).next().map(|s| s.to_string()) - } else { - None - }; + }).flat_map(|t| t).next(); - doc_url - .map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/") - .map(|s| s.to_string()) + doc_url.map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/") } } -- cgit v1.2.3