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

Method extractComponent

src/extraction/cfml-extractor.ts:233–286  ·  view source on GitHub ↗

* ` ... `. * The grammar's implicit-end-tag scanner means component body content * (cffunction tags, cfscript tags, etc.) appears as the open tag's FOLLOWING * siblings in `program`, not nested children — walk forward to the mat

(openTag: SyntaxNode, containerId: string | undefined)

Source from the content-addressed store, hash-verified

231 * cf_component_close_tag.
232 */
233 private extractComponent(openTag: SyntaxNode, containerId: string | undefined): SyntaxNode {
234 const name = this.tagAttr(openTag, 'name') ?? this.componentNameFromPath();
235 const id = this.nodeIds.generate(this.filePath, 'class', name, openTag.startPosition.row + 1, openTag.startPosition.column);
236
237 const classNode: Node = {
238 id,
239 kind: 'class',
240 name,
241 qualifiedName: `${this.filePath}::${name}`,
242 filePath: this.filePath,
243 language: this.language,
244 startLine: openTag.startPosition.row + 1,
245 endLine: openTag.startPosition.row + 1, // extended below once the close tag is found
246 startColumn: openTag.startPosition.column,
247 endColumn: openTag.endPosition.column,
248 isExported: true,
249 updatedAt: Date.now(),
250 };
251 this.nodes.push(classNode);
252 if (containerId) {
253 this.edges.push({ source: containerId, target: classNode.id, kind: 'contains' });
254 }
255
256 const extendsName = this.tagAttr(openTag, 'extends');
257 if (extendsName) {
258 this.unresolvedReferences.push({
259 fromNodeId: classNode.id,
260 referenceName: extendsName,
261 referenceKind: 'extends',
262 filePath: this.filePath,
263 line: openTag.startPosition.row + 1,
264 column: openTag.startPosition.column,
265 language: this.language,
266 });
267 }
268 this.pushInheritanceRefs(classNode.id, this.tagAttr(openTag, 'implements'), 'implements', openTag);
269
270 // Walk siblings between the open tag and its close tag.
271 let sibling = openTag.nextSibling;
272 let lastNode: SyntaxNode = openTag;
273 while (sibling) {
274 if (sibling.type === 'cf_component_close_tag') {
275 lastNode = sibling;
276 break;
277 }
278 // Component scope: cffunctions are its methods, pseudo-constructor
279 // code's calls (a component-level `<cfset init()>`) are the component's.
280 this.visitTag(sibling, openTag.parent?.type ?? '', classNode.id, classNode.name, true);
281 lastNode = sibling;
282 sibling = sibling.nextSibling;
283 }
284 classNode.endLine = lastNode.endPosition.row + 1;
285 return lastNode;
286 }
287
288 /**
289 * `<cfinterface extends="IBase,IOther">...</cfinterface>` (#2091). Unlike

Callers 1

walkProgramMethod · 0.95

Calls 6

tagAttrMethod · 0.95
componentNameFromPathMethod · 0.95
pushInheritanceRefsMethod · 0.95
visitTagMethod · 0.95
pushMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected