This post is more than 2 years old.
<cfparam name="ideeventinfo"> <cfset builderHelper = new builderHelper(ideeventinfo)> <cfset runAs = builderHelper.getRunType()>
You begin by passing in the XML packet CFBuilder sends on all requests to the CFC. The getRunType returns how the extension was run. Since my JSLint extension runs from both the project explorer and the editor I need to know which was used.
<cfif runAs is "projectView"> <cfset selectedResource = builderHelper.getSelectedResource()> <cffile action="read" file="#selectedResource.path#" variable="contents"> <cfset resource = selectedResource.path> <cfelseif runAs is "editor"> <cfset data = builderHelper.getSelectedText()> <cfset contents = data.text> <cfset resource = data.path> <cfelse> <cfthrow message="JSLint extension run in a way it is not supposed to be run."> </cfif>
If we called the extension via the project view, I ask for the selected resource. This returns a structure of the path of the selection as well as the type (folder versus file). If the editor was used, I simply run getSelectedText. This method will check to see if there was an actual selection. If not, it grabs the entire contents of the file. Finally, here is another method in action:
Anyway, I plan on adding to this as time goes on. Click the download link below to get the extension.