codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

CFML: calls in tag-based code (<cfset>, <cfif>, <cfreturn>, …) are not extracted; functions inside <cfprocessingdirective> / <cfinterface> are missed

Open HarryMuc opened this issue 2 months ago • 0 comments

Summary

On a large tag-based CFML codebase (~6,000 .cfc/.cfm files, 95% of the components tag-based), symbol extraction works well (99.5% of <cffunction>s are indexed), but call edges are almost entirely missing: only 6.4% of the 38k CFML methods have any caller in the graph. As a result callers, impact and the blast radius in codegraph_explore aren't reliable for CFML.

Version: @colbymchenry/codegraph 1.6.1 (full re-index with codegraph index -f), Windows x64.

1. Calls outside <cfscript> / <cfquery> are dropped (main issue)

CfmlExtractor sends only <cfscript> bodies and <cfquery> #hash# expressions through call extraction. In tag-based code most calls live in other tags, and tree-sitter-cfml already parses them into normal call_expression nodes:

<cfcomponent>
	<cffunction name="a">
		<cfset x = b(1)>
		<cfif c(2)></cfif>
		<cfreturn d()>
	</cffunction>
	<cffunction name="b"></cffunction>
	<cffunction name="c"></cffunction>
	<cffunction name="d"></cffunction>
</cfcomponent>

AST (bundled tree-sitter-cfml.wasm):

(cf_function_tag …
  (cf_set_tag (assignment_expression left: (identifier) right: (call_expression function: (identifier) arguments: (arguments (number)))))
  (cf_if_tag (call_expression …))
  (cf_return_tag (call_expression …)))

Expected: a → b, a → c, a → d call edges. Actual: none. codegraph callers b → 0.

Real-world example: one method calls 8 project methods (same-component calls like generateShortlinks(...), inherited ones like getLogger(), and member calls like oQueryfct.tablediff(...), all inside <cfset>). The graph has exactly 1 edge, the one call that sits inside a <cfquery> #…#.

Suggestion: inside a cf_function_tag (and at component/template scope), run the same call/reference extraction used for cfscript over every expression node the cfml grammar produces: at least cf_set_tag, cf_if_tag / cf_elseif_tag, cf_return_tag, and hash_expression (e.g. in cf_output_tag). Tag attributes whose value is an expression string (e.g. <cfloop condition="c()">) come through as plain attribute_value, so they're a nice-to-have.

2. <cffunction> inside <cfprocessingdirective> is not extracted

<cfcomponent>
	<cfprocessingdirective suppresswhitespace="true">
		<cffunction name="onRequestStart"></cffunction>
	</cfprocessingdirective>
</cfcomponent>

The grammar parses this as a generic cf_tag with the cf_function_tag nested inside. The extractor only looks at the component's direct following siblings, so the component ends up with 0 methods. The pattern is common in Application.cfc.

Suggestion: descend into generic cf_tag containers (like delegateNestedTags already does for <cfscript>/<cfquery>) when looking for cf_function_tag.

3. <cfinterface> is not supported

<cfinterface>
	<cffunction name="search" access="public"></cffunction>
</cfinterface>

This parses as a generic cf_tag (cf_tag_name = cfinterface) and produces neither an interface/class node nor any methods. Expected: an interface node with its method signatures, plus implements edges from <cfcomponent implements="…">.

Numbers (before/after the 1.4.1 → 1.6.1 upgrade, unchanged)

metric value
CFML files 5,962
<cffunction>/function found vs. regex ground truth 38,188 / 38,376 (99.5%)
CFML methods with ≥1 incoming calls edge 2,463 / 38,207 (6.4%)
tag-based vs script-based .cfc 2,381 / 124

Happy to test a pre-release against this codebase.

HarryMuc avatar Sep 29 '26 10:09 HarryMuc