diff --git a/src/vs/workbench/api/node/extHostDiagnostics.ts b/src/vs/workbench/api/node/extHostDiagnostics.ts index 60f96a01f2e..35542e775e7 100644 --- a/src/vs/workbench/api/node/extHostDiagnostics.ts +++ b/src/vs/workbench/api/node/extHostDiagnostics.ts @@ -116,7 +116,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection { orderLoop: for (let i = 0; i < 4; i++) { for (let diagnostic of diagnostics) { if (diagnostic.severity === order[i]) { - const len = marker.push(converter.fromDiagnostic(diagnostic)); + const len = marker.push(converter.Diagnostic.from(diagnostic)); if (len === DiagnosticCollection._maxDiagnosticsPerFile) { break orderLoop; } @@ -134,7 +134,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection { endColumn: marker[marker.length - 1].endColumn }); } else { - marker = diagnostics.map(converter.fromDiagnostic); + marker = diagnostics.map(converter.Diagnostic.from); } } diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 0b5d7475ecc..e824bee4c21 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -311,7 +311,7 @@ class CodeActionAdapter { result.push({ title: candidate.title, command: candidate.command && this._commands.toInternal(candidate.command), - diagnostics: candidate.diagnostics && candidate.diagnostics.map(typeConvert.fromDiagnostic), + diagnostics: candidate.diagnostics && candidate.diagnostics.map(typeConvert.Diagnostic.from), edit: candidate.edit && typeConvert.WorkspaceEdit.from(candidate.edit), kind: candidate.kind && candidate.kind.value }); diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 5b671d2c54c..1f6563cfac7 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -88,55 +88,60 @@ export namespace Position { } } -export function fromDiagnostic(value: vscode.Diagnostic): IMarkerData { - return { - ...Range.from(value.range), - message: value.message, - source: value.source, - code: String(value.code), - severity: fromDiagnosticSeverity(value.severity), - relatedInformation: value.relatedInformation && value.relatedInformation.map(fromDiagnosticRelatedInformation) - }; -} - -export function fromDiagnosticRelatedInformation(value: types.DiagnosticRelatedInformation): IRelatedInformation { - return { - ...Range.from(value.location.range), - message: value.message, - resource: value.location.uri - }; -} - -export function toDiagnosticRelatedInformation(value: IRelatedInformation): types.DiagnosticRelatedInformation { - return new types.DiagnosticRelatedInformation(new types.Location(value.resource, Range.to(value)), value.message); -} - -export function fromDiagnosticSeverity(value: number): MarkerSeverity { - switch (value) { - case types.DiagnosticSeverity.Error: - return MarkerSeverity.Error; - case types.DiagnosticSeverity.Warning: - return MarkerSeverity.Warning; - case types.DiagnosticSeverity.Information: - return MarkerSeverity.Info; - case types.DiagnosticSeverity.Hint: - return MarkerSeverity.Hint; +export namespace Diagnostic { + export function from(value: vscode.Diagnostic): IMarkerData { + return { + ...Range.from(value.range), + message: value.message, + source: value.source, + code: String(value.code), + severity: DiagnosticSeverity.from(value.severity), + relatedInformation: value.relatedInformation && value.relatedInformation.map(DiagnosticRelatedInformation.from) + }; } - return MarkerSeverity.Error; } -export function toDiagnosticSeverty(value: MarkerSeverity): types.DiagnosticSeverity { - switch (value) { - case MarkerSeverity.Info: - return types.DiagnosticSeverity.Information; - case MarkerSeverity.Warning: - return types.DiagnosticSeverity.Warning; - case MarkerSeverity.Error: - return types.DiagnosticSeverity.Error; - case MarkerSeverity.Hint: - return types.DiagnosticSeverity.Hint; +export namespace DiagnosticRelatedInformation { + export function from(value: types.DiagnosticRelatedInformation): IRelatedInformation { + return { + ...Range.from(value.location.range), + message: value.message, + resource: value.location.uri + }; + } + export function to(value: IRelatedInformation): types.DiagnosticRelatedInformation { + return new types.DiagnosticRelatedInformation(new types.Location(value.resource, Range.to(value)), value.message); + } +} +export namespace DiagnosticSeverity { + + export function from(value: number): MarkerSeverity { + switch (value) { + case types.DiagnosticSeverity.Error: + return MarkerSeverity.Error; + case types.DiagnosticSeverity.Warning: + return MarkerSeverity.Warning; + case types.DiagnosticSeverity.Information: + return MarkerSeverity.Info; + case types.DiagnosticSeverity.Hint: + return MarkerSeverity.Hint; + } + return MarkerSeverity.Error; + } + + export function to(value: MarkerSeverity): types.DiagnosticSeverity { + switch (value) { + case MarkerSeverity.Info: + return types.DiagnosticSeverity.Information; + case MarkerSeverity.Warning: + return types.DiagnosticSeverity.Warning; + case MarkerSeverity.Error: + return types.DiagnosticSeverity.Error; + case MarkerSeverity.Hint: + return types.DiagnosticSeverity.Hint; + } + return types.DiagnosticSeverity.Error; } - return types.DiagnosticSeverity.Error; }