diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:50:30 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:50:30 +0100 |
commit | 5452368fad8ee8d03d980de47604fa108111ea57 (patch) | |
tree | 6ee0a7d37456c210e0f0a65d4b9656ace534740f /crates | |
parent | 7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (diff) |
Renames, comments, and dead code removal
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir/src/code_model.rs | 19 | ||||
-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.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/link_rewrite.rs | 4 |
4 files changed, 8 insertions, 23 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 | ||
44 | use crate::{ | 44 | use 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 | ||
256 | pub use hir_def::{ | 239 | pub 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 | ||
3 | use std::iter::once; | 3 | use 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. |
117 | fn strip_prefixes_suffixes(mut s: &str) -> &str { | 117 | fn 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 | ||
28 | mod from_id; | 28 | mod from_id; |
29 | mod code_model; | 29 | mod code_model; |
30 | mod link_rewrite; | 30 | mod doc_links; |
31 | 31 | ||
32 | mod has_source; | 32 | mod 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 | ||
diff --git a/crates/ide/src/link_rewrite.rs b/crates/ide/src/link_rewrite.rs index a826220e3..ff3200eef 100644 --- a/crates/ide/src/link_rewrite.rs +++ b/crates/ide/src/link_rewrite.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | //! This is a wrapper around [`hir::link_rewrite`] connecting it to the markdown parser. | 1 | //! Resolves and rewrites links in markdown documentation. |
2 | //! | ||
3 | //! Most of the implementation can be found in [`hir::doc_links`]. | ||
2 | 4 | ||
3 | use pulldown_cmark::{CowStr, Event, Options, Parser, Tag}; | 5 | use pulldown_cmark::{CowStr, Event, Options, Parser, Tag}; |
4 | use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions}; | 6 | use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions}; |