Skip to content

Commit

Permalink
Provide access to resolved schema from service
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jan 27, 2024
1 parent 3521fbc commit 0f1e662
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { DocumentContext } from "@gxwf/server-common/src/languageTypes";
import { inject, injectable } from "inversify";
import { Diagnostic, DiagnosticSeverity } from "vscode-languageserver-types";
import { TYPES } from "../types";
import { IApplicableSchema, JSONSchemaService } from "./adapter";
import { ResolvedSchema } from "./jsonSchema";
import { WorkflowTestsSchemaProvider } from "./provider";
import { TYPES } from "../types";
import { DocumentContext } from "@gxwf/server-common/src/languageTypes";
import { DiagnosticSeverity, Diagnostic } from "vscode-languageserver-types";

export interface WorkflowTestsSchemaService {
schema: ResolvedSchema;
validate(documentContext: DocumentContext, severity?: DiagnosticSeverity): Diagnostic[] | undefined;
getMatchingSchemas(documentContext: DocumentContext, nodeOffset?: number | undefined): IApplicableSchema[];
}
Expand All @@ -16,10 +18,16 @@ export class WorkflowTestsSchemaServiceImpl implements WorkflowTestsSchemaServic
@inject(TYPES.WorkflowTestsSchemaProvider) protected schemaProvider: WorkflowTestsSchemaProvider,
@inject(TYPES.JSONSchemaService) protected jsonSchemaService: JSONSchemaService
) {}

get schema(): ResolvedSchema {
return this.schemaProvider.getResolvedSchema();
}

validate(documentContext: DocumentContext, severity?: DiagnosticSeverity): Diagnostic[] | undefined {
const resolvedSchema = this.schemaProvider.getResolvedSchema();
return this.jsonSchemaService.validate(documentContext, resolvedSchema.schema, severity);
}

getMatchingSchemas(documentContext: DocumentContext, nodeOffset?: number | undefined): IApplicableSchema[] {
const resolvedSchema = this.schemaProvider.getResolvedSchema();
return this.jsonSchemaService.getMatchingSchemas(documentContext, resolvedSchema.schema, nodeOffset);
Expand Down

0 comments on commit 0f1e662

Please sign in to comment.