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

Method extractComponent

src/extraction/cfml-extractor.ts:234–287  ·  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

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