diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 8fec9a5b62d09..b19a3b797a4ee 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -9,12 +9,6 @@ declare module 'vscode' { //#region "read diagnostics" - export interface DiagnosticInformation { - has(uri: Uri): boolean; - get(uri: Uri): Diagnostic[] | undefined; - all(): [Uri, Diagnostic[]][]; - } - export interface DiagnosticChangeEvent { uris: Uri[]; } @@ -26,7 +20,10 @@ declare module 'vscode' { */ export const onDidChangeDiagnostics: Event; - export const diagnostics: DiagnosticInformation; + /** + * + */ + export function getDiagnostics(resource?: Uri): Diagnostic[]; } //#endregion diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index fc60b35cffbfe..37ffb6502824f 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -236,11 +236,9 @@ export function createApiFactory( checkProposedApiEnabled(extension); return extHostDiagnostics.onDidChangeDiagnostics; }, - diagnostics: { - has: proposedApiFunction(extension, uri => extHostDiagnostics.hasDiagnostics(uri)), - get: proposedApiFunction(extension, uri => extHostDiagnostics.getDiagnostics(uri)), - all: proposedApiFunction(extension, () => extHostDiagnostics.getAllDiagnostics()) - }, + getDiagnostics: proposedApiFunction(extension, resource => { + return extHostDiagnostics.getDiagnostics(resource); + }), getLanguages(): TPromise { return extHostLanguages.getLanguages(); }, diff --git a/src/vs/workbench/api/node/extHostDiagnostics.ts b/src/vs/workbench/api/node/extHostDiagnostics.ts index f1f424a703a31..5f47a2d79f72c 100644 --- a/src/vs/workbench/api/node/extHostDiagnostics.ts +++ b/src/vs/workbench/api/node/extHostDiagnostics.ts @@ -287,38 +287,18 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape { return result; } - hasDiagnostics(resource: vscode.Uri): boolean { - for (const collection of this._collections) { - if (collection.has(resource)) { - return true; - } - } - return false; - } - - getDiagnostics(resource: vscode.Uri): vscode.Diagnostic[] { + getDiagnostics(resource?: vscode.Uri): vscode.Diagnostic[] { let res: vscode.Diagnostic[] = []; for (const collection of this._collections) { - if (collection.has(resource)) { - res = res.concat(collection.get(resource)); - } - } - return res; - } - - getAllDiagnostics(): [vscode.Uri, vscode.Diagnostic[]][] { - let map = new Map(); - let res: [vscode.Uri, vscode.Diagnostic[]][] = []; - for (const collection of this._collections) { - collection.forEach((resource: vscode.Uri, diagnostics: vscode.Diagnostic[]) => { - let index = map.get(resource.toString()); - if (typeof index === 'undefined') { - index = res.length; - res.push([resource, []]); - map.set(resource.toString(), index); + if (resource) { + // filtered + if (collection.has(resource)) { + res = res.concat(collection.get(resource)); } - res[index][1] = res[index][1].concat(diagnostics); - }); + } else { + // all + collection.forEach((uri, diag) => res = res.concat(diag)); + } } return res; }