adopt schemaValidation and schemaRequest (for https://github.com/microsoft/monaco-editor/issues/1852)

pull/2748/head
Martin Aeschlimann 4 years ago
parent 10776a19b8
commit 22746ae61a

9
monaco.d.ts vendored

@ -36,7 +36,16 @@ declare namespace monaco.languages.json {
* If set, the schema service would load schema content on-demand with 'fetch' if available
*/
readonly enableSchemaRequest?: boolean;
/**
* The severity of problems from schema validation. If set to 'ignore', schema validation will be skipped. If not set, 'warning' is used.
*/
readonly schemaValidation?: SeverityLevel;
/**
* The severity of problems that occurred when resolving and loading schemas. If set to 'ignore', schema resolving problems are not reported. If not set, 'warning' is used.
*/
readonly schemaRequest?: SeverityLevel;
}
export type SeverityLevel = 'error' | 'warning' | 'ignore';
export interface ModeConfiguration {
/**
* Defines whether the built-in documentFormattingEdit provider is enabled.

6
package-lock.json generated

@ -720,9 +720,9 @@
"dev": true
},
"vscode-json-languageservice": {
"version": "3.8.4",
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.8.4.tgz",
"integrity": "sha512-njDG0+YJvYNKXH+6plQGZMxgbifATFrRpC6Qnm/SAn4IW8bMHxsYunsxrjtpqK42CVSz6Lr7bpbTEZbVuOmFLw==",
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.9.0.tgz",
"integrity": "sha512-J+2rbntYRLNL9wk0D2iovWo1df3JwYM+5VvWl1omNUgw+XbgpNBwpFZ/TsC1pTCdmpu5RMatXooplXZ8l/Irsg==",
"dev": true,
"requires": {
"jsonc-parser": "^2.3.1",

@ -32,7 +32,7 @@
"requirejs": "^2.3.6",
"terser": "^5.3.2",
"typescript": "4.0.3",
"vscode-json-languageservice": "3.8.4",
"vscode-json-languageservice": "3.9.0",
"vscode-uri": "2.1.2"
},
"husky": {

@ -6,6 +6,7 @@
import * as jsonService from 'vscode-json-languageservice';
import type { worker } from './fillers/monaco-editor-core';
import { URI } from 'vscode-uri';
import { DiagnosticsOptions } from './monaco.contribution';
let defaultSchemaRequestService;
if (typeof fetch !== 'undefined') {
@ -17,7 +18,7 @@ if (typeof fetch !== 'undefined') {
export class JSONWorker {
private _ctx: worker.IWorkerContext;
private _languageService: jsonService.LanguageService;
private _languageSettings: jsonService.LanguageSettings;
private _languageSettings: DiagnosticsOptions;
private _languageId: string;
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
@ -40,7 +41,7 @@ export class JSONWorker {
let document = this._getTextDocument(uri);
if (document) {
let jsonDocument = this._languageService.parseJSONDocument(document);
return this._languageService.doValidation(document, jsonDocument);
return this._languageService.doValidation(document, jsonDocument, this._languageSettings);
}
return Promise.resolve([]);
}
@ -182,7 +183,7 @@ function joinPath(uriString: string, ...paths: string[]): string {
export interface ICreateData {
languageId: string;
languageSettings: jsonService.LanguageSettings;
languageSettings: DiagnosticsOptions;
enableSchemaRequest: boolean;
}

@ -38,8 +38,18 @@ export interface DiagnosticsOptions {
* If set, the schema service would load schema content on-demand with 'fetch' if available
*/
readonly enableSchemaRequest?: boolean;
/**
* The severity of problems from schema validation. If set to 'ignore', schema validation will be skipped. If not set, 'warning' is used.
*/
readonly schemaValidation?: SeverityLevel;
/**
* The severity of problems that occurred when resolving and loading schemas. If set to 'ignore', schema resolving problems are not reported. If not set, 'warning' is used.
*/
readonly schemaRequest?: SeverityLevel;
}
export declare type SeverityLevel = 'error' | 'warning' | 'ignore';
export interface ModeConfiguration {
/**
* Defines whether the built-in documentFormattingEdit provider is enabled.
@ -148,7 +158,9 @@ const diagnosticDefault: Required<DiagnosticsOptions> = {
validate: true,
allowComments: true,
schemas: [],
enableSchemaRequest: false
enableSchemaRequest: false,
schemaRequest: 'warning',
schemaValidation: 'warning'
};
const modeConfigurationDefault: Required<ModeConfiguration> = {

Loading…
Cancel
Save