1931: Support the new deprecated tag r=matklad a=arsdragonfly

Which is rendered as a strike-through line. Fixes #1671 .
![深度截图_选择区域_20190927162008](https://user-images.githubusercontent.com/4067473/65799714-ccb4c180-e142-11e9-8e45-ab18964605f3.png)


Co-authored-by: arsdragonfly <arsdragonfly@gmail.com>
This commit is contained in:
bors[bot] 2019-09-28 15:59:28 +00:00 committed by GitHub
commit dbdf0e24d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -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, []);

View File

@ -111,6 +111,17 @@ 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
*
@ -200,6 +211,7 @@ export function mapRustDiagnosticToVsCode(
vd.source = source;
vd.code = code;
vd.relatedInformation = [];
vd.tags = [];
for (const secondarySpan of secondarySpans) {
const related = mapSecondarySpanToRelated(secondarySpan);
@ -234,7 +246,11 @@ export function mapRustDiagnosticToVsCode(
}
if (isUnusedOrUnnecessary(rd)) {
vd.tags = [vscode.DiagnosticTag.Unnecessary];
vd.tags.push(vscode.DiagnosticTag.Unnecessary);
}
if (isDeprecated(rd)) {
vd.tags.push(vscode.DiagnosticTag.Deprecated);
}
return {