From 48be333c70048516e2b9a2bfe2074ddfd994991f Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Wed, 11 Feb 2026 13:46:58 +0300 Subject: [PATCH] functions without arguments still should include parentheses --- package.json | 2 +- src/completion-provider.ts | 7 ++----- .../completion-provider-builders.test.ts | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e477610..d8e15c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@atomic-ehr/fhirpath", - "version": "0.1.0", + "version": "0.1.1", "description": "A TypeScript implementation of FHIRPath", "type": "module", "main": "./dist/index.node.js", diff --git a/src/completion-provider.ts b/src/completion-provider.ts index 7cf99a6..177d26f 100644 --- a/src/completion-provider.ts +++ b/src/completion-provider.ts @@ -329,15 +329,13 @@ async function getIdentifierCompletions( const isApplicable = !typeBeforeCursor || await isFunctionApplicable(funcDef, typeBeforeCursor, modelProvider); if (isApplicable) { - // Determine if any signature takes parameters - const hasParams = funcDef.signatures?.some(sig => (sig.parameters?.length ?? 0) > 0) ?? false; const funcDescription = funcDef.description || `FHIRPath ${name} function`; completions.push({ label: name, kind: CompletionKind.Function, detail: funcDescription, - insertText: name + (hasParams ? '()' : '') + insertText: name + '()' }); } } @@ -352,12 +350,11 @@ async function getIdentifierCompletions( const typeFunctions = registry.getFunctionsForType(typeForRegistry); for (const func of typeFunctions) { if (!completions.some(c => c.label === func.name) && await isFunctionApplicable(func, typeBeforeCursor, modelProvider)) { - const hasParams = func.signatures?.some(sig => (sig.parameters?.length ?? 0) > 0) ?? false; completions.push({ label: func.name, kind: CompletionKind.Function, detail: func.description || `FHIRPath ${func.name} function`, - insertText: func.name + (hasParams ? '()' : '') + insertText: func.name + '()' }); } } diff --git a/test/completition-provider/completion-provider-builders.test.ts b/test/completition-provider/completion-provider-builders.test.ts index 3db63f7..7184d08 100644 --- a/test/completition-provider/completion-provider-builders.test.ts +++ b/test/completition-provider/completion-provider-builders.test.ts @@ -34,12 +34,10 @@ describe('CompletionProvider - builder consistency', () => { expect(byLabel.get('count')?.count ?? 0).toBe(1); expect(byLabel.get('where')?.count ?? 0).toBe(1); - // Refactor 2 expectation: insertText - // - no-arg function like count should not force parentheses in insertText + // All functions should include parentheses in insertText const countItem = byLabel.get('count')!.items[0]; - expect(countItem.insertText === 'count').toBe(true); + expect(countItem.insertText).toBe('count()'); - // - arg-taking function like where should include parentheses const whereItem = byLabel.get('where')!.items[0]; expect(whereItem.insertText).toBe('where()'); });