Skip to content

Commit 306fe40

Browse files
committed
refactor: update parameter handling and position comments in utils.ts for improved clarity
1 parent 3e1c361 commit 306fe40

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ValidationResult {
2525
code: number
2626
severity: "error" | "warning"
2727
nodeId?: NodeFunction["id"]
28-
parameterIndex?: number
28+
parameterIndex?: number | null
2929
}>;
3030
}
3131

@@ -142,7 +142,7 @@ export function generateFlowSourceCode(
142142
return isForInference ? `/* @pos ${nodeId} ${paramIdx} */ ({} as any)` : `/* @pos ${nodeId} ${paramIdx} */ undefined`;
143143
}).join(", ");
144144

145-
const funcName = `fn_${node.functionDefinition.identifier.replace(/::/g, '_')}`;
145+
const funcName = `/* @pos ${nodeId} null */ fn_${node.functionDefinition.identifier.replace(/::/g, '_')}`;
146146
const call = `${funcName}(${args})`;
147147
// Add position comment only for nested calls (when called from within an argument)
148148
if (parentNodeId !== undefined && parentParamIndex !== undefined) {
@@ -214,7 +214,7 @@ export function generateFlowSourceCode(
214214
const funcName = `fn_${node?.functionDefinition?.identifier?.replace(/::/g, '_')}`;
215215
const needsAnyCast = args.includes("undefined");
216216
const isReturnNode = node.functionDefinition.identifier === "std::control::return";
217-
let code = `${indent}${isReturnNode ? "return " : `const ${varName} = `}${funcName}(${args})${needsAnyCast ? "" : ""} ;\n`;
217+
let code = `${indent}${isReturnNode ? "return " : `const ${varName} = `}/* @pos ${nodeId} null */ ${funcName}(${args})${needsAnyCast ? "" : ""} ;\n`;
218218
if (node.nextNodeId) code += generateNodeCode(node.nextNodeId, indent);
219219
return code;
220220
};
@@ -229,7 +229,7 @@ export function generateFlowSourceCode(
229229
if (p?.value?.__typename === "NodeFunctionIdWrapper" && p.value.id) subTreeIds.add(p.value.id);
230230
}));
231231

232-
const flowCode = flow ? `const flow_${sanitizeId(flow.id ?? "")} = flow(${flow.settings?.nodes?.map((setting, index) => `/* @pos undefined ${index} */ ${stringify(setting?.value)}`).join(", ") ?? ""});` : ""
232+
const flowCode = flow ? `const flow_${sanitizeId(flow.id ?? "")} = /* @pos null null */ flow(${flow.settings?.nodes?.map((setting, index) => `/* @pos null ${index} */ ${stringify(setting?.value)}`).join(", ") ?? ""});` : ""
233233

234234
const executionCode = nodes
235235
.filter(n => n?.id && !nextNodeIds.has(n.id) && !subTreeIds.has(n.id))

0 commit comments

Comments
 (0)