Skip to main content

Quick Fix in ColdFusion Builder

Quick Fix is another interesting feature introduced in ColdFusion Builder 2.0. The CFML Editor now provides corrections to the problems found in the file that you are editing. The Editor tries to resolve the CFCs specified at various places i.e. in createObject function, the new operator or the ones specified in the tags cfinvoke\cfobject. The Editor also tries to resolve the functions using CFC introspection. Now if you have declared a CFC or a function which doesn't exist, then the CFML Editor instead of showing an error in document provides Quick Fix suggestions.


Quick fix suggestions for components:


As shown in picture above, the CFML Editor was not able to resolve the component 'Component1' and instead of showing an error, the Editor has shown a yellow marker indicating that a quick fix suggestion is available. On clicking the yellow marker, a list containing suggestions are shown.
On selecting the first suggestion, the component will be created in the same directory as the cfm file. The user need not invoke the New CFC wizard. Instead, the IDE will create the component on users' behalf. 
On selecting the second option, the component would be created right under the webroot of the associated server. If the server is not associated with the project, then this suggestion would not be shown.
The third option would create the component in a directory location specified by the user.

Similarly quick fix suggestions would be shown for the tags cfinvoke and cfobject. Quick fix suggestions are also shown if the Editor is not able to resolve the components mentioned as attribute values to extends or implements in a cfcomponent tag.

Quick fix suggestions for functions:

Quick fix suggestions are also provided for functions which are not defined. Taking the above example, once the component is created and when you try to invoke a function which doesn't exist, then the quick fix will suggest you to create a function. 


On accepting the suggestion, the function would be created in Component1. 

If one invokes a function with arguments, then the cffunction with arguments would be created. Say if I invoke a function with two arguments 'arg1' and 'arg2' which are of type numeric and string respectively, then a cffunction would be created with two arguments and the type of those arguments will be numeric and string.   That is, arguments will be of the same type as the parameters passed to the function.
How cool is that... 

If you are writing a script style code, then the component or the function would be created in script style syntax.


Comments

  1. It doesn't look like QuickFix can find a function defined in a file that is extended by the Application.cfc (extends a framework.cfc)

    ReplyDelete
  2. Can you explain with an example? Do you mean if a function in Application.cfc say onRequest invokes a function in the parent cfc, the editor shows quick fix for that?

    ReplyDelete
  3. It sounds like Anonymous has run into one of the bugs I logged:

    https://bugbase.adobe.com/index.cfm?event=bug&id=2829326

    Essentially, it only works if the text-case you use in your Extends attribute exactly matches the case you find in CFB's Services browser (and the physical file system)

    So if the extends attribute is: extends="my.framework" but the file system is my/Framework.cfc, then QuickFix doesn't recognize the match. If you change your extends attribute to my.Framework, then it works as expected.

    Vote for the bug! ;)

    ReplyDelete
  4. Personally, I find this feature pretty useless and, therefore, I keep it disabled when loading a lib file using dynamic path, e.g. 'cfinclude template="#p_cf_tags#/cf_lib.cfm"'

    ReplyDelete
  5. @Edy,

    Dynamic path is not supported since the IDE cannot know the value of it.

    ReplyDelete
  6. @Sagar,

    Indeed, that's the reason that forces me to disable the Quick Fix.

    ReplyDelete

Post a Comment

Popular posts from this blog

Custom validation messages for HTML5 Input elements using the constraint validation API

HTML5 has introduced several input types such as EMAIL, URL, RANGE, SEARCH, DATE, TIME, etc,. Most of the modern browsers have implemented them and are ready to be used in a HTML document. Another exciting feature introduced in HTML5 is the form validation. Instead of writing JavaScript to validate users input, browsers can now validate it and show an appropriate message if the validation fails. The validation message is shown in line with the field for which the validation has failed. The default error message is shown when the validation fails. In this post I'll explain how these error messages can be changed.

Adding beforeRender and afterRender functions to a Backbone View

I was working on a Backbone application that updated the DOM when a response was received from the server. In a Backbone View, the initialize method would perform some operations and then call the render method to update the view. This worked fine, however there was scenario where in I wanted to perform some tasks before and after rendering the view. This can be considered as firing an event before and after the function had completed its execution. I found a very simple way to do this with Underscore's wrap method.

De-obfuscating javascript code in Chrome Developer Tools

I had blogged about JavaScript debugging with Chrome Developer Tools some time back, wherein I have explained how these developer tools can help in debugging javascript code. Today Google Chrome 12 was released and my Chrome browser was updated to this version. As with every release, there have been some improvements made on performance, usability etc,. One feature that stood out for me is the ability to De-obfuscate the javascript code.

What is Minification?

Minification is the process of removing unnecessary characters such as white spaces, comments, new lines from the source code. These otherwise would be added to make the code more readable. Minifying the source code helps in reducing the file size and thereby reducing the time taken to download the file. This is the reason why most of the popular javascript libraries such as jQuery are minified. A minified jQuery file is of 31 KB in size where as an uncompressed one is about 229 KB. Unfortunately, debugging minified javascript file…