Use ErrorCode in JSON Language Service schema resolution error handling

This adds a dependency on vscode-json-languageservice to the client,
which might not be desired, but allows for cleaner code and the correct
reference should the error codes change.
This commit is contained in:
Literallie
2018-10-09 01:46:24 +02:00
parent 157ee8c394
commit 0137ebd471
3 changed files with 24 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ const localize = nls.loadMessageBundle();
import { workspace, window, languages, ExtensionContext, extensions, Uri, LanguageConfiguration, Diagnostic } from 'vscode';
import { LanguageClient, LanguageClientOptions, RequestType, ServerOptions, TransportKind, NotificationType, DidChangeConfigurationNotification, HandleDiagnosticsSignature } from 'vscode-languageclient';
import { ErrorCode } from 'vscode-json-languageservice';
import TelemetryReporter from 'vscode-extension-telemetry';
import { hash } from './utils/hash';
@@ -92,7 +93,7 @@ export function activate(context: ExtensionContext) {
},
handleDiagnostics: (uri: Uri, diagnostics: Diagnostic[], next: HandleDiagnosticsSignature) => {
let schemaResolveDiagnostic = diagnostics
.find(candidate => candidate.code === /* SchemaResolveError */ 0x300);
.find(candidate => candidate.code === ErrorCode.SchemaResolveError);
if (schemaResolveDiagnostic) {
// Show schema resolution errors in status bar only; ref: #51032
window.showWarningMessage(schemaResolveDiagnostic.message);