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.

A cheat sheet of keyboard shortcuts in ColdFusion Builder

In my last post I have explained about keyboard shortcuts in ColdFusion Builder 2.0. This blog post contains a list of all shortcut keys and I have listed these keyboard shortcuts based on the categories that it falls into. Well, this post was not planned since users can easily get to know the keyboard shortcuts by navigating to the preferences (ColdFusion -> Profiles -> Keys). However, I met Joshua at Scotch on the rocks in Edinburgh and he suggested that it would be nice to have the list of keyboard shortcuts handy. So this post is for those who would like to have the list with them and refer it whenever required.


Keyboard shortcuts for inserting text:

These are the keyboard shortcuts which are used to insert some text into the editor:

CommandKeyboard shortcuts on WindowsKeyboard shortcuts on MacInsert anchor tagCTRL + T, LCMD + T, LInsert bold tagCTRL + T, BCMD + T, BInsert br tagCTRL + T, RCMD + T, RInsert cfabortCTRL + T, ACMD + T, AInsert cfdumpCTRL + T, DCMD + T, DInsert cfs…