本文整理汇总了TypeScript中vs/workbench/api/node/extHostDiagnostics.DiagnosticCollection类的典型用法代码示例。如果您正苦于以下问题:TypeScript DiagnosticCollection类的具体用法?TypeScript DiagnosticCollection怎么用?TypeScript DiagnosticCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DiagnosticCollection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('diagnostics with related information', function (done) {
let collection = new DiagnosticCollection('ddd', new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
let [[, data]] = entries;
assert.equal(entries.length, 1);
assert.equal(data.length, 1);
let [diag] = data;
assert.equal(diag.relatedInformation.length, 2);
assert.equal(diag.relatedInformation[0].message, 'more1');
assert.equal(diag.relatedInformation[1].message, 'more2');
done();
}
}, new Emitter<any>());
let diag = new Diagnostic(new Range(0, 0, 1, 1), 'Foo');
diag.relatedInformation = [
new DiagnosticRelatedInformation(new Location(URI.parse('cc:dd'), new Range(0, 0, 0, 0)), 'more1'),
new DiagnosticRelatedInformation(new Location(URI.parse('cc:ee'), new Range(0, 0, 0, 0)), 'more2')
];
collection.set(URI.parse('aa:bb'), [diag]);
});
示例2: test
test('diagnostic capping', function () {
let lastEntries: [URI, IMarkerData[]][];
let collection = new DiagnosticCollection('test', new class extends DiagnosticsShape {
$changeMany(owner: string, entries: [URI, IMarkerData[]][]): TPromise<any> {
lastEntries = entries;
return super.$changeMany(owner, entries);
}
});
let uri = URI.parse('aa:bb');
let diagnostics: Diagnostic[] = [];
for (let i = 0; i < 500; i++) {
diagnostics.push(new Diagnostic(new Range(i, 0, i + 1, 0), `error#${i}`, i < 300
? DiagnosticSeverity.Warning
: DiagnosticSeverity.Error));
}
collection.set(uri, diagnostics);
assert.equal(collection.get(uri).length, 500);
assert.equal(lastEntries.length, 1);
assert.equal(lastEntries[0][1].length, 251);
assert.equal(lastEntries[0][1][0].severity, Severity.Error);
assert.equal(lastEntries[0][1][200].severity, Severity.Warning);
assert.equal(lastEntries[0][1][250].severity, Severity.Error);
});
示例3: test
test('disposeCheck', () => {
const collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
collection.dispose();
collection.dispose(); // that's OK
assert.throws(() => collection.name);
assert.throws(() => collection.clear());
assert.throws(() => collection.delete(URI.parse('aa:bb')));
// tslint:disable-next-line:semicolon
assert.throws(() => collection.forEach(() => { ; }));
assert.throws(() => collection.get(URI.parse('aa:bb')));
assert.throws(() => collection.has(URI.parse('aa:bb')));
assert.throws(() => collection.set(URI.parse('aa:bb'), []));
assert.throws(() => collection.set(URI.parse('aa:bb'), undefined!));
});