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