[json] add 'Clear schema cache' command. Fixes #138524

This commit is contained in:
Martin Aeschlimann
2021-12-06 16:56:12 +01:00
parent 1d4b413018
commit 95a9378519
6 changed files with 72 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ namespace VSCodeContentRequest {
}
namespace SchemaContentChangeNotification {
export const type: NotificationType<string> = new NotificationType('json/schemaContent');
export const type: NotificationType<string | string[]> = new NotificationType('json/schemaContent');
}
namespace ResultLimitReachedNotification {
@@ -264,8 +264,18 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
// A schema has changed
connection.onNotification(SchemaContentChangeNotification.type, uri => {
if (languageService.resetSchema(uri)) {
connection.onNotification(SchemaContentChangeNotification.type, uriOrUris => {
let needsRevalidation = false;
if (Array.isArray(uriOrUris)) {
for (const uri of uriOrUris) {
if (languageService.resetSchema(uri)) {
needsRevalidation = true;
}
}
} else {
needsRevalidation = languageService.resetSchema(uriOrUris);
}
if (needsRevalidation) {
for (const doc of documents.all()) {
triggerValidation(doc);
}