Search code examples
coldfusionmetaprogrammingcoldfusion-11

Get runtime ColdFusion syntax trees?


Is it possible to get access to / modify ColdFusion syntax trees at run time?

I'd wager not, and a 10 minute google search didn't find anything. Fiddling with closures and writing metadata dumps, we can see stringified versions of objects like [runtime expression], for example in the following:

function x(a=b+1) {}
WriteDump(getMetaData(x).parameters[1]["default"]);

Does it allow us to go no deeper than this, or perhaps someone knows how to keep digging and start walking trees?


Solution

  • Default UDF parameter expressions aren't available in function metadata as you've found. Other libraries that have implemented some form of CFML parser are

    CFLint (written in Java and using ANTLR)

    https://github.com/cflint/CFLint

    CFFormat (also uses a binary compiled from Rust)

    https://www.forgebox.io/view/commandbox-cfformat

    Function LineNums (pure CFML)

    https://www.forgebox.io/view/funclinenums