From 635a35d91073218b4ef00d1a8d67630c68a0d38d Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 1 Jun 2024 19:15:28 +0200 Subject: [PATCH] Add default value completion for primitive types in format2 workflows --- .../src/services/completionService.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/gx-workflow-ls-format2/src/services/completionService.ts b/server/gx-workflow-ls-format2/src/services/completionService.ts index 78c1ec8..25429a3 100644 --- a/server/gx-workflow-ls-format2/src/services/completionService.ts +++ b/server/gx-workflow-ls-format2/src/services/completionService.ts @@ -64,6 +64,23 @@ export class GxFormat2CompletionService { result.push(item); }); } else if (schemaNode instanceof FieldSchemaNode) { + if (this.schemaNodeResolver.definitions.primitiveTypes.has(schemaNode.typeRef)) { + const defaultValue = String(schemaNode.default ?? ""); + if (defaultValue) { + const item: CompletionItem = { + label: defaultValue, + kind: CompletionItemKind.Value, + documentation: schemaNode.documentation, + insertText: defaultValue, + textEdit: { + range: overwriteRange, + newText: defaultValue, + }, + }; + result.push(item); + return result; + } + } const schemaRecord = this.schemaNodeResolver.getSchemaNodeByTypeRef(schemaNode.typeRef); if (schemaRecord instanceof EnumSchemaNode) { schemaRecord.symbols