ColdFusion Builder - References

This post is more than 2 years old.

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!

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Allen posted on 3/12/2010 at 11:09 PM

I didn't even know this was possible with cfBuilder. I"ll have to give it a try. I'm a big believer in giving variables and functions meaningful names. This would help a lot in doing that both for new code and old.

Comment 2 by Marko Simic posted on 3/15/2010 at 1:42 PM

It doesn't work on method calls by cfinvoke

Comment 3 by Randy Smith posted on 12/30/2013 at 8:00 PM

I just stumbled upon this article and was happily surprised to discover the reason behind that "References" menu item on the CFB context menu. I had never bothered to click on it in all the years I've been using ColdFusion Builder.

In my CFB 2.0, I decided to try it out. I right clicked the first file I saw in my clients project, chose project (vs. workspace), ran. and ran. and ran. and then it killed ColdFusion Builder.

First time I've ever seen CFB die like that.

I re-started CFB, chose a different file, and this time it gave me an error with the message "An internal error occurred during: "Finding references ...".

I am rather dissapointed.

Comment 4 by Raymond Camden posted on 12/30/2013 at 8:01 PM

Randy, best I can recommend is a) ensuring you are on the latest (which I think is 2.0.1?) and filing a bug report for what you saw. I don't use CFB myself anymore.

Comment 5 by Randy Smith posted on 12/30/2013 at 8:18 PM

Ray, thanks. It looks like I am on the latest:

Version: 2.0.1
Build: 283931

but I will check for updates anyway.

What are you using for an IDE these days for ColdFusion?


Comment 6 by Raymond Camden posted on 12/30/2013 at 8:25 PM

Sublime Text 2 with the CFML plugin.