ew java snippets for constructors for auto creation of setter/getters
This commit is contained in:
parent
9dd78cd750
commit
5dd7717f9d
@ -18,13 +18,15 @@ def nl(snip):
|
|||||||
snip += ""
|
snip += ""
|
||||||
else:
|
else:
|
||||||
snip.rv += " "
|
snip.rv += " "
|
||||||
endglobal
|
def getArgs(group):
|
||||||
|
import re
|
||||||
|
word = re.compile('[a-zA-Z><.]+ \w+')
|
||||||
|
return [i.split(" ") for i in word.findall(group) ]
|
||||||
|
|
||||||
snippet cn "public constructor" !b
|
def camel(word):
|
||||||
public `!p snip.rv = snip.basename or "unknown"`($1) {
|
return word[0].upper() + word[1:]
|
||||||
$0
|
|
||||||
}
|
endglobal
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet sleep "try sleep catch" !b
|
snippet sleep "try sleep catch" !b
|
||||||
try {
|
try {
|
||||||
@ -40,7 +42,7 @@ $0
|
|||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet /o|v/ "new Object or variable" !br
|
snippet /o|v/ "new Object or variable" !br
|
||||||
${1:Object} ${2:var} = new ${2}(${3});
|
${1:Object} ${2:var} = new $1(${3});
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet f "field" !b
|
snippet f "field" !b
|
||||||
@ -91,7 +93,58 @@ snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements
|
|||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet clc "class" b
|
snippet clc "class with constructor, fields, setter and getters" !b
|
||||||
|
public class `!p
|
||||||
|
snip.rv = snip.basename or "untitled"` {
|
||||||
|
`!p
|
||||||
|
import re
|
||||||
|
args = getArgs(t[1])
|
||||||
|
if len(args) == 0: snip.rv = ""
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
||||||
|
if len(args) > 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
||||||
|
args = getArgs(t[1])
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
||||||
|
if len(args) == 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
}
|
||||||
|
`!p
|
||||||
|
args = getArgs(t[1])
|
||||||
|
if len(args) == 0: snip.rv = ""
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
|
||||||
|
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
|
||||||
|
|
||||||
|
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\
|
||||||
|
\n\t\treturn " + i[1] + ";\n\t}\n"
|
||||||
|
`
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet clc "class with constucutor, with field names" b
|
||||||
|
public class `!p
|
||||||
|
snip.rv = snip.basename or "untitled"` {
|
||||||
|
`!p
|
||||||
|
import re
|
||||||
|
args = getArgs(t[1])
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
||||||
|
if len(args) > 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
||||||
|
args = getArgs(t[1])
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
||||||
|
if len(args) == 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet clc "class and constrcutor" b
|
||||||
public class `!p
|
public class `!p
|
||||||
snip.rv = snip.basename or "untitled"` {
|
snip.rv = snip.basename or "untitled"` {
|
||||||
|
|
||||||
@ -144,7 +197,7 @@ for ($1 $2 : $3)`!p nl(snip)`{
|
|||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet fori "for" b
|
snippet fori "for" b
|
||||||
for (int ${1:i} = 0; $1 < $2; $1++)`!p nl(snip)`{
|
for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{
|
||||||
$0
|
$0
|
||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -192,16 +245,33 @@ snippet set "Collections Set" !b
|
|||||||
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
|
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet /s(tr)?/ "String" !br
|
snippet /Str?|str/ "String" !br
|
||||||
String
|
String
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet cn "Constructor" !b
|
snippet cn "Constructor" b
|
||||||
public `!p snip.rv = snip.basename or "untitled"`(${1:}) {
|
public `!p snip.rv = snip.basename or "untitled"`(${1:}) {
|
||||||
$0
|
$0
|
||||||
}
|
}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
snippet cn "constructor, \w fields + assigments" b
|
||||||
|
`!p
|
||||||
|
import re
|
||||||
|
args = getArgs(t[1])
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
|
||||||
|
if len(args) > 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
|
||||||
|
args = getArgs(t[1])
|
||||||
|
for i in args:
|
||||||
|
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
|
||||||
|
if len(args) == 0:
|
||||||
|
snip.rv += "\n"`
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
snippet j.b "java_beans_" i
|
snippet j.b "java_beans_" i
|
||||||
java.beans.
|
java.beans.
|
||||||
endsnippet
|
endsnippet
|
||||||
@ -251,11 +321,8 @@ endsnippet
|
|||||||
snippet md "Method With javadoc" !b
|
snippet md "Method With javadoc" !b
|
||||||
/**
|
/**
|
||||||
* ${7:Short Description}`!p
|
* ${7:Short Description}`!p
|
||||||
import re
|
for i in getArgs(t[4]):
|
||||||
snip.rv = ""
|
snip.rv += "\n\t * @param " + i[1] + " usage..."`
|
||||||
word = re.compile('\w+ \w+')
|
|
||||||
for i in word.findall(t[4]):
|
|
||||||
snip.rv += "\n\t * @param " + i.split(" ")[1] + " usage..."`
|
|
||||||
* `!p
|
* `!p
|
||||||
if "throws" in t[5]:
|
if "throws" in t[5]:
|
||||||
snip.rv = "\n\t * @throws " + t[6]
|
snip.rv = "\n\t * @throws " + t[6]
|
||||||
|
@ -10,10 +10,6 @@ ${4:" Last Modified: `!v strftime("%B %d, %Y")`}
|
|||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet b "Bundle" !b
|
|
||||||
Bundle '$0'
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet gvar "Global / configuration variable"
|
snippet gvar "Global / configuration variable"
|
||||||
if !exists("g:${1:MyUltraImportantVar}")
|
if !exists("g:${1:MyUltraImportantVar}")
|
||||||
let g:$1 = ${2:"${3:<tab>}"}
|
let g:$1 = ${2:"${3:<tab>}"}
|
||||||
|
@ -3,3 +3,7 @@ snippet t "Simple tag" b
|
|||||||
${2:content}
|
${2:content}
|
||||||
</${1/(\w+).*/$1/}>
|
</${1/(\w+).*/$1/}>
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
snippet ti "Inline tag" b
|
||||||
|
<${1:tag}>${2:content}</${1/(\w+).*/$1/}>
|
||||||
|
endsnippet
|
||||||
|
Loading…
Reference in New Issue
Block a user