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

Method visitTag

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

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