Skip to content

Commit

Permalink
Change java set/get snippets to use mixedCase.
Browse files Browse the repository at this point in the history
The java setter and getter snippets were incorrectly formatting the
set/get name as all lowercase.  It should be mixed case, as per java's
coding standard.

A new function was made (mixedCase) to handle that.
  • Loading branch information
ryanpineo committed Mar 28, 2014
1 parent ad8883d commit e5f3d6b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions UltiSnips/java.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def getArgs(group):
def camel(word):
return word[0].upper() + word[1:]
def mixedCase(word):
return word[0].lower() + word[1:]
endglobal

snippet sleep "try sleep catch" b
Expand Down Expand Up @@ -338,23 +341,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} `!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])`;
}
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 e5f3d6b

Please sign in to comment.