aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-08-24 10:50:30 +0100
committerZac Pullar-Strecker <[email protected]>2020-08-24 10:50:30 +0100
commit5452368fad8ee8d03d980de47604fa108111ea57 (patch)
tree6ee0a7d37456c210e0f0a65d4b9656ace534740f /crates/hir
parent7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (diff)
Renames, comments, and dead code removal
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/code_model.rs19
-rw-r--r--crates/hir/src/doc_links.rs (renamed from crates/hir/src/link_rewrite.rs)4
-rw-r--r--crates/hir/src/lib.rs4
3 files changed, 5 insertions, 22 deletions
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};
43 43
44use crate::{ 44use crate::{
45 db::{DefDatabase, HirDatabase}, 45 db::{DefDatabase, HirDatabase},
46 doc_links::Resolvable,
46 has_source::HasSource, 47 has_source::HasSource,
47 link_rewrite::Resolvable,
48 HirDisplay, InFile, Name, 48 HirDisplay, InFile, Name,
49}; 49};
50 50
@@ -234,23 +234,6 @@ impl ModuleDef {
234 ModuleDef::BuiltinType(it) => Some(it.as_name()), 234 ModuleDef::BuiltinType(it) => Some(it.as_name()),
235 } 235 }
236 } 236 }
237
238 pub fn resolver<D: DefDatabase + HirDatabase>(&self, db: &D) -> Option<Resolver> {
239 Some(match self {
240 ModuleDef::Module(m) => ModuleId::from(m.clone()).resolver(db),
241 ModuleDef::Function(f) => FunctionId::from(f.clone()).resolver(db),
242 ModuleDef::Adt(adt) => AdtId::from(adt.clone()).resolver(db),
243 ModuleDef::EnumVariant(ev) => {
244 GenericDefId::from(GenericDef::from(ev.clone())).resolver(db)
245 }
246 ModuleDef::Const(c) => GenericDefId::from(GenericDef::from(c.clone())).resolver(db),
247 ModuleDef::Static(s) => StaticId::from(s.clone()).resolver(db),
248 ModuleDef::Trait(t) => TraitId::from(t.clone()).resolver(db),
249 ModuleDef::TypeAlias(t) => ModuleId::from(t.module(db)).resolver(db),
250 // FIXME: This should be a resolver relative to `std/core`
251 ModuleDef::BuiltinType(_t) => None?,
252 })
253 }
254} 237}
255 238
256pub use hir_def::{ 239pub use hir_def::{
diff --git a/crates/hir/src/link_rewrite.rs b/crates/hir/src/doc_links.rs
index dad3a39cf..45b26519e 100644
--- a/crates/hir/src/link_rewrite.rs
+++ b/crates/hir/src/doc_links.rs
@@ -1,4 +1,4 @@
1//! Resolves and rewrites links in markdown documentation for hovers/completion windows. 1//! Resolves links in markdown documentation.
2 2
3use std::iter::once; 3use std::iter::once;
4 4
@@ -113,7 +113,7 @@ fn try_resolve_path(db: &dyn HirDatabase, moddef: &ModuleDef, link_target: &str)
113 .map(|url| url.into_string()) 113 .map(|url| url.into_string())
114} 114}
115 115
116// Strip prefixes, suffixes, and inline code marks from the given string. 116/// Strip prefixes, suffixes, and inline code marks from the given string.
117fn strip_prefixes_suffixes(mut s: &str) -> &str { 117fn strip_prefixes_suffixes(mut s: &str) -> &str {
118 s = s.trim_matches('`'); 118 s = s.trim_matches('`');
119 119
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index ae2f1fd4d..d1f4d7813 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -27,7 +27,7 @@ pub mod diagnostics;
27 27
28mod from_id; 28mod from_id;
29mod code_model; 29mod code_model;
30mod link_rewrite; 30mod doc_links;
31 31
32mod has_source; 32mod has_source;
33 33
@@ -38,8 +38,8 @@ pub use crate::{
38 Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, 38 Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, 39 ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
40 }, 40 },
41 doc_links::resolve_doc_link,
41 has_source::HasSource, 42 has_source::HasSource,
42 link_rewrite::resolve_doc_link,
43 semantics::{original_range, PathResolution, Semantics, SemanticsScope}, 43 semantics::{original_range, PathResolution, Semantics, SemanticsScope},
44}; 44};
45 45