Skip to content

Commit

Permalink
Merge pull request honza#329 from RyanPineo/master
Browse files Browse the repository at this point in the history
Java: fix setter. camel case vars/types properly.
  • Loading branch information
SirVer committed Mar 30, 2014
2 parents 3924bae + 87ea532 commit 6de3bb7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions UltiSnips/java.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6de3bb7

Please sign in to comment.