Skip to content

Commit ade2f5c

Browse files
committed
Reduce test verbosity
1 parent 0e3581e commit ade2f5c

File tree

3 files changed

+169
-597
lines changed

3 files changed

+169
-597
lines changed

crates/ide/src/display/navigation_target.rs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! FIXME: write short doc here
22
3+
use std::fmt;
4+
35
use either::Either;
46
use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource};
57
use ide_db::{
@@ -42,7 +44,7 @@ pub enum SymbolKind {
4244
///
4345
/// Typically, a `NavigationTarget` corresponds to some element in the source
4446
/// code, like a function or a struct, but this is not strictly required.
45-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
47+
#[derive(Clone, PartialEq, Eq, Hash)]
4648
pub struct NavigationTarget {
4749
pub file_id: FileId,
4850
/// Range which encompasses the whole element.
@@ -68,6 +70,24 @@ pub struct NavigationTarget {
6870
pub docs: Option<Documentation>,
6971
}
7072

73+
impl fmt::Debug for NavigationTarget {
74+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75+
let mut f = f.debug_struct("NavigationTarget");
76+
macro_rules! opt {
77+
($($name:ident)*) => {$(
78+
if let Some(it) = &self.$name {
79+
f.field(stringify!($name), it);
80+
}
81+
)*}
82+
}
83+
f.field("file_id", &self.file_id).field("full_range", &self.full_range);
84+
opt!(focus_range);
85+
f.field("name", &self.name);
86+
opt!(kind container_name description docs);
87+
f.finish()
88+
}
89+
}
90+
7191
pub(crate) trait ToNav {
7292
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget;
7393
}
@@ -487,38 +507,21 @@ fn foo() { enum FooInner { } }
487507
0,
488508
),
489509
full_range: 0..17,
490-
focus_range: Some(
491-
5..13,
492-
),
510+
focus_range: 5..13,
493511
name: "FooInner",
494-
kind: Some(
495-
Enum,
496-
),
497-
container_name: None,
498-
description: Some(
499-
"enum FooInner",
500-
),
501-
docs: None,
512+
kind: Enum,
513+
description: "enum FooInner",
502514
},
503515
NavigationTarget {
504516
file_id: FileId(
505517
0,
506518
),
507519
full_range: 29..46,
508-
focus_range: Some(
509-
34..42,
510-
),
520+
focus_range: 34..42,
511521
name: "FooInner",
512-
kind: Some(
513-
Enum,
514-
),
515-
container_name: Some(
516-
"foo",
517-
),
518-
description: Some(
519-
"enum FooInner",
520-
),
521-
docs: None,
522+
kind: Enum,
523+
container_name: "foo",
524+
description: "enum FooInner",
522525
},
523526
]
524527
"#]]

0 commit comments

Comments
 (0)