Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 2 additions & 5 deletions src/completion-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '()'
});
}
}
Expand All @@ -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 + '()'
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()');
});
Expand Down