Merge pull request #329 from RyanPineo/master

Java: fix setter. camel case vars/types properly.
This commit is contained in:
Holger Rapp 2014-03-30 12:05:31 +02:00
commit 6de3bb7ccb

View File

@ -25,8 +25,13 @@ def getArgs(group):
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
if not word: return ''
return word[0].upper() + word[1:]
def mixedCase(word):
if not word: return ''
return word[0].lower() + word[1:]
endglobal
snippet sleep "try sleep catch" b
@ -338,23 +343,23 @@ endsnippet
snippet /get(ter)?/ "getter" br
public ${1:String} get${2:Name}() {
return `!p snip.rv = t[2].lower()`;
return `!p snip.rv = mixedCase(t[2])`;
}
endsnippet
snippet /set(ter)?/ "setter" br
public void set${1:Name}(${2:String} $1) {
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
endsnippet
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
}
public $2 get$1() {
return `!p snip.rv = t[1].lower()`;
return `!p snip.rv = mixedCase(t[1])`;
}
endsnippet