History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CFML-52
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Valeria Nikolaenko
Reporter: Kenton
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IntelliJ IDEA CFML Plugin

Application.cfm/cfc awareness

Created: 17 Jun 09 18:20   Updated: 15 Aug 09 01:25
Component/s: None
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
I mentioned this on a previous ticket, but I think it deserves its own.

Application.cfm/cfc is similar to a servlet filter, where the code runs before the page is executed. The application.cfm/cfc in the first parent directory is the one used.

On application.cfm all code is executed before request start, on the application.cfc only the onRequestStart method is executed.

So for example if you had a directory structure like so

/application.cfm
/myfolder/application.cfm
/myfolder/subfolder/MyPage.cfm
/anotherfolder/AnotherPage.cfm

MyPage.cfm would run myfolder/application.cfm before execution. /application.cfm would not be run

However AnotherPage.cfm would run /application.cfm because it doesn't have an application.cfm inside /anotherfolder/

It is common practice in Application.cfm/cfc to define or include functions and variables so you would want them available to you.

It is very common to use a <cfinclude template="/functions/MyFunctionsLib.cfm"> on the Application.cfm to import a file of <cffunction> tags

Since it is common to declare variables it would be fantastic if I could use the @cfmlvariable annotation on my application to make request wide variables automatically type aware throughout pages that use the application.cfm/cfc.

Let me know if I can provide any more detail or explanation. Here is a document from Adobe with an overview of the structure of Application.cfm/cfc
http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00001111.htm



 All   Comments   Work Log   Change History      Sort Order:
bill shelton - 19 Jun 09 14:15 - edited
IDEAlly it would be nice to not specify variable meta data anywhere and IDEA would just know. But it's a step in the right direction ...

Since IDEA is decoupled from the CF runtime, what about (for now) specifying this configuration information at the project level instead of in the code? Maybe something in the ColdFusion facet that allows you to specify variable name literals or patterns and patterns for matching directories and files? Example:

Project Settings > Facets > ColdFusion > MyColdFusion Facet ... Then somewhere in there, you could specify something like:

Variable References Table:

Variable Name(pattern) Type Libraries Apply to Files(Filter)
loader javaloader /lib/*.jar, foo.jar /***/*
javaVar* java /usr/lib/jar.jar /admin/***/*.cfc
myCFVar cf /www/someapp/ /***/.*
flex* flex /www/flex/foo.swf /ui/**.cfc

Where "loader" is a literal name to be matched exactly anywhere in the project structure. And "javaVar*" is a pattern that would match any valid variable name that begins the string javaVar AND that exists anywhere in the /admin/ subdirectory AND matches any cfc files. At least this way, we might be able to have content assist for 3rd party classes but only have to specify it in one place. However, maybe while coding, we wouldn't want to stop to configure the project, so using the <!---@cfmlvariable ... ---> would override what's defined at the project level.

just an idea ...


Daniel Jimenez - 19 Jun 09 20:04
Bill no offense, that sounds pretty confusing and crazy. Lots of room for errors. Personally I don't want to use a coldfusion facet, just like I wouldn't want to use a JSP facet.

Kenton - 19 Jun 09 20:14
Bill, I can understand that approach, but I do think it might be too complicated to configure. From an end users perspective though it would be nice if it understood the concept of application.cfm/cfcs as they are so integral to Coldfusion.

Of course the way javascript in IntelliJ works is it just indexes everything, which would accomplish the same goal. I don't know the feasibility of having IntelliJ follow cfincludes so this might end up being the most robust approach, with the least amount of specialized logic (though I do cringe at the thought of my startup times in IntelliJ with over 7,000 cfm files).


bill shelton - 20 Jun 09 04:22
No offense taken I totally agree that IDEA needs to be "application aware", or context sensitive. I guess the question is how? Consider an application.cfc where you would define a set of variables used by the editor (not by coldfusion) in the context of the entire application. How may would that be and could it possibly clutter the code over time? Maybe ... maybe not. It might look like:
<cfapplication ...>
 <!--- @cfmlvariable name="class1" type="org.foo.Bar" --->
 <!--- @cfmlvariable name="class2" type="org.foo.Bar2" --->
 <!--- @cfmlvariable name="class3" type="org.foo.Bar3" --->

I don't know ... this just "feels like" editor configuration information to me. In a Java project, we just add the respective jars to the project's classpath and we have resolution anywhere in the project. So, that's where I'm coming from and would prefer to go if we can make that happen. In the long run, I'd rather have this kind of info persisted with the project rather than in the source code.


Kenton - 15 Aug 09 01:25
I just read this on the Intellij blog and I would love for coldfusion to have a similar configuration option for variables

http://blogs.jetbrains.com/idea/2009/08/enabling-implicit-context-variables-resolution-in-template-files/

This allows you to define it using a comment method OR through a module configuration. Sounds like the best of both worlds to me!