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

Method visitTag

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

* Visit one node of tag markup. `containerId` is the scope the node sits in * — the function whose body it is, else the component, else the file — and * owns whatever calls it makes. `declScope` is true outside function bodies * (component/interface/template scope), where a ` ` d

(node: SyntaxNode, parentType: string, containerId: string, parentClassName: string | undefined, declScope: boolean)

Source from the content-addressed store, hash-verified

408 * enough to tell the expression from the tag around it.
409 */
410 private visitTag(node: SyntaxNode, parentType: string, containerId: string, parentClassName: string | undefined, declScope: boolean): void {
411 switch (node.type) {
412 case 'cf_script_tag':
413 this.delegateScriptTag(node, containerId, parentClassName);
414 return;
415 case 'cf_query_tag':
416 // The SQL body is opaque to this grammar; the walk below only reaches
417 // the tag's attributes (`datasource="#dsn()#"`), never the body twice.
418 this.delegateQueryTag(node, containerId);
419 break;
420 case 'cf_function_tag':
421 if (declScope) this.extractFunctionTag(node, parentClassName ? containerId : undefined, containerId, parentClassName);
422 return;
423 case 'cf_selfclose_tag':
424 // `<cfinclude template="…">`, wherever it is written (#2651). Its
425 // attributes are still walked below for `#hash#` expressions.
426 if (this.selfCloseTagName(node) === 'include') this.extractIncludeTag(node, containerId);
427 break;
428 case 'cf_tag': {
429 const name = this.cfTagName(node);
430 if (name === 'interface' && declScope && !parentClassName) {
431 this.extractInterfaceTag(node, containerId);
432 return;
433 }
434 // `<cfloop condition="hasNext()">` — the one common tag attribute whose
435 // plain-text value is a CFML expression rather than a literal.
436 if (name === 'loop') {
437 const condition = this.tagAttrValueNode(this.cfStartTag(node) ?? node, 'condition');
438 if (condition) this.addTagExpression(condition, containerId);
439 }
440 break;
441 }
442 default:
443 if (TAG_EXPRESSION_PARENTS.has(parentType) && TAG_EXPRESSION_TYPES.has(node.type)) {
444 this.addTagExpression(node, containerId);
445 return;
446 }
447 }
448 this.delegateNestedTags(node, containerId, parentClassName, declScope && node.type !== 'ERROR');
449 }
450
451 /**
452 * Visit `node`'s children (see visitTag) — e.g. a `<cfscript>`/`<cfquery>`

Callers 3

walkProgramMethod · 0.95
extractComponentMethod · 0.95
delegateNestedTagsMethod · 0.95

Calls 12

delegateScriptTagMethod · 0.95
delegateQueryTagMethod · 0.95
extractFunctionTagMethod · 0.95
selfCloseTagNameMethod · 0.95
extractIncludeTagMethod · 0.95
cfTagNameMethod · 0.95
extractInterfaceTagMethod · 0.95
tagAttrValueNodeMethod · 0.95
cfStartTagMethod · 0.95
addTagExpressionMethod · 0.95
delegateNestedTagsMethod · 0.95
hasMethod · 0.80

Tested by

no test coverage detected