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

File upload and Progress events with HTML5 XmlHttpRequest Level 2

The XmlHttpRequest Level 2 specification adds several enhancements to the XmlHttpRequest object. Last week I had blogged about cross-origin-requests and how it is different from Flash\Silverlight's approach .  With Level 2 specification one can upload the file to the server by passing the file object to the send method. In this post I'll try to explore uploading file using XmlHttpRequest 2 in conjunction with the progress events. I'll also provide a description on the new HTML5 tag -  progress which can be updated while the file is being uploaded to the server. And of course, some ColdFusion code that will show how the file is accepted and stored on the server directory.

Server sent events with HTML5 and ColdFusion

There are several ways to interact with the server apart from the traditional request\response and refresh all protocol. They are polling, long polling, Ajax and Websockets ( pusherapp ). Of all these Ajax and Websockets have been very popular. There is another way to interact with the server such that the server can send notifications to the client using Server Sent Events (SSE) . SSE is a part of HTML5 spec:  http://dev.w3.org/html5/eventsource/

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.