6933: Reduce test verbosity r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-12-18 18:27:28 +00:00 committed by GitHub
commit 25185c1418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 453 deletions

View File

@ -1,5 +1,7 @@
//! FIXME: write short doc here
use std::fmt;
use either::Either;
use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource};
use ide_db::{
@ -35,8 +37,6 @@ pub enum SymbolKind {
TypeAlias,
Trait,
Macro,
// Do we actually need this?
DocTest,
}
/// `NavigationTarget` represents and element in the editor's UI which you can
@ -44,7 +44,7 @@ pub enum SymbolKind {
///
/// Typically, a `NavigationTarget` corresponds to some element in the source
/// code, like a function or a struct, but this is not strictly required.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct NavigationTarget {
pub file_id: FileId,
/// Range which encompasses the whole element.
@ -64,12 +64,30 @@ pub struct NavigationTarget {
/// Clients should place the cursor on this range when navigating to this target.
pub focus_range: Option<TextRange>,
pub name: SmolStr,
pub kind: SymbolKind,
pub kind: Option<SymbolKind>,
pub container_name: Option<SmolStr>,
pub description: Option<String>,
pub docs: Option<Documentation>,
}
impl fmt::Debug for NavigationTarget {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("NavigationTarget");
macro_rules! opt {
($($name:ident)*) => {$(
if let Some(it) = &self.$name {
f.field(stringify!($name), it);
}
)*}
}
f.field("file_id", &self.file_id).field("full_range", &self.full_range);
opt!(focus_range);
f.field("name", &self.name);
opt!(kind container_name description docs);
f.finish()
}
}
pub(crate) trait ToNav {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget;
}
@ -110,8 +128,13 @@ pub(crate) fn assert_match(&self, expected: &str) {
#[cfg(test)]
pub(crate) fn debug_render(&self) -> String {
let mut buf =
format!("{} {:?} {:?} {:?}", self.name, self.kind, self.file_id, self.full_range);
let mut buf = format!(
"{} {:?} {:?} {:?}",
self.name,
self.kind.unwrap(),
self.file_id,
self.full_range
);
if let Some(focus_range) = self.focus_range {
buf.push_str(&format!(" {:?}", focus_range))
}
@ -146,7 +169,7 @@ fn from_syntax(
NavigationTarget {
file_id,
name,
kind,
kind: Some(kind),
full_range,
focus_range,
container_name: None,
@ -161,7 +184,7 @@ fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
NavigationTarget {
file_id: self.file_id,
name: self.name.clone(),
kind: match self.kind {
kind: Some(match self.kind {
FileSymbolKind::Function => SymbolKind::Function,
FileSymbolKind::Struct => SymbolKind::Struct,
FileSymbolKind::Enum => SymbolKind::Enum,
@ -171,7 +194,7 @@ fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
FileSymbolKind::Const => SymbolKind::Const,
FileSymbolKind::Static => SymbolKind::Static,
FileSymbolKind::Macro => SymbolKind::Macro,
},
}),
full_range: self.range,
focus_range: self.name_range,
container_name: self.container_name.clone(),
@ -386,7 +409,7 @@ fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
NavigationTarget {
file_id: full_range.file_id,
name,
kind: SymbolKind::Local,
kind: Some(SymbolKind::Local),
full_range: full_range.range,
focus_range: None,
container_name: None,
@ -410,7 +433,7 @@ fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
NavigationTarget {
file_id: src.file_id.original_file(db),
name: self.name(db).to_string().into(),
kind: SymbolKind::TypeParam,
kind: Some(SymbolKind::TypeParam),
full_range,
focus_range,
container_name: None,
@ -427,7 +450,7 @@ fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
NavigationTarget {
file_id: src.file_id.original_file(db),
name: self.name(db).to_string().into(),
kind: SymbolKind::LifetimeParam,
kind: Some(SymbolKind::LifetimeParam),
full_range,
focus_range: Some(full_range),
container_name: None,
@ -484,34 +507,21 @@ fn foo() { enum FooInner { } }
0,
),
full_range: 0..17,
focus_range: Some(
5..13,
),
focus_range: 5..13,
name: "FooInner",
kind: Enum,
container_name: None,
description: Some(
"enum FooInner",
),
docs: None,
description: "enum FooInner",
},
NavigationTarget {
file_id: FileId(
0,
),
full_range: 29..46,
focus_range: Some(
34..42,
),
focus_range: 34..42,
name: "FooInner",
kind: Enum,
container_name: Some(
"foo",
),
description: Some(
"enum FooInner",
),
docs: None,
container_name: "foo",
description: "enum FooInner",
},
]
"#]]

View File

@ -86,7 +86,7 @@ fn self_to_nav_target(self_param: ast::SelfParam, file_id: FileId) -> Option<Nav
full_range: self_param.syntax().text_range(),
focus_range: Some(self_token.text_range()),
name: self_token.text().clone(),
kind: SymbolKind::SelfParam,
kind: Some(SymbolKind::SelfParam),
container_name: None,
description: None,
docs: None,

View File

@ -2187,14 +2187,9 @@ fn foo_<|>test() {}
0,
),
full_range: 0..24,
focus_range: Some(
11..19,
),
focus_range: 11..19,
name: "foo_test",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -2230,14 +2225,9 @@ fn foo_test() {}
0,
),
full_range: 0..46,
focus_range: Some(
4..9,
),
focus_range: 4..9,
name: "tests",
kind: Module,
container_name: None,
description: None,
docs: None,
},
kind: TestMod {
path: "tests",
@ -2269,16 +2259,10 @@ struct S{ f1: u32 }
0,
),
full_range: 0..19,
focus_range: Some(
7..8,
),
focus_range: 7..8,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -2308,16 +2292,10 @@ struct S<T>{ f1: T }
0,
),
full_range: 17..37,
focus_range: Some(
24..25,
),
focus_range: 24..25,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
HoverGotoTypeData {
@ -2327,16 +2305,10 @@ struct S<T>{ f1: T }
0,
),
full_range: 0..16,
focus_range: Some(
7..10,
),
focus_range: 7..10,
name: "Arg",
kind: Struct,
container_name: None,
description: Some(
"struct Arg",
),
docs: None,
description: "struct Arg",
},
},
],
@ -2366,16 +2338,10 @@ struct S<T>{ f1: T }
0,
),
full_range: 17..37,
focus_range: Some(
24..25,
),
focus_range: 24..25,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
HoverGotoTypeData {
@ -2385,16 +2351,10 @@ struct S<T>{ f1: T }
0,
),
full_range: 0..16,
focus_range: Some(
7..10,
),
focus_range: 7..10,
name: "Arg",
kind: Struct,
container_name: None,
description: Some(
"struct Arg",
),
docs: None,
description: "struct Arg",
},
},
],
@ -2427,16 +2387,10 @@ mod M {
0,
),
full_range: 0..14,
focus_range: Some(
7..8,
),
focus_range: 7..8,
name: "A",
kind: Struct,
container_name: None,
description: Some(
"struct A",
),
docs: None,
description: "struct A",
},
},
HoverGotoTypeData {
@ -2446,16 +2400,10 @@ mod M {
0,
),
full_range: 15..29,
focus_range: Some(
22..23,
),
focus_range: 22..23,
name: "B",
kind: Struct,
container_name: None,
description: Some(
"struct B",
),
docs: None,
description: "struct B",
},
},
HoverGotoTypeData {
@ -2465,16 +2413,10 @@ mod M {
0,
),
full_range: 42..60,
focus_range: Some(
53..54,
),
focus_range: 53..54,
name: "C",
kind: Struct,
container_name: None,
description: Some(
"pub struct C",
),
docs: None,
description: "pub struct C",
},
},
],
@ -2504,16 +2446,10 @@ fn foo() -> impl Foo {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
],
@ -2544,16 +2480,10 @@ fn foo() -> impl Foo<S> {}
0,
),
full_range: 0..15,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -2563,16 +2493,10 @@ fn foo() -> impl Foo<S> {}
0,
),
full_range: 16..25,
focus_range: Some(
23..24,
),
focus_range: 23..24,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -2603,16 +2527,10 @@ fn foo() -> impl Foo + Bar {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -2622,16 +2540,10 @@ fn foo() -> impl Foo + Bar {}
0,
),
full_range: 13..25,
focus_range: Some(
19..22,
),
focus_range: 19..22,
name: "Bar",
kind: Trait,
container_name: None,
description: Some(
"trait Bar",
),
docs: None,
description: "trait Bar",
},
},
],
@ -2665,16 +2577,10 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
0,
),
full_range: 0..15,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -2684,16 +2590,10 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
0,
),
full_range: 16..31,
focus_range: Some(
22..25,
),
focus_range: 22..25,
name: "Bar",
kind: Trait,
container_name: None,
description: Some(
"trait Bar",
),
docs: None,
description: "trait Bar",
},
},
HoverGotoTypeData {
@ -2703,16 +2603,10 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
0,
),
full_range: 32..44,
focus_range: Some(
39..41,
),
focus_range: 39..41,
name: "S1",
kind: Struct,
container_name: None,
description: Some(
"struct S1",
),
docs: None,
description: "struct S1",
},
},
HoverGotoTypeData {
@ -2722,16 +2616,10 @@ fn foo() -> impl Foo<S1> + Bar<S2> {}
0,
),
full_range: 45..57,
focus_range: Some(
52..54,
),
focus_range: 52..54,
name: "S2",
kind: Struct,
container_name: None,
description: Some(
"struct S2",
),
docs: None,
description: "struct S2",
},
},
],
@ -2759,16 +2647,10 @@ fn foo(ar<|>g: &impl Foo) {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
],
@ -2799,16 +2681,10 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -2818,16 +2694,10 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
0,
),
full_range: 13..28,
focus_range: Some(
19..22,
),
focus_range: 19..22,
name: "Bar",
kind: Trait,
container_name: None,
description: Some(
"trait Bar",
),
docs: None,
description: "trait Bar",
},
},
HoverGotoTypeData {
@ -2837,16 +2707,10 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {}
0,
),
full_range: 29..39,
focus_range: Some(
36..37,
),
focus_range: 36..37,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -2882,16 +2746,10 @@ mod future {
0,
),
full_range: 101..163,
focus_range: Some(
140..146,
),
focus_range: 140..146,
name: "Future",
kind: Trait,
container_name: None,
description: Some(
"pub trait Future",
),
docs: None,
description: "pub trait Future",
},
},
HoverGotoTypeData {
@ -2901,16 +2759,10 @@ mod future {
0,
),
full_range: 0..9,
focus_range: Some(
7..8,
),
focus_range: 7..8,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -2939,16 +2791,10 @@ fn foo(ar<|>g: &impl Foo<S>) {}
0,
),
full_range: 0..15,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -2958,16 +2804,10 @@ fn foo(ar<|>g: &impl Foo<S>) {}
0,
),
full_range: 16..27,
focus_range: Some(
23..24,
),
focus_range: 23..24,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -3001,16 +2841,10 @@ fn foo() -> B<dyn Foo> {}
0,
),
full_range: 42..55,
focus_range: Some(
49..50,
),
focus_range: 49..50,
name: "B",
kind: Struct,
container_name: None,
description: Some(
"struct B",
),
docs: None,
description: "struct B",
},
},
HoverGotoTypeData {
@ -3020,16 +2854,10 @@ fn foo() -> B<dyn Foo> {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
],
@ -3057,16 +2885,10 @@ fn foo(ar<|>g: &dyn Foo) {}
0,
),
full_range: 0..12,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
],
@ -3095,16 +2917,10 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
0,
),
full_range: 0..15,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
HoverGotoTypeData {
@ -3114,16 +2930,10 @@ fn foo(ar<|>g: &dyn Foo<S>) {}
0,
),
full_range: 16..27,
focus_range: Some(
23..24,
),
focus_range: 23..24,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -3155,16 +2965,10 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
0,
),
full_range: 0..21,
focus_range: Some(
6..15,
),
focus_range: 6..15,
name: "ImplTrait",
kind: Trait,
container_name: None,
description: Some(
"trait ImplTrait",
),
docs: None,
description: "trait ImplTrait",
},
},
HoverGotoTypeData {
@ -3174,16 +2978,10 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
0,
),
full_range: 43..57,
focus_range: Some(
50..51,
),
focus_range: 50..51,
name: "B",
kind: Struct,
container_name: None,
description: Some(
"struct B",
),
docs: None,
description: "struct B",
},
},
HoverGotoTypeData {
@ -3193,16 +2991,10 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
0,
),
full_range: 22..42,
focus_range: Some(
28..36,
),
focus_range: 28..36,
name: "DynTrait",
kind: Trait,
container_name: None,
description: Some(
"trait DynTrait",
),
docs: None,
description: "trait DynTrait",
},
},
HoverGotoTypeData {
@ -3212,16 +3004,10 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {}
0,
),
full_range: 58..69,
focus_range: Some(
65..66,
),
focus_range: 65..66,
name: "S",
kind: Struct,
container_name: None,
description: Some(
"struct S",
),
docs: None,
description: "struct S",
},
},
],
@ -3260,16 +3046,10 @@ fn test() -> impl Foo { S {} }
0,
),
full_range: 0..62,
focus_range: Some(
6..9,
),
focus_range: 6..9,
name: "Foo",
kind: Trait,
container_name: None,
description: Some(
"trait Foo",
),
docs: None,
description: "trait Foo",
},
},
],

