Do any of the ColdFusion IDEs/IDE plugins allow you to perform actions similar to Visual Studio's go to definition and find usages (some details of which are on this page)?

For example, in one .cfc file I might have:

<cfset variables.fooResult = CreateObject(
    "component",
    "Components.com.company.myClass").fooMethod()>

And in myClass.cfc I have:

<cffunction name="fooMethod" access="public">
    <!-- function body -->
</cffunction>

If I have my cursor set over .fooMethod in the first file, a go to definition action should place me on the declaration of that method in myClass.cfc.

At present I'm using the CFEclipse plugin for Eclipse to view some legacy ColdFusion.

有帮助吗?

解决方案

CFEclipse doesn't have this functionality, partly because CFML is a dynamic language with a fair bit of complexity parsing-wise.

You can use regex searching to get you most of the way there in most cases.

Function Definitions

To find a function definition, most times searching for...

(name="|ion )methodname

...is enough, and quicker than the more thorough form of:

(<cffunction\s+name\s*=\s*['"]|\bfunction\s+)methodname

Function Calls

To find a function call, against just do:

methodname\s*\(

Though against you might need to be more thorough, with:

['"]methodname['"]\s*\]\s*\(

...if bracket notation has been used.

You might also want to check for cfinvoke usage:

<cfinvoke[^>]+?method\s*=\s*['"]methodname

Of course, neither of these methods will find if you have code that is:

<cfset meth = "methodname" />
<cfinvoke ... method="#meth#" />

...nor any other form of dynamic method names.


If you really need to be thorough and find all instances, it's probably best to search for the method name alone (or wrapped as \bmethodname\b), and manually walk through the code for any variables using it.

其他提示

IF you use

<cfset c = new Components.com.company.myClass()>
<cfset variables.fooResult = c.fooMethod()>

I believe in CFBuilder you can click Ctrl and the CFC class and method will turn into a hyperlink. See "Code insight" on http://www.adobe.com/ca/products/coldfusion-builder/features.html It works when it work, it doesn't when mapping is incorrect or certain syntax may not be supported. I'm not sure if they support the CreateObject() way.

There's no find usage as CF is not a static language. However, the Find can find what you need most of the time unless the code invokes method dynamically or uses Evaulate()

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top