|
1 | 1 | import { DiagnosticSeverity } from "vscode-languageserver";
|
2 |
| -import { BASIC, compile, getSchema, hasDialect, hasVocabulary, interpret } from "@hyperjump/json-schema/experimental"; |
| 2 | +import { BASIC, compile, getSchema, hasDialect, hasVocabulary } from "@hyperjump/json-schema/experimental"; |
3 | 3 | import * as SchemaNode from "../model/schema-node.js";
|
4 | 4 | import { keywordNameFor } from "../util/util.js";
|
| 5 | +import { interpret, ValidationError } from "@hyperjump/json-schema/annotations/experimental"; |
5 | 6 |
|
6 | 7 | /**
|
7 | 8 | * @import { Server } from "../services/server.js";
|
@@ -93,18 +94,17 @@ export class ValidateSchemaFeature {
|
93 | 94 | try {
|
94 | 95 | const schema = await getSchema(schemaResource.dialectUri);
|
95 | 96 | const compiled = await compile(schema);
|
96 |
| - const output = interpret(compiled, schemaResource, BASIC); |
97 |
| - if (output.errors) { |
98 |
| - for (const error of output.errors) { |
| 97 | + interpret(compiled, schemaResource, BASIC); |
| 98 | + } catch (error) { |
| 99 | + if (error instanceof ValidationError) { |
| 100 | + for (const outputUnit of error.output.errors ?? []) { |
99 | 101 | schemaDocument.errors.push({
|
100 |
| - keyword: error.keyword, |
101 |
| - keywordNode: await getSchema(error.absoluteKeywordLocation), |
102 |
| - instanceNode: /** @type SchemaNodeType */ (this.#schemas.getSchemaNode(error.instanceLocation, schemaResource)) |
| 102 | + keyword: outputUnit.keyword, |
| 103 | + keywordNode: await getSchema(outputUnit.absoluteKeywordLocation), |
| 104 | + instanceNode: /** @type SchemaNodeType */ (this.#schemas.getSchemaNode(outputUnit.instanceLocation, schemaResource)) |
103 | 105 | });
|
104 | 106 | }
|
105 |
| - } |
106 |
| - } catch (error) { |
107 |
| - if (error instanceof Error) { |
| 107 | + } else if (error instanceof Error) { |
108 | 108 | schemaDocument.errors.push({
|
109 | 109 | keyword: "",
|
110 | 110 | instanceNode: schemaDocument.schemaResources[0],
|
|
0 commit comments