jEdit Community - Resources for users of the jEdit Text Editor
Somewhat Advanced SuperAbbrevs
Submitted by takeshin on Tuesday, 4 November, 2008 - 22:10
Hello, Is there any chance of getting SupperAbrrevs to process variable twice? I'm trying to do something like that, but it doesn’t work: ${1:public} <# if ("$1" == "private") { #> <#= "_" #> <# } #> If user enters "private" it should write underscore. Another problem is processing entered variables like this: /** * Setter for property '${1:property}' * * @access ${2:public} * @name set<# fu = "$1"; fu = fu.toUpperCase(); #><#= fu #> * @param ${3:string} \$$1 $4 * @return ${5:null} */ $2 function set${1=firstUp(s)}(\$$1) { \$this->${6:_}$1 = \$$1; } $end It returns setter in PHP like this: /** * Setter for property 'property' * * @access public * @name setproperty * @param string $property * @return null */ public function setProperty($property) { $this->_property = $property; } But I want to have camelCase setProperty after @name How to achieve that? -- regards, takeshin
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Late answer
by sune_simonsen on Sat, 21/02/2009 - 00:10
Hey takeshin,

If I understand you correctly you want you want a SuperAbbrev that will insert an underscore before private variables. The thing you missed, properly because of my poor documentation is that code that should be evaluated when typing is placed in transformation field. You can achieve what you want using the following code:

${1:public} ${1=ifEquals(s,"private","_","")}${2:name};

The part to notice is ${1=ifEquals(s,"private","_","")}, this is a transformation field that transform the text from field 1 given by the variable s. The ifEquals method compares the two first first arguments and returns the third argument if they are equals; otherwise argument four is returned.

For the camelCase problem there is a method named firstUp() you can use. Take a look at the SuperAbbrevs for java, they shows some of the advanced features.

Hope that clear up things a little.

-- Sune Simonsen (SuperAbbrevs)
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300