Andrew Odri

May
6
2009
There are 3 comments

Dreamweaver Code Hints

After many battles with the quirks in the Dreamweaver API, code completion is now working quiet nicely. After trawling through the code hinting documentation, and getting some help from the Adobe team, it turns out that it’s actually not all that difficult to get working if you adhere closely to a prescribed structure.

One few thing to keep in mind: start off simple. Don’t add any language or file restrictions in until everything is proven to work. I learn best from examples, so here is an example that defines packages and classes, which use static properties and methods, as well as and instance properties and methods:

<codehints xmlns:MMString="http://www.adobe.com/schemes/data/string/">
	<menugroup MMString:name="CodeHints_Example" id="CodeHints_Example" name="Example Code Hints" enabled="true">
		<description>
			<![CDATA[Example Code Hints]]>
		</description>
		<!--
			This is how a package is defined.
				- Each tier must be defined by an independant menu element
				- The pattern attribute must be used
				- The pattern value must be followed by a dot
		-->
		<menu pattern="package." casesensitive="true">
			<menuitem label="firsttier" icon="shared/mm/images/hintPackage.gif" />
		</menu>
		<menu pattern="package.firsttier." casesensitive="true">
			<menuitem label="secondtier" icon="shared/mm/images/hintPackage.gif" />
		</menu>
		<menu pattern="package.firsttier.secondtier." casesensitive="true">
			<menuitem label="ExampleClass" icon="shared/mm/images/hintClass.gif" />
		</menu>
		<!--
			This is how a class constructor is defined.
				- The pattern attribute must be used
				- The pattern value must be the absolute path to the class
				- The pattern value must also contain any parameters that need to be passed to the constructor
		-->
		<function pattern="package.firsttier.secondtier.ExampleClass(Object parameter)" casesensitive="true" icon="shared/mm/images/hintClass.gif" />		
		<!--
			This is how static class members are defined.
				- The pattern value must be the absolute path to the class
				- The pattern value must be followed by a dot
				- Static properties and events must be menuitem elements that are children of the menu element
				- Static methods must be menuitem elements that are children of the menu element, with a label element the ends with an opening parenthesis
				- Static methods must also be function elements that are siblings of the menu element
				- Static methods must also contain any parameters that need to be passed to the function
		-->
		<menu pattern="package.firsttier.secondtier.ExampleClass." casesensitive="true">
			<menuitem label="staticProperty" icon="shared/mm/images/hintProperty.gif" />
			
			<menuitem label="staticMethod" value="staticMethod(" icon="shared/mm/images/hintFunction.gif" />
		</menu>
		<function pattern="package.firsttier.secondtier.ExampleClass.staticMethod(Integer id, String value)" icon="shared/mm/images/hintFunction.gif" />
		<!--
			This is how instance class members are defined. 
				- The classpattern attribute must be used, and not the pattern attribute
				- The classpattern value must be the absolute path to the class
				- Instance properties must be property elements that are children of the menu element
				- Instance methods must be function elements that are children of the menu element
				- Instance methods must also contain any parameters that need to be passed to the function
		-->
		<menu classpattern="package.firsttier.secondtier.ExampleClass">
			<property label="instanceProperty" icon="shared/mm/images/hintProperty.gif" />
			
			<method pattern="append(ExampleClass childExampleClass)" icon="shared/mm/images/hintFunction.gif" />
			<method pattern="remove(ExampleClass childExampleClass)" icon="shared/mm/images/hintFunction.gif" />
		</menu>
	</menugroup>
</codehints>

There are a few ways to get this up and running, and much of what you need to get going will be contained in the code hints tag reference.

July
27
2009

Hi,

I’m trying to figure out how to get the methods (functions) from the CFC objects to be displayed after I type in objectName.

It’s such a pain to keep having to open up the CFC to see what the methods were called, isn’t there a way to make it automatically show all the methods for an object after a period is typed? Do I really have to manually add all the methods for each object to an XML?

July
27
2009
by Andrew Odri (@andrewodri)

Hey Roman,

From what I can tell, ColdFusion support is actually building into Dreamweaver CS4 – I attempted creating a component, and the code hinting seemed to work quiet well.

However, if you have an older version, or perhaps are using some features of the language that I am not familiar with (which is very very likely :P), I would suggest looking at the Dreamweaver Exchange to see if you can find a prebuilt extension for the functionality you are looking for:

http://www.adobe.com/cfusion/exchange/index.cfm?searchfield=coldfusion&search_exchange=3&search_category=-1&search_license=&search_rating=&search_platform=0&search_pubdate=&num=25&startnum=1&event=search&sticky=true&sort=0&rnav_dummy_tmpfield=&Submit=

Hope this turns up a solution for you!

May
7
2011
by Ibn Saeed

Thanks alot, it really helped me to create my custom tags.

It was excellent that you created a very simple example and it worked perfectly in Dreamweaver CS5.

Now i can learn from it to create my own tags.

Leave a Response

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>