MCPcopy Create free account
hub / github.com/codemix/graph / isLegacyFunctionExpression

Function isLegacyFunctionExpression

packages/graph/src/astToSteps.ts:2537–2562  ·  view source on GitHub ↗

* Helper to check if an expression is a function call to labels() or type()

(
  item: import("./AST.js").ReturnItem,
)

Source from the content-addressed store, hash-verified

2535 * Helper to check if an expression is a function call to labels() or type()
2536 */
2537function isLegacyFunctionExpression(
2538 item: import("./AST.js").ReturnItem,
2539): { function: "labels" | "type"; variable: string } | null {
2540 if (item.function && item.variable) {
2541 return { function: item.function, variable: item.variable };
2542 }
2543 const expr = item.expression;
2544 if (expr && typeof expr === "object" && "type" in expr) {
2545 if (expr.type === "FunctionCall") {
2546 const funcCall = expr as FunctionCall;
2547 const name = funcCall.name.toLowerCase();
2548 if ((name === "labels" || name === "type") && funcCall.args.length === 1) {
2549 const arg = funcCall.args[0];
2550 if (arg && typeof arg === "object" && "type" in arg) {
2551 if (arg.type === "VariableRef") {
2552 return {
2553 function: name as "labels" | "type",
2554 variable: (arg as import("./AST.js").VariableRef).variable,
2555 };
2556 }
2557 }
2558 }
2559 }
2560 }
2561 return null;
2562}
2563
2564/**
2565 * Helper to check if an expression is a plain variable reference

Callers 1

convertReturnClauseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected