display Doctest code lens before comment #4785

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-06-18 11:31:15 +02:00
parent 36d9105d0e
commit 2732fdb595
2 changed files with 3 additions and 9 deletions

View file

@ -4,7 +4,6 @@ use either::Either;
use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource};
use ra_db::{FileId, SourceDatabase};
use ra_ide_db::{defs::Definition, RootDatabase};
use ra_syntax::ast::AstToken;
use ra_syntax::{
ast::{self, DocCommentsOwner, NameOwner},
match_ast, AstNode, SmolStr,
@ -159,13 +158,12 @@ impl NavigationTarget {
) -> NavigationTarget {
let name =
named.value.name().map(|it| it.text().clone()).unwrap_or_else(|| SmolStr::new("_"));
let focus_range = node.value.doc_comments().next().map(|it| it.syntax().text_range());
let frange = original_range(db, node.map(|it| it.syntax()));
NavigationTarget::from_syntax(
frange.file_id,
name,
focus_range,
None,
frange.range,
node.value.syntax().kind(),
)

View file

@ -427,9 +427,7 @@ mod tests {
full_range: 22..64,
name: "foo",
kind: FN_DEF,
focus_range: Some(
22..29,
),
focus_range: None,
container_name: None,
description: None,
docs: None,
@ -494,9 +492,7 @@ mod tests {
full_range: 51..105,
name: "foo",
kind: FN_DEF,
focus_range: Some(
51..58,
),
focus_range: None,
container_name: None,
description: None,
docs: None,