From 1f04d2a5de320f7ebb51d4d3958e2eaa21ea3dc8 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 22 Jun 2024 11:57:00 +0200 Subject: [PATCH 1/2] Refactor completionService to ignore certain schema references --- .../src/services/completionService.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/gx-workflow-ls-format2/src/services/completionService.ts b/server/gx-workflow-ls-format2/src/services/completionService.ts index dbe1a79..feb374a 100644 --- a/server/gx-workflow-ls-format2/src/services/completionService.ts +++ b/server/gx-workflow-ls-format2/src/services/completionService.ts @@ -6,6 +6,12 @@ import { FieldSchemaNode, RecordSchemaNode, SchemaNode, SchemaNodeResolver } fro import { EnumSchemaNode } from "../schema/definitions"; export class GxFormat2CompletionService { + /** + * Schema references that should be ignored when suggesting completions. + * These are typically user-defined names and we cannot suggest completions for them. + */ + private readonly ignoredSchemaRefs = new Set(["InputParameter", "OutputParameter", "WorkflowStep"]); + constructor(protected readonly schemaNodeResolver: SchemaNodeResolver) {} public doComplete(documentContext: GxFormat2WorkflowDocument, position: Position): Promise { @@ -111,6 +117,10 @@ export class GxFormat2CompletionService { return result; } + if (this.ignoredSchemaRefs.has(schemaNode.typeRef)) { + return result; + } + const schemaRecord = this.schemaNodeResolver.getSchemaNodeByTypeRef(schemaNode.typeRef); if (schemaRecord) { return this.getProposedItems(schemaRecord, textBuffer, exclude, offset); From ccc886c55bbd6cdafd094892e5f3c056620eb212 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 22 Jun 2024 11:57:50 +0200 Subject: [PATCH 2/2] Add test coverage for inputs, outputs, and steps suggestions --- .../tests/integration/completion.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server/gx-workflow-ls-format2/tests/integration/completion.test.ts b/server/gx-workflow-ls-format2/tests/integration/completion.test.ts index 2174957..e1c8e81 100644 --- a/server/gx-workflow-ls-format2/tests/integration/completion.test.ts +++ b/server/gx-workflow-ls-format2/tests/integration/completion.test.ts @@ -110,6 +110,45 @@ in$ expect(completions?.items[0].label).toBe("inputs"); }); + it("should not suggest any properties when defining new workflow inputs", async () => { + const template = ` +class: GalaxyWorkflow +inputs: + $ +`; + const { contents, position } = parseTemplate(template); + + const completions = await getCompletions(contents, position); + + expect(completions?.items.length).toBe(0); + }); + + it("should not suggest any properties when defining new workflow outputs", async () => { + const template = ` +class: GalaxyWorkflow +outputs: + $ +`; + const { contents, position } = parseTemplate(template); + + const completions = await getCompletions(contents, position); + + expect(completions?.items.length).toBe(0); + }); + + it("should not suggest any properties when defining new workflow steps", async () => { + const template = ` +class: GalaxyWorkflow +steps: + $ +`; + const { contents, position } = parseTemplate(template); + + const completions = await getCompletions(contents, position); + + expect(completions?.items.length).toBe(0); + }); + it("should not suggest property completions inlined with the definition", async () => { const template = ` class: GalaxyWorkflow