Skip to content

Commit e5f3d6b

Browse files
committed
Change java set/get snippets to use mixedCase.
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.
1 parent ad8883d commit e5f3d6b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

UltiSnips/java.snippets

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def getArgs(group):
2727
def camel(word):
2828
return word[0].upper() + word[1:]
2929
30+
def mixedCase(word):
31+
return word[0].lower() + word[1:]
32+
3033
endglobal
3134

3235
snippet sleep "try sleep catch" b
@@ -338,23 +341,23 @@ endsnippet
338341

339342
snippet /get(ter)?/ "getter" br
340343
public ${1:String} get${2:Name}() {
341-
return `!p snip.rv = t[2].lower()`;
344+
return `!p snip.rv = mixedCase(t[2])`;
342345
}
343346
endsnippet
344347

345348
snippet /set(ter)?/ "setter" br
346-
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
347-
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
349+
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
350+
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
348351
}
349352
endsnippet
350353

351354
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
352-
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
353-
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
355+
public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
356+
this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
354357
}
355358

356359
public $2 get$1() {
357-
return `!p snip.rv = t[1].lower()`;
360+
return `!p snip.rv = mixedCase(t[1])`;
358361
}
359362
endsnippet
360363

0 commit comments

Comments
 (0)