Skip to content

Commit

Permalink
Add wf tests completion service (no-op for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jan 28, 2024
1 parent 0f1e662 commit 26c38ef
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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<WorkflowTestsSchemaProvider>(TYPES.WorkflowTestsSchemaProvider)
.to(WorkflowTestsSchemaProviderImpl)
.inSingletonScope();

bind<JSONSchemaService>(TYPES.JSONSchemaService).to(JSONSchemaServiceImpl).inSingletonScope();

bind<WorkflowTestsSchemaService>(TYPES.WorkflowTestsSchemaService)
.to(WorkflowTestsSchemaServiceImpl)
.inSingletonScope();

bind<WorkflowTestsHoverService>(TYPES.WorkflowTestsHoverService).to(WorkflowTestsHoverServiceImpl).inSingletonScope();

bind<WorkflowTestsCompletionService>(TYPES.WorkflowTestsCompletionService)
.to(WorkflowTestsCompletionServiceImpl)
.inSingletonScope();

bind<WorkflowTestsValidationService>(TYPES.WorkflowTestsValidationService)
.to(WorkflowTestsValidationServiceImpl)
.inSingletonScope();

bind<WorkflowTestsLanguageService>(COMMON_TYPES.WorkflowTestsLanguageService)
.to(GxWorkflowTestsLanguageServiceImpl)
.inSingletonScope();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<WorkflowTestsDocument> {
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);
Expand All @@ -51,8 +54,7 @@ export class GxWorkflowTestsLanguageServiceImpl extends LanguageServiceBase<Work
documentContext: WorkflowTestsDocument,
position: Position
): Promise<CompletionList | null> {
// TODO: Implement completion
return Promise.resolve(null);
return this.completionService.doComplete(documentContext, position);
}

protected override async doValidation(documentContext: WorkflowTestsDocument): Promise<Diagnostic[]> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CompletionList | null>;
}

/**
* 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<CompletionList | null> {

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'documentContext' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'position' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'documentContext' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'position' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'documentContext' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'position' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'documentContext' is defined but never used

Check warning on line 17 in server/packages/workflow-tests-language-service/src/services/completion/completion.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'position' is defined but never used
// TODO: Add custom completion logic specific to workflow test files here
const result = null;
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { WorkflowTestsCompletionService, WorkflowTestsCompletionServiceImpl } from "./completion";

export { WorkflowTestsCompletionService, WorkflowTestsCompletionServiceImpl };
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
};

0 comments on commit 26c38ef

Please sign in to comment.