Style and test fixes

This commit is contained in:
Kirill Bulatov 2019-08-05 00:47:14 +03:00
parent 15411d4474
commit 3fb6462d54
2 changed files with 45 additions and 34 deletions

View File

@ -216,52 +216,52 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [193; 197), range: [193; 197),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [236; 244), range: [236; 244),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [275; 279), range: [275; 279),
kind: LetBindingType, kind: TypeHint,
label: "&str", label: "&str",
}, },
InlayHint { InlayHint {
range: [539; 543), range: [539; 543),
kind: LetBindingType, kind: TypeHint,
label: "(i32, char)", label: "(i32, char)",
}, },
InlayHint { InlayHint {
range: [566; 567), range: [566; 567),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [570; 571), range: [570; 571),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [573; 574), range: [573; 574),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [584; 585), range: [584; 585),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [577; 578), range: [577; 578),
kind: LetBindingType, kind: TypeHint,
label: "f64", label: "f64",
}, },
InlayHint { InlayHint {
range: [580; 581), range: [580; 581),
kind: LetBindingType, kind: TypeHint,
label: "f64", label: "f64",
}, },
]"# ]"#
@ -283,12 +283,12 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [21; 30), range: [21; 30),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [57; 66), range: [57; 66),
kind: ClosureParameterType, kind: TypeHint,
label: "i32", label: "i32",
}, },
]"# ]"#
@ -310,12 +310,12 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [21; 30), range: [21; 30),
kind: LetBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
InlayHint { InlayHint {
range: [44; 53), range: [44; 53),
kind: ForExpressionBindingType, kind: TypeHint,
label: "i32", label: "i32",
}, },
]"# ]"#
@ -356,27 +356,27 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [166; 170), range: [166; 170),
kind: LetBindingType, kind: TypeHint,
label: "CustomOption<Test>", label: "CustomOption<Test>",
}, },
InlayHint { InlayHint {
range: [334; 338), range: [334; 338),
kind: IfExpressionType, kind: TypeHint,
label: "&Test", label: "&Test",
}, },
InlayHint { InlayHint {
range: [389; 390), range: [389; 390),
kind: IfExpressionType, kind: TypeHint,
label: "&CustomOption<u32>", label: "&CustomOption<u32>",
}, },
InlayHint { InlayHint {
range: [392; 393), range: [392; 393),
kind: IfExpressionType, kind: TypeHint,
label: "&u8", label: "&u8",
}, },
InlayHint { InlayHint {
range: [531; 532), range: [531; 532),
kind: IfExpressionType, kind: TypeHint,
label: "&u32", label: "&u32",
}, },
]"# ]"#
@ -417,7 +417,7 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [166; 170), range: [166; 170),
kind: LetBindingType, kind: TypeHint,
label: "CustomOption<Test>", label: "CustomOption<Test>",
}, },
]"# ]"#
@ -457,23 +457,23 @@ fn main() {
assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
InlayHint { InlayHint {
range: [312; 316), range: [311; 315),
kind: MatchArmType, kind: TypeHint,
label: "Test", label: "Test",
}, },
InlayHint { InlayHint {
range: [359; 360), range: [358; 359),
kind: MatchArmType, kind: TypeHint,
label: "CustomOption<u32>", label: "CustomOption<u32>",
}, },
InlayHint { InlayHint {
range: [362; 363), range: [361; 362),
kind: MatchArmType, kind: TypeHint,
label: "u8", label: "u8",
}, },
InlayHint { InlayHint {
range: [485; 486), range: [484; 485),
kind: MatchArmType, kind: TypeHint,
label: "u32", label: "u32",
}, },
]"# ]"#

View File

@ -27,14 +27,19 @@ export class HintsUpdater {
if (this.displayHints) { if (this.displayHints) {
const documentUri = this.getEditorDocumentUri(editor); const documentUri = this.getEditorDocumentUri(editor);
if (documentUri !== null) { if (documentUri !== null) {
const latestDecorations = this.drawnDecorations.get(documentUri); const latestDecorations = this.drawnDecorations.get(
documentUri
);
if (latestDecorations === undefined) { if (latestDecorations === undefined) {
await this.updateDecorationsFromServer( await this.updateDecorationsFromServer(
documentUri, documentUri,
editor! editor!
); );
} else { } else {
await editor!.setDecorations(typeHintDecorationType, latestDecorations); await editor!.setDecorations(
typeHintDecorationType,
latestDecorations
);
} }
} }
} }
@ -48,9 +53,12 @@ export class HintsUpdater {
if (displayHints) { if (displayHints) {
return this.updateHints(); return this.updateHints();
} else { } else {
const editor = vscode.window.activeTextEditor; const currentEditor = vscode.window.activeTextEditor;
if (this.getEditorDocumentUri(editor) !== null) { if (this.getEditorDocumentUri(currentEditor) !== null) {
return editor!.setDecorations(typeHintDecorationType, []); return currentEditor!.setDecorations(
typeHintDecorationType,
[]
);
} }
} }
} }
@ -92,7 +100,10 @@ export class HintsUpdater {
this.drawnDecorations.set(documentUri, newDecorations); this.drawnDecorations.set(documentUri, newDecorations);
if (this.getEditorDocumentUri(vscode.window.activeTextEditor) === documentUri) { if (
this.getEditorDocumentUri(vscode.window.activeTextEditor) ===
documentUri
) {
return editor.setDecorations( return editor.setDecorations(
typeHintDecorationType, typeHintDecorationType,
newDecorations newDecorations