Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore auto-complete suggestions for some schema elements in Format2 #77

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions server/gx-workflow-ls-format2/src/services/completionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompletionList> {
Expand Down Expand Up @@ -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);
Expand Down
39 changes: 39 additions & 0 deletions server/gx-workflow-ls-format2/tests/integration/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down