mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +01:00
adopt schemaValidation and schemaRequest (for https://github.com/microsoft/monaco-editor/issues/1852)
This commit is contained in:
parent
10776a19b8
commit
22746ae61a
5 changed files with 30 additions and 8 deletions
9
monaco.d.ts
vendored
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
|
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||||
*/
|
*/
|
||||||
readonly enableSchemaRequest?: boolean;
|
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 {
|
export interface ModeConfiguration {
|
||||||
/**
|
/**
|
||||||
* Defines whether the built-in documentFormattingEdit provider is enabled.
|
* Defines whether the built-in documentFormattingEdit provider is enabled.
|
||||||
|
|
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -720,9 +720,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"vscode-json-languageservice": {
|
"vscode-json-languageservice": {
|
||||||
"version": "3.8.4",
|
"version": "3.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.8.4.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-3.9.0.tgz",
|
||||||
"integrity": "sha512-njDG0+YJvYNKXH+6plQGZMxgbifATFrRpC6Qnm/SAn4IW8bMHxsYunsxrjtpqK42CVSz6Lr7bpbTEZbVuOmFLw==",
|
"integrity": "sha512-J+2rbntYRLNL9wk0D2iovWo1df3JwYM+5VvWl1omNUgw+XbgpNBwpFZ/TsC1pTCdmpu5RMatXooplXZ8l/Irsg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"jsonc-parser": "^2.3.1",
|
"jsonc-parser": "^2.3.1",
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
"terser": "^5.3.2",
|
"terser": "^5.3.2",
|
||||||
"typescript": "4.0.3",
|
"typescript": "4.0.3",
|
||||||
"vscode-json-languageservice": "3.8.4",
|
"vscode-json-languageservice": "3.9.0",
|
||||||
"vscode-uri": "2.1.2"
|
"vscode-uri": "2.1.2"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
import * as jsonService from 'vscode-json-languageservice';
|
import * as jsonService from 'vscode-json-languageservice';
|
||||||
import type { worker } from './fillers/monaco-editor-core';
|
import type { worker } from './fillers/monaco-editor-core';
|
||||||
import { URI } from 'vscode-uri';
|
import { URI } from 'vscode-uri';
|
||||||
|
import { DiagnosticsOptions } from './monaco.contribution';
|
||||||
|
|
||||||
let defaultSchemaRequestService;
|
let defaultSchemaRequestService;
|
||||||
if (typeof fetch !== 'undefined') {
|
if (typeof fetch !== 'undefined') {
|
||||||
|
|
@ -17,7 +18,7 @@ if (typeof fetch !== 'undefined') {
|
||||||
export class JSONWorker {
|
export class JSONWorker {
|
||||||
private _ctx: worker.IWorkerContext;
|
private _ctx: worker.IWorkerContext;
|
||||||
private _languageService: jsonService.LanguageService;
|
private _languageService: jsonService.LanguageService;
|
||||||
private _languageSettings: jsonService.LanguageSettings;
|
private _languageSettings: DiagnosticsOptions;
|
||||||
private _languageId: string;
|
private _languageId: string;
|
||||||
|
|
||||||
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
|
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
|
||||||
|
|
@ -40,7 +41,7 @@ export class JSONWorker {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
if (document) {
|
if (document) {
|
||||||
let jsonDocument = this._languageService.parseJSONDocument(document);
|
let jsonDocument = this._languageService.parseJSONDocument(document);
|
||||||
return this._languageService.doValidation(document, jsonDocument);
|
return this._languageService.doValidation(document, jsonDocument, this._languageSettings);
|
||||||
}
|
}
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +183,7 @@ function joinPath(uriString: string, ...paths: string[]): string {
|
||||||
|
|
||||||
export interface ICreateData {
|
export interface ICreateData {
|
||||||
languageId: string;
|
languageId: string;
|
||||||
languageSettings: jsonService.LanguageSettings;
|
languageSettings: DiagnosticsOptions;
|
||||||
enableSchemaRequest: boolean;
|
enableSchemaRequest: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,18 @@ export interface DiagnosticsOptions {
|
||||||
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||||
*/
|
*/
|
||||||
readonly enableSchemaRequest?: boolean;
|
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 {
|
export interface ModeConfiguration {
|
||||||
/**
|
/**
|
||||||
* Defines whether the built-in documentFormattingEdit provider is enabled.
|
* Defines whether the built-in documentFormattingEdit provider is enabled.
|
||||||
|
|
@ -148,7 +158,9 @@ const diagnosticDefault: Required<DiagnosticsOptions> = {
|
||||||
validate: true,
|
validate: true,
|
||||||
allowComments: true,
|
allowComments: true,
|
||||||
schemas: [],
|
schemas: [],
|
||||||
enableSchemaRequest: false
|
enableSchemaRequest: false,
|
||||||
|
schemaRequest: 'warning',
|
||||||
|
schemaValidation: 'warning'
|
||||||
};
|
};
|
||||||
|
|
||||||
const modeConfigurationDefault: Required<ModeConfiguration> = {
|
const modeConfigurationDefault: Required<ModeConfiguration> = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue