MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / cfmlCreatedComponent

Function cfmlCreatedComponent

src/extraction/languages/cfscript.ts:68–89  ·  view source on GitHub ↗
(call: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

66 * (`createObject("java", …)`), and for a name built at runtime.
67 */
68export function cfmlCreatedComponent(call: SyntaxNode, source: string): string | null {
69 if (call.type !== 'call_expression') return null;
70 const fn = getChildByField(call, 'function');
71 if (fn?.type !== 'identifier' || getNodeText(fn, source).toLowerCase() !== 'createobject') return null;
72 const args = getChildByField(call, 'arguments')?.namedChildren ?? [];
73 let type: string | null | undefined;
74 let name: string | null | undefined;
75 if (args.length > 0 && args.every((a: SyntaxNode) => a.type === 'assignment_expression')) {
76 for (const arg of args) {
77 const key = getNodeText(getChildByField(arg, 'left') ?? arg, source).toLowerCase();
78 if (key === 'type') type = literalString(getChildByField(arg, 'right'), source);
79 else if (key === 'component') name = literalString(getChildByField(arg, 'right'), source);
80 }
81 } else if (args.length === 1) {
82 name = literalString(args[0], source);
83 } else if (args.length >= 2) {
84 type = literalString(args[0], source);
85 name = literalString(args[1], source);
86 }
87 if (type !== undefined && type?.toLowerCase() !== 'component') return null;
88 return name && COMPONENT_PATH.test(name) ? name : null;
89}
90
91/**
92 * The component an expression constructs, when the expression is a

Callers 2

extractCallMethod · 0.90
cfmlConstructedComponentFunction · 0.85

Calls 3

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
literalStringFunction · 0.85

Tested by

no test coverage detected