Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix java setter method param case, remove return. #329

Merged
merged 3 commits into from
Mar 30, 2014
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a case for when word is empty - in case it is called on an empty tabstop. it will blow up then.

if not word:
     return ''

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} $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