MCPcopy Index your code
hub / github.com/thesysdev/openui / classifyStatement

Function classifyStatement

packages/lang-core/src/parser/parser.ts:56–83  ·  view source on GitHub ↗

* Classify a raw statement + parsed expression into a typed Statement. * Determined at parse time from token type + expression shape.

(raw: RawStmt, expr: ASTNode)

Source from the content-addressed store, hash-verified

54 * Determined at parse time from token type + expression shape.
55 */
56function classifyStatement(raw: RawStmt, expr: ASTNode): Statement {
57 // Query(...) → query declaration — check BEFORE $var to handle `$foo = Query(...)` correctly
58 if (expr.k === "Comp" && expr.name === RESERVED_CALLS.Query) {
59 const deps = collectQueryDeps(expr.args[1]);
60 return {
61 kind: "query",
62 id: raw.id,
63 call: { callee: RESERVED_CALLS.Query, args: expr.args },
64 expr,
65 deps: deps.length > 0 ? deps : undefined,
66 };
67 }
68 // Mutation(...) → mutation declaration
69 if (expr.k === "Comp" && expr.name === RESERVED_CALLS.Mutation) {
70 return {
71 kind: "mutation",
72 id: raw.id,
73 call: { callee: RESERVED_CALLS.Mutation, args: expr.args },
74 expr,
75 };
76 }
77 // $variables → state declaration
78 if (raw.idTokenType === T.StateVar) {
79 return { kind: "state", id: raw.id, init: expr };
80 }
81 // Everything else → value declaration
82 return { kind: "value", id: raw.id, expr };
83}
84
85/**
86 * Extract typed statements from the symbol table.

Callers 3

parseFunction · 0.85
addStmtFunction · 0.85
currentResultFunction · 0.85

Calls 1

collectQueryDepsFunction · 0.85

Tested by

no test coverage detected