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

Method extractComponent

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

174 * cf_component_close_tag.
175 */
176 private extractComponent(openTag: SyntaxNode, containerId: string | undefined): SyntaxNode {
177 const name = this.tagAttr(openTag, 'name') ?? this.componentNameFromPath();
178 const id = this.nodeIds.generate(this.filePath, 'class', name, openTag.startPosition.row + 1, openTag.startPosition.column);
179
180 const classNode: Node = {
181 id,
182 kind: 'class',
183 name,
184 qualifiedName: `${this.filePath}::${name}`,
185 filePath: this.filePath,
186 language: this.language,
187 startLine: openTag.startPosition.row + 1,
188 endLine: openTag.startPosition.row + 1, // extended below once the close tag is found
189 startColumn: openTag.startPosition.column,
190 endColumn: openTag.endPosition.column,
191 isExported: true,
192 updatedAt: Date.now(),
193 };
194 this.nodes.push(classNode);
195 if (containerId) {
196 this.edges.push({ source: containerId, target: classNode.id, kind: 'contains' });
197 }
198
199 const extendsName = this.tagAttr(openTag, 'extends');
200 if (extendsName) {
201 this.unresolvedReferences.push({
202 fromNodeId: classNode.id,
203 referenceName: extendsName,
204 referenceKind: 'extends',
205 filePath: this.filePath,
206 line: openTag.startPosition.row + 1,
207 column: openTag.startPosition.column,
208 language: this.language,
209 });
210 }
211 const implementsAttr = this.tagAttr(openTag, 'implements');
212 if (implementsAttr) {
213 for (const iface of implementsAttr.split(',').map((s) => s.trim()).filter(Boolean)) {
214 this.unresolvedReferences.push({
215 fromNodeId: classNode.id,
216 referenceName: iface,
217 referenceKind: 'implements',
218 filePath: this.filePath,
219 line: openTag.startPosition.row + 1,
220 column: openTag.startPosition.column,
221 language: this.language,
222 });
223 }
224 }
225
226 // Walk siblings between the open tag and its close tag.
227 let sibling = openTag.nextSibling;
228 let lastNode: SyntaxNode = openTag;
229 while (sibling) {
230 if (sibling.type === 'cf_component_close_tag') {
231 lastNode = sibling;
232 break;
233 }

Callers 1

walkProgramMethod · 0.95

Calls 9

tagAttrMethod · 0.95
componentNameFromPathMethod · 0.95
extractFunctionTagMethod · 0.95
delegateScriptTagMethod · 0.95
delegateQueryTagMethod · 0.95
delegateNestedTagsMethod · 0.95
pushMethod · 0.80
mapMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected