Improvements based on code review feedback
This commit is contained in:
parent
9d298115a6
commit
7b35da04bf
@ -76,7 +76,6 @@ fn get_chaining_hints(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ty = sema.type_of_expr(&expr)?;
|
let ty = sema.type_of_expr(&expr)?;
|
||||||
let label = ty.display_truncated(sema.db, options.max_length).to_string();
|
|
||||||
if ty.is_unknown() {
|
if ty.is_unknown() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -96,6 +95,7 @@ fn get_chaining_hints(
|
|||||||
let next = tokens.next()?.kind();
|
let next = tokens.next()?.kind();
|
||||||
let next_next = tokens.next()?.kind();
|
let next_next = tokens.next()?.kind();
|
||||||
if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT {
|
if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT {
|
||||||
|
let label = ty.display_truncated(sema.db, options.max_length).to_string();
|
||||||
acc.push(InlayHint {
|
acc.push(InlayHint {
|
||||||
range: expr.syntax().text_range(),
|
range: expr.syntax().text_range(),
|
||||||
kind: InlayKind::ChainingHint,
|
kind: InlayKind::ChainingHint,
|
||||||
@ -1105,7 +1105,7 @@ fn chaining_hints_ignore_comments() {
|
|||||||
r#"
|
r#"
|
||||||
struct A(B);
|
struct A(B);
|
||||||
impl A { fn into_b(self) -> B { self.0 } }
|
impl A { fn into_b(self) -> B { self.0 } }
|
||||||
struct B(C)
|
struct B(C);
|
||||||
impl B { fn into_c(self) -> C { self.0 } }
|
impl B { fn into_c(self) -> C { self.0 } }
|
||||||
struct C;
|
struct C;
|
||||||
|
|
||||||
@ -1118,12 +1118,12 @@ fn main() {
|
|||||||
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
|
assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
|
||||||
[
|
[
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [231; 268),
|
range: [232; 269),
|
||||||
kind: ChainingHint,
|
kind: ChainingHint,
|
||||||
label: "B",
|
label: "B",
|
||||||
},
|
},
|
||||||
InlayHint {
|
InlayHint {
|
||||||
range: [231; 238),
|
range: [232; 239),
|
||||||
kind: ChainingHint,
|
kind: ChainingHint,
|
||||||
label: "A",
|
label: "A",
|
||||||
},
|
},
|
||||||
@ -1136,7 +1136,7 @@ fn chaining_hints_without_newlines() {
|
|||||||
r#"
|
r#"
|
||||||
struct A(B);
|
struct A(B);
|
||||||
impl A { fn into_b(self) -> B { self.0 } }
|
impl A { fn into_b(self) -> B { self.0 } }
|
||||||
struct B(C)
|
struct B(C);
|
||||||
impl B { fn into_c(self) -> C { self.0 } }
|
impl B { fn into_c(self) -> C { self.0 } }
|
||||||
struct C;
|
struct C;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user