FlashDevelop Code Generation
FlashDevelop Beta 6 was released last Friday and with it came a great new tool for contextual code generation.
It will generate event handlers, getter/setter methods, unknown members, promote local variables to instance variables, and insert interface methods. As you probably can probably guess from my Gaia Flash Framework, I'm a big fan of code generation.
Update! A commenter pointed out that putting braces on the next line is an option in FlashDevelop. However, the getter code generation puts the getter on a single line. I've made a slight modification to the code generation template file. If you dig on the forums you'll find out where the code template file is.
Here is the updated file. Just overwrite your Generator.txt file with this one for cleaner code generation in FlashDevelop. I also recommend changing the keyboard shortcut from CTRL+SHIFT+1, which is awkward, to say the least, to something like ALT+2, which is natural to press with your thumb and middle finger and not natively reserved by anything in FD.
Posted in Actionscript, Tips/Tricks, Workflow
February 21st, 2008 at 5:42 pm
"I used to hate it, but I decided to try it for a month and I discovered why it’s popular"
Why is it popular? (Still hate it, myself.)
These additions are great–nice to have some of the code generation functionality that Eclipse offers for Java. But I'm finding a few problems with FlashDevelop's implementation. For example, if I'm create a class that implements an interface which extends other interfaces, but adds nothing new of its own, then FlashDevelop doesn't create any interface methods when I tell it to. It's like it can only see one level up in the interface hierarchy.
Still, beats the competition, at least for code generation. Just waiting for everyone to catch up to Eclipse….
February 21st, 2008 at 6:06 pm
The only thing I can say is that it's still in beta, and the interface inheritance issue you brought up will likely be resolved should enough people post about it on the forums. The authors are active on the forums.
February 21st, 2008 at 6:42 pm
Having the braces one line after helps a lot in debugging because if you scroll up and down, you'll easily see if the braces line up (and thus can detect missing braces easier)
February 22nd, 2008 at 2:29 am
Just to comment on using a new line before curly braces, one thing I do religiously is to put spaces between braces and parameters and between parameters and their type specifiers, so for a function signature, I might use
function myFunction( param1 : Type1, param2 : Type2 ) : Type3
It makes code far easier to read when you have large classes (or small ones for that matter).
Lee
February 22nd, 2008 at 4:05 am
hi. in fd3 program settings (F10), you can set the Coding Style Type to BracesAfterLine (under Indenting in main setting panel). Templates use the $(CSLB) token to determine whether or not the programmer wants those line breaks.
February 22nd, 2008 at 9:27 am
Haha. Man, I should learn to RTFM. I've been manually putting my braces on the next line in FD since version 1.
Thanks!
February 25th, 2008 at 10:06 pm
Hi Steven, could you shed some light on how you change the keyboard shortcut from CTRL+SHIFT+1 to ALT+2? I've searched through the forums but can't find a solution.
Thanks in advance!
February 25th, 2008 at 11:52 pm
F10 for Program Settings
Select ASCompletion from left column
Scrolldown to
Shortcuts
– Contextual Generator
February 26th, 2008 at 6:52 pm
Thanks! I was absolutely digging in the wrong place!
October 25th, 2009 at 2:11 am
How do you use the getter and setter creation ?
July 27th, 2010 at 11:55 am
use the contextual code generator shortcut on any class member variable at it's declaration.
i.e. private var foo:String;
you would use the shortcut on the part that says foo