Skip to content

Commit

Permalink
Refactor EnumSchemaNode to improve handling of "Any" type
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 22, 2024
1 parent e2b0394 commit 4f69902
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/gx-workflow-ls-format2/src/schema/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ export class EnumSchemaNode implements SchemaNode {
return false;
}

public get canBeAny(): boolean {
return this.name === "Any";
}

public get typeRef(): string {
return this._schemaEnum.name;
}

public matchesType(typeName: string): boolean {
return this.name === "Any" || this.symbols.includes(typeName);
return this.canBeAny || this.symbols.includes(typeName);
}

//Override toString for debugging purposes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class GxFormat2CompletionService {
const position = textBuffer.getPosition(offset);
const isPositionAfterColon = textBuffer.isPositionAfterToken(position, ":");
if (schemaNode instanceof EnumSchemaNode) {
if (schemaNode.canBeAny) return result;

schemaNode.symbols
.filter((v) => v.startsWith(currentWord))
.forEach((value) => {
Expand Down

0 comments on commit 4f69902

Please sign in to comment.