codegraph icon indicating copy to clipboard operation
codegraph copied to clipboard

CFML: tag `<cfinclude template="…">` creates no edge; included functions are not attached to the component (mixins)

Open HarryMuc opened this issue 1 month ago • 1 comments

Summary

Script-style include "x.cfm"; produces an imports edge. The tag form does not.

Our project has 246 <cfinclude template="…"> with a literal path, and none of them appears in the graph. All 9 imports edges in the index come from script includes.

Example

<!--- contens/core/baseform.cfc --->
<cfcomponent output="false">
	...
	<!--- shared parts of forms, lists and exports --->
	<cfinclude template="formlistshared.cfm">
</cfcomponent>
  • formlistshared.cfm is indexed, and its functions (checkRightsPartPrepare, checkRightsPartRecords, …) appear as top-level function nodes.
  • There is no edge from baseform.cfc to formlistshared.cfm.
  • The functions are not members of baseform or its subclasses.

A component-level include is the common CFML mixin pattern: the included functions become methods of the including component and of every component that extends it.

Path styles seen (all literal)

Style Count
relative to the current file (../x/y.cfm) 128
same directory (formlistshared.cfm) 67
mapping-rooted (/contenscms/..., depends on mapping support, see the dotted extends issue) 46

Expected

  1. An imports (or includes) edge for <cfinclude template="…">, the same as for the script form.
  2. When the include sits at component level (outside <cffunction>), the included file's functions count as members of the component. Calls such as this.checkRightsPartPrepare() or unqualified calls in subclasses then resolve.

HarryMuc avatar Oct 19 '26 09:10 HarryMuc

Thanks for the report!

#2838 is merged to main and covers the first part. <cfinclude template="…"> now links the component, function or template it sits in to the file it includes, as the script include already did. So do cfinclude(template="…"), include template="…"; and an include inside a function. Relative paths like ../shared/helpers.cfm resolve against the including file, so they find the right file even when another file has the same name. That ships in the next release.

Treating a component-level include's functions as members of the component and its subclasses (the mixin part) is a bigger change. We're leaving this issue open for it as a feature request. Mapping-rooted paths (/contenscms/…) depend on the mapping option discussed in #2650.

colbymchenry avatar Oct 23 '26 09:10 colbymchenry