diagnostic.severity,
vscode.DiagnosticSeverity.Error
);
+ assert.strictEqual(diagnostic.source, 'rustc');
assert.strictEqual(
diagnostic.message,
[
].join('\n')
);
assert.strictEqual(diagnostic.code, 'unused_variables');
+ assert.strictEqual(diagnostic.source, 'rustc');
assert.deepStrictEqual(diagnostic.tags, [
vscode.DiagnosticTag.Unnecessary
]);
'this function takes 2 parameters but 3 parameters were supplied'
);
assert.strictEqual(diagnostic.code, 'E0061');
+ assert.strictEqual(diagnostic.source, 'rustc');
assert.strictEqual(diagnostic.tags, undefined);
// One related information for the original definition
diagnostic.severity,
vscode.DiagnosticSeverity.Warning
);
+ assert.strictEqual(diagnostic.source, 'clippy');
assert.strictEqual(
diagnostic.message,
[
'for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref'
].join('\n')
);
- assert.strictEqual(
- diagnostic.code,
- 'clippy::trivially_copy_pass_by_ref'
- );
+ assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref');
assert.strictEqual(diagnostic.tags, undefined);
// One related information for the lint definition
assert(areDiagnosticsEqual(diagnostic1, diagnostic2));
});
+ it('should treat diagnostics with different sources as inequal', () => {
+ const diagnostic1 = new vscode.Diagnostic(
+ range1,
+ 'Hello, world!',
+ vscode.DiagnosticSeverity.Error
+ );
+ diagnostic1.source = 'rustc';
+
+ const diagnostic2 = new vscode.Diagnostic(
+ range1,
+ 'Hello, world!',
+ vscode.DiagnosticSeverity.Error
+ );
+ diagnostic2.source = 'clippy';
+
+ assert(!areDiagnosticsEqual(diagnostic1, diagnostic2));
+ });
+
it('should treat diagnostics with different ranges as inequal', () => {
const diagnostic1 = new vscode.Diagnostic(
range1,
const vd = new vscode.Diagnostic(location.range, rd.message, severity);
- vd.source = 'rustc';
- vd.code = rd.code ? rd.code.code : undefined;
+ let source = 'rustc';
+ let code = rd.code && rd.code.code;
+ if (code) {
+ // See if this is an RFC #2103 scoped lint (e.g. from Clippy)
+ const scopedCode = code.split('::');
+ if (scopedCode.length === 2) {
+ [source, code] = scopedCode;
+ }
+ }
+
+ vd.source = source;
+ vd.code = code;
vd.relatedInformation = [];
for (const secondarySpan of secondarySpans) {