Skip to Content »

FlashApe » Auto-create getters/setters in TextMate

 Auto-create getters/setters in TextMate

  • March 14th, 2006
  • 2:34 pm

Since I'm digging into components more I have been writing a lot more getters/setters than I used to, which I don't like, because they are just boring. Luckily, I found a TextMate command by Jason Froderman that will automatically create getter/setter pairs from a class property you have selected. Yeah!

note: it wont work if you already have a value assigned to the property:

Actionscript:
  1. private var a:Number

works

Actionscript:
  1. private var a:Number =10

no workie.

New Car Loans new car financing

2 People had this to say...

Gravatar
  • Ketan
  • March 14th, 2006
  • 4:20 pm

You can also use a snippet, a little simpler. I set my tab trigger to "getset"

// @property ${2:Description}
private var \$${1:name}:${4:Type};

/////////////////////////////////////
/*
// @method get ${1:name}
//
// @description ${2:Description}
// @return ${4:Void}
*/
function get ${1:name} ():${4:Type} {
return \$${1:name};
}

/////////////////////////////////////
/*
// @method set ${1:name}
//
// @description ${2:Description}
// @param p_${1:name}:${4:Type} Description
// @return ${4:Type}
*/
function set ${1:name} (p_${1:name}:${4:Type}):${4:Type} {
\$${1:name} = p_${1:name};
${5:statement;}
}

Gravatar
  • rich
  • March 14th, 2006
  • 9:57 pm

whoa!! that is awesome! thats the first time i ever tried using a snippet. That's friggin sweet how you can put the tab stops in there to tab around to the necessary points after you insert the getter/setters. thanks for that!

Want your say?

* Required fields. Your e-mail address will not be published on this site


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