diff --git a/server/packages/workflow-tests-language-service/src/inversify.config.ts b/server/packages/workflow-tests-language-service/src/inversify.config.ts index 3267f23..b7e58eb 100644 --- a/server/packages/workflow-tests-language-service/src/inversify.config.ts +++ b/server/packages/workflow-tests-language-service/src/inversify.config.ts @@ -1,25 +1,35 @@ +import { TYPES as COMMON_TYPES, WorkflowTestsLanguageService } from "@gxwf/server-common/src/languageTypes"; import { ContainerModule } from "inversify"; import { GxWorkflowTestsLanguageServiceImpl } from "./languageService"; -import { TYPES as COMMON_TYPES, WorkflowTestsLanguageService } from "@gxwf/server-common/src/languageTypes"; -import { WorkflowTestsHoverService, WorkflowTestsHoverServiceImpl } from "./services/hover"; -import { TYPES } from "./types"; -import { WorkflowTestsSchemaProvider, WorkflowTestsSchemaProviderImpl } from "./schema/provider"; import { JSONSchemaService, JSONSchemaServiceImpl } from "./schema/adapter"; +import { WorkflowTestsSchemaProvider, WorkflowTestsSchemaProviderImpl } from "./schema/provider"; import { WorkflowTestsSchemaService, WorkflowTestsSchemaServiceImpl } from "./schema/service"; +import { WorkflowTestsCompletionService, WorkflowTestsCompletionServiceImpl } from "./services/completion"; +import { WorkflowTestsHoverService, WorkflowTestsHoverServiceImpl } from "./services/hover"; import { WorkflowTestsValidationService, WorkflowTestsValidationServiceImpl } from "./services/validation"; +import { TYPES } from "./types"; export const WorkflowTestsLanguageServiceContainerModule = new ContainerModule((bind) => { bind(TYPES.WorkflowTestsSchemaProvider) .to(WorkflowTestsSchemaProviderImpl) .inSingletonScope(); + bind(TYPES.JSONSchemaService).to(JSONSchemaServiceImpl).inSingletonScope(); + bind(TYPES.WorkflowTestsSchemaService) .to(WorkflowTestsSchemaServiceImpl) .inSingletonScope(); + bind(TYPES.WorkflowTestsHoverService).to(WorkflowTestsHoverServiceImpl).inSingletonScope(); + + bind(TYPES.WorkflowTestsCompletionService) + .to(WorkflowTestsCompletionServiceImpl) + .inSingletonScope(); + bind(TYPES.WorkflowTestsValidationService) .to(WorkflowTestsValidationServiceImpl) .inSingletonScope(); + bind(COMMON_TYPES.WorkflowTestsLanguageService) .to(GxWorkflowTestsLanguageServiceImpl) .inSingletonScope(); diff --git a/server/packages/workflow-tests-language-service/src/languageService.ts b/server/packages/workflow-tests-language-service/src/languageService.ts index 751aa8f..c3a2133 100644 --- a/server/packages/workflow-tests-language-service/src/languageService.ts +++ b/server/packages/workflow-tests-language-service/src/languageService.ts @@ -1,34 +1,37 @@ import { - TextDocument, - Range, + CompletionList, + Diagnostic, FormattingOptions, - TextEdit, + Hover, LanguageServiceBase, Position, - Hover, - CompletionList, - Diagnostic, + Range, + TextDocument, + TextEdit, WorkflowTestsDocument, } from "@gxwf/server-common/src/languageTypes"; +import { TYPES as YAML_TYPES } from "@gxwf/yaml-language-service/src/inversify.config"; import { YAMLLanguageService } from "@gxwf/yaml-language-service/src/yamlLanguageService"; -import { GxWorkflowTestsDocument } from "./document"; import { inject, injectable } from "inversify"; -import { TYPES as YAML_TYPES } from "@gxwf/yaml-language-service/src/inversify.config"; +import { GxWorkflowTestsDocument } from "./document"; +import { WorkflowTestsCompletionService } from "./services/completion"; import { WorkflowTestsHoverService } from "./services/hover"; -import { TYPES } from "./types"; import { WorkflowTestsValidationService } from "./services/validation"; +import { TYPES } from "./types"; const LANGUAGE_ID = "gxwftests"; /** * A custom implementation of the YAML Language Service to support language features * for Galaxy workflow test files. + * It combines specific services to implement the language features. */ @injectable() export class GxWorkflowTestsLanguageServiceImpl extends LanguageServiceBase { constructor( @inject(YAML_TYPES.YAMLLanguageService) protected yamlLanguageService: YAMLLanguageService, @inject(TYPES.WorkflowTestsHoverService) protected hoverService: WorkflowTestsHoverService, + @inject(TYPES.WorkflowTestsCompletionService) protected completionService: WorkflowTestsCompletionService, @inject(TYPES.WorkflowTestsValidationService) protected validationService: WorkflowTestsValidationService ) { super(LANGUAGE_ID); @@ -51,8 +54,7 @@ export class GxWorkflowTestsLanguageServiceImpl extends LanguageServiceBase { - // TODO: Implement completion - return Promise.resolve(null); + return this.completionService.doComplete(documentContext, position); } protected override async doValidation(documentContext: WorkflowTestsDocument): Promise { diff --git a/server/packages/workflow-tests-language-service/src/services/completion/completion.ts b/server/packages/workflow-tests-language-service/src/services/completion/completion.ts new file mode 100644 index 0000000..63fff19 --- /dev/null +++ b/server/packages/workflow-tests-language-service/src/services/completion/completion.ts @@ -0,0 +1,22 @@ +import { CompletionList, DocumentContext, Position } from "@gxwf/server-common/src/languageTypes"; +import { inject, injectable } from "inversify"; +import { WorkflowTestsSchemaService } from "../../schema/service"; +import { TYPES } from "../../types"; + +export interface WorkflowTestsCompletionService { + doComplete(documentContext: DocumentContext, position: Position): Promise; +} + +/** + * Simple wrapper around the YAMLCompletionHelper to combine it with custom completion logic. + */ +@injectable() +export class WorkflowTestsCompletionServiceImpl implements WorkflowTestsCompletionService { + constructor(@inject(TYPES.WorkflowTestsSchemaService) protected schemaService: WorkflowTestsSchemaService) {} + + public async doComplete(documentContext: DocumentContext, position: Position): Promise { + // TODO: Add custom completion logic specific to workflow test files here + const result = null; + return result; + } +} diff --git a/server/packages/workflow-tests-language-service/src/services/completion/index.ts b/server/packages/workflow-tests-language-service/src/services/completion/index.ts new file mode 100644 index 0000000..f12a8a1 --- /dev/null +++ b/server/packages/workflow-tests-language-service/src/services/completion/index.ts @@ -0,0 +1,3 @@ +import { WorkflowTestsCompletionService, WorkflowTestsCompletionServiceImpl } from "./completion"; + +export { WorkflowTestsCompletionService, WorkflowTestsCompletionServiceImpl }; diff --git a/server/packages/workflow-tests-language-service/src/types.ts b/server/packages/workflow-tests-language-service/src/types.ts index b5536cf..53efaf6 100644 --- a/server/packages/workflow-tests-language-service/src/types.ts +++ b/server/packages/workflow-tests-language-service/src/types.ts @@ -3,5 +3,6 @@ export const TYPES = { WorkflowTestsSchemaProvider: Symbol.for("WorkflowTestsSchemaProvider"), WorkflowTestsSchemaService: Symbol.for("WorkflowTestsSchemaService"), WorkflowTestsHoverService: Symbol.for("WorkflowTestsHoverService"), + WorkflowTestsCompletionService: Symbol.for("WorkflowTestsCompletionService"), WorkflowTestsValidationService: Symbol.for("WorkflowTestsValidationService"), };