From d1988a17f4ceb90bcdaed79072c4b7f647c86854 Mon Sep 17 00:00:00 2001 From: arsdragonfly Date: Fri, 27 Sep 2019 16:17:02 -0400 Subject: Support the new deprecated tag --- editors/code/src/utils/diagnostics/rust.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts index 1fb1f7b6d..a66b52313 100644 --- a/editors/code/src/utils/diagnostics/rust.ts +++ b/editors/code/src/utils/diagnostics/rust.ts @@ -111,6 +111,19 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean { ].includes(rd.code.code); } +/** + * Determines if diagnostic is related to deprecated code + */ +function isDeprecated(rd: RustDiagnostic): boolean { + if (!rd.code) { + return false; + } + + return [ + 'deprecated', + ].includes(rd.code.code); +} + /** * Converts a Rust child diagnostic to a VsCode related information * @@ -233,8 +246,14 @@ export function mapRustDiagnosticToVsCode( vd.message += `\n${primarySpanLabel}`; } + vd.tags = [] + if (isUnusedOrUnnecessary(rd)) { - vd.tags = [vscode.DiagnosticTag.Unnecessary]; + vd.tags.push(vscode.DiagnosticTag.Unnecessary); + } + + if (isDeprecated(rd)) { + vd.tags.push(vscode.DiagnosticTag.Deprecated); } return { -- cgit v1.2.3 From 945679e42fbefe565cb37456d3cf9cc3b0da6df5 Mon Sep 17 00:00:00 2001 From: arsdragonfly Date: Fri, 27 Sep 2019 17:33:14 -0400 Subject: Fix tests --- editors/code/src/test/utils/diagnotics/rust.test.ts | 8 ++++---- editors/code/src/utils/diagnostics/rust.ts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/editors/code/src/test/utils/diagnotics/rust.test.ts b/editors/code/src/test/utils/diagnotics/rust.test.ts index 7fb003fe2..327d15046 100644 --- a/editors/code/src/test/utils/diagnotics/rust.test.ts +++ b/editors/code/src/test/utils/diagnotics/rust.test.ts @@ -50,7 +50,7 @@ describe('mapRustDiagnosticToVsCode', () => { ].join('\n') ); assert.strictEqual(diagnostic.code, 'E0053'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // No related information assert.deepStrictEqual(diagnostic.relatedInformation, []); @@ -115,7 +115,7 @@ describe('mapRustDiagnosticToVsCode', () => { ); assert.strictEqual(diagnostic.code, 'E0061'); assert.strictEqual(diagnostic.source, 'rustc'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // One related information for the original definition const relatedInformation = diagnostic.relatedInformation; @@ -149,7 +149,7 @@ describe('mapRustDiagnosticToVsCode', () => { ].join('\n') ); assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // One related information for the lint definition const relatedInformation = diagnostic.relatedInformation; @@ -189,7 +189,7 @@ describe('mapRustDiagnosticToVsCode', () => { ); assert.strictEqual(diagnostic.code, 'E0308'); assert.strictEqual(diagnostic.source, 'rustc'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // No related information assert.deepStrictEqual(diagnostic.relatedInformation, []); diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts index a66b52313..cd02ee46c 100644 --- a/editors/code/src/utils/diagnostics/rust.ts +++ b/editors/code/src/utils/diagnostics/rust.ts @@ -213,6 +213,7 @@ export function mapRustDiagnosticToVsCode( vd.source = source; vd.code = code; vd.relatedInformation = []; + vd.tags = []; for (const secondarySpan of secondarySpans) { const related = mapSecondarySpanToRelated(secondarySpan); @@ -246,8 +247,6 @@ export function mapRustDiagnosticToVsCode( vd.message += `\n${primarySpanLabel}`; } - vd.tags = [] - if (isUnusedOrUnnecessary(rd)) { vd.tags.push(vscode.DiagnosticTag.Unnecessary); } -- cgit v1.2.3 From 17d1405a8b4eddedaf3665fc41ff4fa17a1409a7 Mon Sep 17 00:00:00 2001 From: arsdragonfly Date: Fri, 27 Sep 2019 20:02:51 -0400 Subject: Fix --- editors/code/src/utils/diagnostics/rust.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts index cd02ee46c..0550d0372 100644 --- a/editors/code/src/utils/diagnostics/rust.ts +++ b/editors/code/src/utils/diagnostics/rust.ts @@ -119,9 +119,7 @@ function isDeprecated(rd: RustDiagnostic): boolean { return false; } - return [ - 'deprecated', - ].includes(rd.code.code); + return ['deprecated'].includes(rd.code.code); } /** -- cgit v1.2.3