From 8b470712c96f504f9861cdd8475d43d08ae6b8e3 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 6 Apr 2018 10:25:11 +0200 Subject: [PATCH] make diagnostics read api public, #30075 --- src/vs/vscode.d.ts | 34 +++++++++++++++++++ src/vs/vscode.proposed.d.ts | 26 -------------- src/vs/workbench/api/node/extHost.api.impl.ts | 6 ++-- .../workbench/api/node/extHostDiagnostics.ts | 1 + 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 8142906c5ec..92b14c0281b 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3680,6 +3680,17 @@ declare module 'vscode' { constructor(uri: Uri, rangeOrPosition: Range | Position); } + /** + * The event that is fired when diagnostics change. + */ + export interface DiagnosticChangeEvent { + + /** + * An array of resources for which diagnostics have changed. + */ + readonly uris: Uri[]; + } + /** * Represents the severity of diagnostics. */ @@ -6044,6 +6055,29 @@ declare module 'vscode' { */ export function match(selector: DocumentSelector, document: TextDocument): number; + /** + * An [event](#Event) which fires when the global set of diagnostics changes. This is + * newly added and removed diagnostics. + */ + export const onDidChangeDiagnostics: Event; + + /** + * Get all diagnostics for a given resource. *Note* that this includes diagnostics from + * all extensions but *not yet* from the task framework. + * + * @param resource A resource + * @returns An arrary of [diagnostics](#Diagnostic) objects or an empty array. + */ + export function getDiagnostics(resource: Uri): Diagnostic[]; + + /** + * Get all diagnostics. *Note* that this includes diagnostics from + * all extensions but *not yet* from the task framework. + * + * @returns An array of uri-diagnostics tuples or an empty array. + */ + export function getDiagnostics(): [Uri, Diagnostic[]][]; + /** * Create a diagnostics collection. * diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index f61737f5919..8704ce7f6f8 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -11,32 +11,6 @@ declare module 'vscode' { export function sampleFunction(): Thenable; } - //#region Joh: readable diagnostics - - export interface DiagnosticChangeEvent { - uris: Uri[]; - } - - export namespace languages { - - /** - * - */ - export const onDidChangeDiagnostics: Event; - - /** - * - */ - export function getDiagnostics(resource: Uri): Diagnostic[]; - - /** - * - */ - export function getDiagnostics(): [Uri, Diagnostic[]][]; - } - - //#endregion - //#region Aeschli: folding export class FoldingRangeList { diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 6757325af76..bd3e382a66f 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -237,9 +237,9 @@ export function createApiFactory( checkProposedApiEnabled(extension); return extHostDiagnostics.onDidChangeDiagnostics; }, - getDiagnostics: proposedApiFunction(extension, (resource?) => { - return extHostDiagnostics.getDiagnostics(resource); - }), + getDiagnostics: (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 342060762d7..60f96a01f2e 100644 --- a/src/vs/workbench/api/node/extHostDiagnostics.ts +++ b/src/vs/workbench/api/node/extHostDiagnostics.ts @@ -229,6 +229,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape { } } } + Object.freeze(uris); return { uris }; } -- GitLab