In my last blog entry, I talked about how you can use ColdFusion Builder to perform code refactoring - essentially - supporting the updating of your APIs through the rest of your code base. You change some method from doX to performX, and ColdFusion Builder can help you update any scripts that make use of that code. Today I'm going to talk about the obvious related feature to this - references.
In order to perform any refactoring, ColdFusionBuilder first has to actually find the stuff that needs updating. There are a few ways you can make use of this feature. First - you can right click on a file in your Navigator view. Unfortunately you can only do this for CFM and CFCs, and not JavaScript or CSS files. In my first test, I simply ran a references report on my layout custom tag for BlogCFC: Nice, and pretty much what I expected. I then tried it on blog.cfc, but the only result then was blog.cfc itself, specifically the returnType="blog" line. CFBuilder wasn't able to recognize that I made an instance of blog.cfc within my Application.cfm file. Since I typically always create my CFCs within Application.cfc/cfm or ColdSpring, this isn't a huge big deal to me. The next place you can use references is on an individual UDF or CFC method. I tried this on my blog's isEmail UDF from a udf library file. It worked exactly as I expected and found every use of isEmail(). I then tried to trick it. I first use the following template:
Is this isemail test?
CFBuilder wasn't fooled by this. Nice! Now the next thing impressed me even more. I changed my template to this:
Is this isemail test?
no test case #ISEMAIL()# dude
Once again, CFBuilder didn't find the call. Can you guess why? No cfoutput! As soon as I wrapped the line in cfoutput tags, CFBuilder found it. On the flip side, when I tried this template:
Is this isemail test?
no test case #ISEMAIL()# dude
<cfset foo = isEmaiL()>
CFBuilder still found it. All in all, pretty impressive. While refactoring makes me nervous (warranted or not), I can see using the references feature quite a bit!