View File

@ -278,7 +278,7 @@ fn try_find_self_references(
full_range: self_param.syntax().text_range(),
focus_range: Some(param_self_token.text_range()),
name: param_self_token.text().clone(),
kind: SymbolKind::SelfParam,
kind: Some(SymbolKind::SelfParam),
container_name: None,
description: None,
docs: None,

View File

@ -208,7 +208,7 @@ fn module_def_doctest(sema: &Semantics<RootDatabase>, def: hir::ModuleDef) -> Op
nav.focus_range = None;
nav.description = None;
nav.docs = None;
nav.kind = SymbolKind::DocTest;
nav.kind = None;
let res = Runnable { nav, kind: RunnableKind::DocTest { test_id }, cfg: attrs.cfg() };
Some(res)
}
@ -352,14 +352,9 @@ fn bench() {}
0,
),
full_range: 1..13,
focus_range: Some(
4..8,
),
focus_range: 4..8,
name: "main",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Bin,
cfg: None,
@ -370,14 +365,9 @@ fn bench() {}
0,
),
full_range: 15..39,
focus_range: Some(
26..34,
),
focus_range: 26..34,
name: "test_foo",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -395,14 +385,9 @@ fn bench() {}
0,
),
full_range: 41..75,
focus_range: Some(
62..70,
),
focus_range: 62..70,
name: "test_foo",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -420,14 +405,9 @@ fn bench() {}
0,
),
full_range: 77..99,
focus_range: Some(
89..94,
),
focus_range: 89..94,
name: "bench",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Bench {
test_id: Path(
@ -517,14 +497,9 @@ fn should_have_no_runnable_6() {}
0,
),
full_range: 1..13,
focus_range: Some(
4..8,
),
focus_range: 4..8,
name: "main",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Bin,
cfg: None,
@ -535,12 +510,7 @@ fn should_have_no_runnable_6() {}
0,
),
full_range: 15..74,
focus_range: None,
name: "should_have_runnable",
kind: DocTest,
container_name: None,
description: None,
docs: None,
},
kind: DocTest {
test_id: Path(
@ -555,12 +525,7 @@ fn should_have_no_runnable_6() {}
0,
),
full_range: 76..148,
focus_range: None,
name: "should_have_runnable_1",
kind: DocTest,
container_name: None,
description: None,
docs: None,
},
kind: DocTest {
test_id: Path(
@ -575,12 +540,7 @@ fn should_have_no_runnable_6() {}
0,
),
full_range: 150..254,
focus_range: None,
name: "should_have_runnable_2",
kind: DocTest,
container_name: None,
description: None,
docs: None,
},
kind: DocTest {
test_id: Path(
@ -595,12 +555,7 @@ fn should_have_no_runnable_6() {}
0,
),
full_range: 756..821,
focus_range: None,
name: "StructWithRunnable",
kind: DocTest,
container_name: None,
description: None,
docs: None,
},
kind: DocTest {
test_id: Path(
@ -639,14 +594,9 @@ fn foo() {}
0,
),
full_range: 1..13,
focus_range: Some(
4..8,
),
focus_range: 4..8,
name: "main",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Bin,
cfg: None,
@ -657,12 +607,7 @@ fn foo() {}
0,
),
full_range: 44..98,
focus_range: None,
name: "foo",
kind: DocTest,
container_name: None,
description: None,
docs: None,
},
kind: DocTest {
test_id: Path(
@ -696,14 +641,9 @@ fn test_foo1() {}
0,
),
full_range: 1..51,
focus_range: Some(
5..13,
),
focus_range: 5..13,
name: "test_mod",
kind: Module,
container_name: None,
description: None,
docs: None,
},
kind: TestMod {
path: "test_mod",
@ -716,14 +656,9 @@ fn test_foo1() {}
0,
),
full_range: 20..49,
focus_range: Some(
35..44,
),
focus_range: 35..44,
name: "test_foo1",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -776,14 +711,9 @@ mod nested_tests_4 {}
0,
),
full_range: 22..323,
focus_range: Some(
26..40,
),
focus_range: 26..40,
name: "nested_tests_0",
kind: Module,
container_name: None,
description: None,
docs: None,
},
kind: TestMod {
path: "root_tests::nested_tests_0",
@ -796,14 +726,9 @@ mod nested_tests_4 {}
0,
),
full_range: 51..192,
focus_range: Some(
55..69,
),
focus_range: 55..69,
name: "nested_tests_1",
kind: Module,
container_name: None,
description: None,
docs: None,
},
kind: TestMod {
path: "root_tests::nested_tests_0::nested_tests_1",
@ -816,14 +741,9 @@ mod nested_tests_4 {}
0,
),
full_range: 84..126,
focus_range: Some(
107..121,
),
focus_range: 107..121,
name: "nested_test_11",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -841,14 +761,9 @@ mod nested_tests_4 {}
0,
),
full_range: 140..182,
focus_range: Some(
163..177,
),
focus_range: 163..177,
name: "nested_test_12",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -866,14 +781,9 @@ mod nested_tests_4 {}
0,
),
full_range: 202..286,
focus_range: Some(
206..220,
),
focus_range: 206..220,
name: "nested_tests_2",
kind: Module,
container_name: None,
description: None,
docs: None,
},
kind: TestMod {
path: "root_tests::nested_tests_0::nested_tests_2",
@ -886,14 +796,9 @@ mod nested_tests_4 {}
0,
),
full_range: 235..276,
focus_range: Some(
258..271,
),
focus_range: 258..271,
name: "nested_test_2",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -929,14 +834,9 @@ fn test_foo1() {}
0,
),
full_range: 1..50,
focus_range: Some(
36..45,
),
focus_range: 36..45,
name: "test_foo1",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(
@ -979,14 +879,9 @@ fn test_foo1() {}
0,
),
full_range: 1..72,
focus_range: Some(
58..67,
),
focus_range: 58..67,
name: "test_foo1",
kind: Function,
container_name: None,
description: None,
docs: None,
},
kind: Test {
test_id: Path(

View File

@ -385,7 +385,10 @@ fn exec_query(snap: &GlobalStateSnapshot, query: Query) -> Result<Vec<SymbolInfo
#[allow(deprecated)]
let info = SymbolInformation {
name: nav.name.to_string(),
kind: to_proto::symbol_kind(nav.kind),
kind: nav
.kind
.map(to_proto::symbol_kind)
.unwrap_or(lsp_types::SymbolKind::Variable),
tags: None,
location: to_proto::location_from_nav(snap, nav)?,
container_name,
@ -1263,7 +1266,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
let RangeInfo { range: _, info: navs } = nav_info;
let res = navs
.into_iter()
.filter(|it| it.kind == SymbolKind::Function)
.filter(|it| it.kind == Some(SymbolKind::Function))
.map(|it| to_proto::call_hierarchy_item(&snap, it))
.collect::<Result<Vec<_>>>()?;

View File

@ -43,10 +43,9 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
SymbolKind::Static => lsp_types::SymbolKind::Constant,
SymbolKind::Const => lsp_types::SymbolKind::Constant,
SymbolKind::Impl => lsp_types::SymbolKind::Object,
SymbolKind::Local
| SymbolKind::SelfParam
| SymbolKind::LifetimeParam
| SymbolKind::DocTest => lsp_types::SymbolKind::Variable,
SymbolKind::Local | SymbolKind::SelfParam | SymbolKind::LifetimeParam => {
lsp_types::SymbolKind::Variable
}
SymbolKind::Union => lsp_types::SymbolKind::Struct,
}
}
@ -722,7 +721,7 @@ pub(crate) fn call_hierarchy_item(
) -> Result<lsp_types::CallHierarchyItem> {
let name = target.name.to_string();
let detail = target.description.clone();
let kind = symbol_kind(target.kind);
let kind = target.kind.map(symbol_kind).unwrap_or(lsp_types::SymbolKind::Function);
let (uri, range, selection_range) = location_info(snap, target)?;
Ok(lsp_types::CallHierarchyItem {
name,