Renames, comments, and dead code removal

This commit is contained in:
Zac Pullar-Strecker 2020-08-24 21:50:30 +12:00
parent 7bbca7a1b3
commit 5452368fad
4 changed files with 8 additions and 23 deletions

View File

@ -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<D: DefDatabase + HirDatabase>(&self, db: &D) -> Option<Resolver> {
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::{

View File

@ -1,4 +1,4 @@
//! Resolves and rewrites links in markdown documentation for hovers/completion windows.
//! Resolves links in markdown documentation.
use std::iter::once;
@ -113,7 +113,7 @@ fn try_resolve_path(db: &dyn HirDatabase, moddef: &ModuleDef, link_target: &str)
.map(|url| url.into_string())
}
// Strip prefixes, suffixes, and inline code marks from the given string.
/// Strip prefixes, suffixes, and inline code marks from the given string.
fn strip_prefixes_suffixes(mut s: &str) -> &str {
s = s.trim_matches('`');

View File

@ -27,7 +27,7 @@ pub mod diagnostics;
mod from_id;
mod code_model;
mod link_rewrite;
mod doc_links;
mod has_source;
@ -38,8 +38,8 @@ pub use crate::{
Function, GenericDef, HasAttrs, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
},
doc_links::resolve_doc_link,
has_source::HasSource,
link_rewrite::resolve_doc_link,
semantics::{original_range, PathResolution, Semantics, SemanticsScope},
};

View File

@ -1,4 +1,6 @@
//! This is a wrapper around [`hir::link_rewrite`] connecting it to the markdown parser.
//! Resolves and rewrites links in markdown documentation.
//!
//! Most of the implementation can be found in [`hir::doc_links`].
use pulldown_cmark::{CowStr, Event, Options, Parser, Tag};
use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions};