diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/test/utils/diagnotics/rust.test.ts | 8 | ||||
-rw-r--r-- | editors/code/src/utils/diagnostics/rust.ts | 18 |
2 files changed, 21 insertions, 5 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', () => { | |||
50 | ].join('\n') | 50 | ].join('\n') |
51 | ); | 51 | ); |
52 | assert.strictEqual(diagnostic.code, 'E0053'); | 52 | assert.strictEqual(diagnostic.code, 'E0053'); |
53 | assert.strictEqual(diagnostic.tags, undefined); | 53 | assert.deepStrictEqual(diagnostic.tags, []); |
54 | 54 | ||
55 | // No related information | 55 | // No related information |
56 | assert.deepStrictEqual(diagnostic.relatedInformation, []); | 56 | assert.deepStrictEqual(diagnostic.relatedInformation, []); |
@@ -115,7 +115,7 @@ describe('mapRustDiagnosticToVsCode', () => { | |||
115 | ); | 115 | ); |
116 | assert.strictEqual(diagnostic.code, 'E0061'); | 116 | assert.strictEqual(diagnostic.code, 'E0061'); |
117 | assert.strictEqual(diagnostic.source, 'rustc'); | 117 | assert.strictEqual(diagnostic.source, 'rustc'); |
118 | assert.strictEqual(diagnostic.tags, undefined); | 118 | assert.deepStrictEqual(diagnostic.tags, []); |
119 | 119 | ||
120 | // One related information for the original definition | 120 | // One related information for the original definition |
121 | const relatedInformation = diagnostic.relatedInformation; | 121 | const relatedInformation = diagnostic.relatedInformation; |
@@ -149,7 +149,7 @@ describe('mapRustDiagnosticToVsCode', () => { | |||
149 | ].join('\n') | 149 | ].join('\n') |
150 | ); | 150 | ); |
151 | assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref'); | 151 | assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref'); |
152 | assert.strictEqual(diagnostic.tags, undefined); | 152 | assert.deepStrictEqual(diagnostic.tags, []); |
153 | 153 | ||
154 | // One related information for the lint definition | 154 | // One related information for the lint definition |
155 | const relatedInformation = diagnostic.relatedInformation; | 155 | const relatedInformation = diagnostic.relatedInformation; |
@@ -189,7 +189,7 @@ describe('mapRustDiagnosticToVsCode', () => { | |||
189 | ); | 189 | ); |
190 | assert.strictEqual(diagnostic.code, 'E0308'); | 190 | assert.strictEqual(diagnostic.code, 'E0308'); |
191 | assert.strictEqual(diagnostic.source, 'rustc'); | 191 | assert.strictEqual(diagnostic.source, 'rustc'); |
192 | assert.strictEqual(diagnostic.tags, undefined); | 192 | assert.deepStrictEqual(diagnostic.tags, []); |
193 | 193 | ||
194 | // No related information | 194 | // No related information |
195 | assert.deepStrictEqual(diagnostic.relatedInformation, []); | 195 | assert.deepStrictEqual(diagnostic.relatedInformation, []); |
diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts index 1fb1f7b6d..0550d0372 100644 --- a/editors/code/src/utils/diagnostics/rust.ts +++ b/editors/code/src/utils/diagnostics/rust.ts | |||
@@ -112,6 +112,17 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean { | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * Determines if diagnostic is related to deprecated code | ||
116 | */ | ||
117 | function isDeprecated(rd: RustDiagnostic): boolean { | ||
118 | if (!rd.code) { | ||
119 | return false; | ||
120 | } | ||
121 | |||
122 | return ['deprecated'].includes(rd.code.code); | ||
123 | } | ||
124 | |||
125 | /** | ||
115 | * Converts a Rust child diagnostic to a VsCode related information | 126 | * Converts a Rust child diagnostic to a VsCode related information |
116 | * | 127 | * |
117 | * This can have three outcomes: | 128 | * This can have three outcomes: |
@@ -200,6 +211,7 @@ export function mapRustDiagnosticToVsCode( | |||
200 | vd.source = source; | 211 | vd.source = source; |
201 | vd.code = code; | 212 | vd.code = code; |
202 | vd.relatedInformation = []; | 213 | vd.relatedInformation = []; |
214 | vd.tags = []; | ||
203 | 215 | ||
204 | for (const secondarySpan of secondarySpans) { | 216 | for (const secondarySpan of secondarySpans) { |
205 | const related = mapSecondarySpanToRelated(secondarySpan); | 217 | const related = mapSecondarySpanToRelated(secondarySpan); |
@@ -234,7 +246,11 @@ export function mapRustDiagnosticToVsCode( | |||
234 | } | 246 | } |
235 | 247 | ||
236 | if (isUnusedOrUnnecessary(rd)) { | 248 | if (isUnusedOrUnnecessary(rd)) { |
237 | vd.tags = [vscode.DiagnosticTag.Unnecessary]; | 249 | vd.tags.push(vscode.DiagnosticTag.Unnecessary); |
250 | } | ||
251 | |||
252 | if (isDeprecated(rd)) { | ||
253 | vd.tags.push(vscode.DiagnosticTag.Deprecated); | ||
238 | } | 254 | } |
239 | 255 | ||
240 | return { | 256 | return { |