Rewrite doctest runnables

Handle more cases in a generic way without copy-pasting code.
This commit is contained in:
Aleksey Kladov 2020-12-17 19:29:31 +03:00
parent 0da1532ef2
commit c888f1de6f
2 changed files with 82 additions and 106 deletions

View file

@ -117,25 +117,6 @@ impl NavigationTarget {
)
}
/// Allows `NavigationTarget` to be created from a `DocCommentsOwner` and a `NameOwner`
pub(crate) fn from_doc_commented(
db: &RootDatabase,
named: InFile<&dyn ast::NameOwner>,
node: InFile<&dyn ast::DocCommentsOwner>,
) -> NavigationTarget {
let name =
named.value.name().map(|it| it.text().clone()).unwrap_or_else(|| SmolStr::new("_"));
let frange = node.map(|it| it.syntax()).original_file_range(db);
NavigationTarget::from_syntax(
frange.file_id,
name,
None,
frange.range,
node.value.syntax().kind(),
)
}
fn from_syntax(
file_id: FileId,
name: SmolStr,