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

Function cfmlCreatedComponent

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

Source from the content-addressed store, hash-verified

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