Skip to content

Commit

Permalink
Merge branch 'main' into define-config-for-JSON-schema-files
Browse files Browse the repository at this point in the history
  • Loading branch information
diyaayay committed May 20, 2024
2 parents c266452 + 35a1a35 commit a2e5ea8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion language-server/src/features/document-settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DidChangeConfigurationNotification } from "vscode-languageserver";
import { publish } from "../pubsub.js";
import { clearSchemaDocuments } from "./schema-documents.js";


export let schemaFilePatterns = ["**/*.schema.json", "**/schema.json"];
Expand All @@ -23,12 +24,13 @@ export default {
connection.onDidChangeConfiguration((change) => {
if (hasConfigurationCapability) {
documentSettings.clear();
clearSchemaDocuments();
} else {
globalSettings = change.settings.jsonSchemaLanguageServer ?? globalSettings;
}
schemaFilePatterns = globalSettings.schemaFilePatterns ?? defaultFilePatterns;

publish("workspaceChange", { changes: [] });
publish("workspaceChanged", { changes: [] });
});

documents.onDidClose(({ document }) => {
Expand Down
2 changes: 2 additions & 0 deletions language-server/src/features/schema-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export const getSchemaDocument = async (connection, textDocument) => {

return schemaDocument;
};

export const clearSchemaDocuments = () => schemaDocuments.clear();
12 changes: 6 additions & 6 deletions language-server/src/features/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TextDocumentSyncKind
} from "vscode-languageserver";
import { TextDocument } from "vscode-languageserver-textdocument";
import { publishAsync } from "../pubsub.js";
import { publish, publishAsync, subscribe } from "../pubsub.js";
import { getSchemaDocument } from "./schema-documents.js";
import { getDocumentSettings } from "./document-settings.js";
import picomatch from "picomatch";
Expand Down Expand Up @@ -60,7 +60,7 @@ export default {
// eventType === "rename" means file added or deleted (on most platforms?)
// eventType === "change" means file saved
// filename is not always available (when is it not available?)
validateWorkspace({
publish("workspaceChanged", {
changes: [
{
uri: filename,
Expand All @@ -70,7 +70,7 @@ export default {
});
};

const validateWorkspace = async (_changes) => {
subscribe("workspaceChanged", async (_message, _changes) => {
const reporter = await connection.window.createWorkDoneProgress();
reporter.begin("JSON Schema: Indexing workspace");

Expand All @@ -88,7 +88,7 @@ export default {
}

reporter.done();
};
});

const validateSchema = async (textDocument) => {
connection.console.log(`Schema Validation: ${textDocument.uri}`);
Expand Down Expand Up @@ -138,7 +138,7 @@ export default {
watchWorkspace(onWorkspaceChange, isMatchedFile);
}

validateWorkspace({ changes: [] });
publish("workspaceChanged", { changes: [] });
});
}

Expand All @@ -152,7 +152,7 @@ export default {
}
});

validateWorkspace({ changes: [] });
publish("workspaceChanged", { changes: [] });
}
};

Expand Down

0 comments on commit a2e5ea8

Please sign in to comment.