aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-08-04 22:47:14 +0100
committerKirill Bulatov <[email protected]>2019-08-04 23:02:36 +0100
commit3fb6462d54c498bfd8835dea29ead19d95099625 (patch)
treeb9a19c3cd9d75cd9a51315f1761e704bc04fd032
parent15411d4474ceaacf10787f52c916ade3dea0eb49 (diff)
Style and test fixes
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs56
-rw-r--r--editors/code/src/commands/inlay_hints.ts23
2 files changed, 45 insertions, 34 deletions
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 60a2c7cf5..7b9190314 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -216,52 +216,52 @@ fn main() {
216 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 216 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
217 InlayHint { 217 InlayHint {
218 range: [193; 197), 218 range: [193; 197),
219 kind: LetBindingType, 219 kind: TypeHint,
220 label: "i32", 220 label: "i32",
221 }, 221 },
222 InlayHint { 222 InlayHint {
223 range: [236; 244), 223 range: [236; 244),
224 kind: LetBindingType, 224 kind: TypeHint,
225 label: "i32", 225 label: "i32",
226 }, 226 },
227 InlayHint { 227 InlayHint {
228 range: [275; 279), 228 range: [275; 279),
229 kind: LetBindingType, 229 kind: TypeHint,
230 label: "&str", 230 label: "&str",
231 }, 231 },
232 InlayHint { 232 InlayHint {
233 range: [539; 543), 233 range: [539; 543),
234 kind: LetBindingType, 234 kind: TypeHint,
235 label: "(i32, char)", 235 label: "(i32, char)",
236 }, 236 },
237 InlayHint { 237 InlayHint {
238 range: [566; 567), 238 range: [566; 567),
239 kind: LetBindingType, 239 kind: TypeHint,
240 label: "i32", 240 label: "i32",
241 }, 241 },
242 InlayHint { 242 InlayHint {
243 range: [570; 571), 243 range: [570; 571),
244 kind: LetBindingType, 244 kind: TypeHint,
245 label: "i32", 245 label: "i32",
246 }, 246 },
247 InlayHint { 247 InlayHint {
248 range: [573; 574), 248 range: [573; 574),
249 kind: LetBindingType, 249 kind: TypeHint,
250 label: "i32", 250 label: "i32",
251 }, 251 },
252 InlayHint { 252 InlayHint {
253 range: [584; 585), 253 range: [584; 585),
254 kind: LetBindingType, 254 kind: TypeHint,
255 label: "i32", 255 label: "i32",
256 }, 256 },
257 InlayHint { 257 InlayHint {
258 range: [577; 578), 258 range: [577; 578),
259 kind: LetBindingType, 259 kind: TypeHint,
260 label: "f64", 260 label: "f64",
261 }, 261 },
262 InlayHint { 262 InlayHint {
263 range: [580; 581), 263 range: [580; 581),
264 kind: LetBindingType, 264 kind: TypeHint,
265 label: "f64", 265 label: "f64",
266 }, 266 },
267]"# 267]"#
@@ -283,12 +283,12 @@ fn main() {
283 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 283 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
284 InlayHint { 284 InlayHint {
285 range: [21; 30), 285 range: [21; 30),
286 kind: LetBindingType, 286 kind: TypeHint,
287 label: "i32", 287 label: "i32",
288 }, 288 },
289 InlayHint { 289 InlayHint {
290 range: [57; 66), 290 range: [57; 66),
291 kind: ClosureParameterType, 291 kind: TypeHint,
292 label: "i32", 292 label: "i32",
293 }, 293 },
294]"# 294]"#
@@ -310,12 +310,12 @@ fn main() {
310 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 310 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
311 InlayHint { 311 InlayHint {
312 range: [21; 30), 312 range: [21; 30),
313 kind: LetBindingType, 313 kind: TypeHint,
314 label: "i32", 314 label: "i32",
315 }, 315 },
316 InlayHint { 316 InlayHint {
317 range: [44; 53), 317 range: [44; 53),
318 kind: ForExpressionBindingType, 318 kind: TypeHint,
319 label: "i32", 319 label: "i32",
320 }, 320 },
321]"# 321]"#
@@ -356,27 +356,27 @@ fn main() {
356 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 356 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
357 InlayHint { 357 InlayHint {
358 range: [166; 170), 358 range: [166; 170),
359 kind: LetBindingType, 359 kind: TypeHint,
360 label: "CustomOption<Test>", 360 label: "CustomOption<Test>",
361 }, 361 },
362 InlayHint { 362 InlayHint {
363 range: [334; 338), 363 range: [334; 338),
364 kind: IfExpressionType, 364 kind: TypeHint,
365 label: "&Test", 365 label: "&Test",
366 }, 366 },
367 InlayHint { 367 InlayHint {
368 range: [389; 390), 368 range: [389; 390),
369 kind: IfExpressionType, 369 kind: TypeHint,
370 label: "&CustomOption<u32>", 370 label: "&CustomOption<u32>",
371 }, 371 },
372 InlayHint { 372 InlayHint {
373 range: [392; 393), 373 range: [392; 393),
374 kind: IfExpressionType, 374 kind: TypeHint,
375 label: "&u8", 375 label: "&u8",
376 }, 376 },
377 InlayHint { 377 InlayHint {
378 range: [531; 532), 378 range: [531; 532),
379 kind: IfExpressionType, 379 kind: TypeHint,
380 label: "&u32", 380 label: "&u32",
381 }, 381 },
382]"# 382]"#
@@ -417,7 +417,7 @@ fn main() {
417 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 417 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
418 InlayHint { 418 InlayHint {
419 range: [166; 170), 419 range: [166; 170),
420 kind: LetBindingType, 420 kind: TypeHint,
421 label: "CustomOption<Test>", 421 label: "CustomOption<Test>",
422 }, 422 },
423]"# 423]"#
@@ -457,23 +457,23 @@ fn main() {
457 457
458 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 458 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
459 InlayHint { 459 InlayHint {
460 range: [312; 316), 460 range: [311; 315),
461 kind: MatchArmType, 461 kind: TypeHint,
462 label: "Test", 462 label: "Test",
463 }, 463 },
464 InlayHint { 464 InlayHint {
465 range: [359; 360), 465 range: [358; 359),
466 kind: MatchArmType, 466 kind: TypeHint,
467 label: "CustomOption<u32>", 467 label: "CustomOption<u32>",
468 }, 468 },
469 InlayHint { 469 InlayHint {
470 range: [362; 363), 470 range: [361; 362),
471 kind: MatchArmType, 471 kind: TypeHint,
472 label: "u8", 472 label: "u8",
473 }, 473 },
474 InlayHint { 474 InlayHint {
475 range: [485; 486), 475 range: [484; 485),
476 kind: MatchArmType, 476 kind: TypeHint,
477 label: "u32", 477 label: "u32",
478 }, 478 },
479]"# 479]"#
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts
index 5af3a69bc..11a2cfac5 100644
--- a/editors/code/src/commands/inlay_hints.ts
+++ b/editors/code/src/commands/inlay_hints.ts
@@ -27,14 +27,19 @@ export class HintsUpdater {
27 if (this.displayHints) { 27 if (this.displayHints) {
28 const documentUri = this.getEditorDocumentUri(editor); 28 const documentUri = this.getEditorDocumentUri(editor);
29 if (documentUri !== null) { 29 if (documentUri !== null) {
30 const latestDecorations = this.drawnDecorations.get(documentUri); 30 const latestDecorations = this.drawnDecorations.get(
31 documentUri
32 );
31 if (latestDecorations === undefined) { 33 if (latestDecorations === undefined) {
32 await this.updateDecorationsFromServer( 34 await this.updateDecorationsFromServer(
33 documentUri, 35 documentUri,
34 editor! 36 editor!
35 ); 37 );
36 } else { 38 } else {
37 await editor!.setDecorations(typeHintDecorationType, latestDecorations); 39 await editor!.setDecorations(
40 typeHintDecorationType,
41 latestDecorations
42 );
38 } 43 }
39 } 44 }
40 } 45 }
@@ -48,9 +53,12 @@ export class HintsUpdater {
48 if (displayHints) { 53 if (displayHints) {
49 return this.updateHints(); 54 return this.updateHints();
50 } else { 55 } else {
51 const editor = vscode.window.activeTextEditor; 56 const currentEditor = vscode.window.activeTextEditor;
52 if (this.getEditorDocumentUri(editor) !== null) { 57 if (this.getEditorDocumentUri(currentEditor) !== null) {
53 return editor!.setDecorations(typeHintDecorationType, []); 58 return currentEditor!.setDecorations(
59 typeHintDecorationType,
60 []
61 );
54 } 62 }
55 } 63 }
56 } 64 }
@@ -92,7 +100,10 @@ export class HintsUpdater {
92 100
93 this.drawnDecorations.set(documentUri, newDecorations); 101 this.drawnDecorations.set(documentUri, newDecorations);
94 102
95 if (this.getEditorDocumentUri(vscode.window.activeTextEditor) === documentUri) { 103 if (
104 this.getEditorDocumentUri(vscode.window.activeTextEditor) ===
105 documentUri
106 ) {
96 return editor.setDecorations( 107 return editor.setDecorations(
97 typeHintDecorationType, 108 typeHintDecorationType,
98 newDecorations 109 newDecorations