Skip to content

Commit

Permalink
resolved default dialect to upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
diyaayay committed Mar 12, 2024
2 parents d6e59ce + a9f4c1a commit 0adf264
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 85 deletions.
6 changes: 4 additions & 2 deletions language-server/src/jsonc-instance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseTree } from "jsonc-parser/lib/esm/main.js";
import { parseTree } from "jsonc-parser";
import * as JsonPointer from "@hyperjump/json-pointer";
import { getKeywordId } from "@hyperjump/json-schema/experimental";
import { drop, find, head, some } from "@hyperjump/pact";
Expand Down Expand Up @@ -29,7 +29,9 @@ export class JsoncInstance {
}

value() {
if (this.node.value === undefined) {
if (this.node === undefined) {
return undefined;
} else if (this.node.value === undefined) {
const json = this.textDocument.getText().slice(this.node.offset, this.node.offset + this.node.length);
return JSON.parse(json);
} else {
Expand Down
6 changes: 4 additions & 2 deletions language-server/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ connection.onInitialize(({ capabilities, workspaceFolders }) => {
hasConfigurationCapability = !!(
capabilities.workspace && !!capabilities.workspace.configuration
);
connection.console.log(hasConfigurationCapability);

if (workspaceFolders) {
addWorkspaceFolders(workspaceFolders);
Expand Down Expand Up @@ -117,6 +118,8 @@ connection.onInitialized(async () => {

const documentSettings = new Map(); // Consider a Map for cache
let globalSettings = {
enableDetailedErrors: false,
schemaValidationSeverity: "error",
defaultDialect: "http://json-schema.org/draft-07/schema#"
}; // Sensible defaults

Expand Down Expand Up @@ -178,11 +181,10 @@ const validateSchema = async (document) => {
const diagnostics = [];
const settings = await getDocumentSettings(document.uri);
connection.console.log(JSON.stringify(settings));
let instance;
let contextDialectUri;
let dialectUri;
const instance = JsoncInstance.fromTextDocument(document);
try {
instance = JsoncInstance.fromTextDocument(document);
const $schema = instance.get("#/$schema");
// Determine the context dialect URI from the document
contextDialectUri = $schema?.value();
Expand Down
4 changes: 0 additions & 4 deletions language-server/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export const workspaceSchemas = async function* () {
const path = fileURLToPath(uri);

for (const filename of await readdir(path, { recursive: true })) {
if (!filename.endsWith(".schema.json")) {
continue;
}

const schemaPath = resolve(path, filename);

yield pathToFileURL(schemaPath).toString();
Expand Down
128 changes: 64 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"vscode:prepublish": "npm run build-client -- --minify && npm run build-server -- --minify",
"build": "npm run build-client -- --sourcemap && npm run build-server -- --sourcemap",
"build-client": "esbuild ./src/extension.js --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"build-server": "esbuild ../language-server/src/server.js --bundle --outfile=out/server.js --external:vscode --format=cjs --platform=node",
"build-server": "esbuild ../language-server/src/server.js --bundle --main-fields=module,main --outfile=out/server.js --external:vscode --format=cjs --platform=node",
"package": "vsce package --out=dist",
"publish": "vsce publish"
},
Expand Down

0 comments on commit 0adf264

Please sign in to comment.