-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
Java.xml
348 lines (344 loc) · 22.3 KB
/
Java.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?xml version="1.0" encoding="UTF-8"?>
<templateSet group="Java">
<template name="fori" value="for(int $INDEX$ = 0; $INDEX$ < $LIMIT$; $INDEX$++) { $END$ }" description="Create iteration loop" toReformat="true" toShortenFQNames="true">
<variable name="INDEX" expression="suggestIndexName()" defaultValue="" alwaysStopAt="true" />
<variable name="LIMIT" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="itar" value="for(int $INDEX$ = 0; $INDEX$ < $ARRAY$.length; $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $ARRAY$[$INDEX$]; $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.itar" toReformat="true" toShortenFQNames="true">
<variable name="INDEX" expression="suggestIndexName()" defaultValue="" alwaysStopAt="true" />
<variable name="ARRAY" expression="arrayVariable()" defaultValue=""array"" alwaysStopAt="true" />
<variable name="ELEMENT_TYPE" expression="componentTypeOf(ARRAY)" defaultValue="" alwaysStopAt="false" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="itco" value="for($ITER_TYPE$ $ITER$ = $COLLECTION$.iterator(); $ITER$.hasNext(); ) { $ELEMENT_TYPE$ $VAR$ =$CAST$ $ITER$.next(); $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.itco" toReformat="true" toShortenFQNames="true">
<variable name="ITER" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="COLLECTION" expression="variableOfType("java.util.Collection")" defaultValue=""collection"" alwaysStopAt="true" />
<variable name="ELEMENT_TYPE" expression="guessElementType(COLLECTION)" defaultValue=""Object"" alwaysStopAt="true" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="ITER_TYPE" expression="rightSideType()" defaultValue=""java.util.Iterator"" alwaysStopAt="false" />
<variable name="CAST" expression="castToLeftSideType()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="iten" value="while($ENUM$.hasMoreElements()){ $TYPE$ $VAR$ = $CAST$ $ENUM$.nextElement(); $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.iten" toReformat="true" toShortenFQNames="true">
<variable name="ENUM" expression="variableOfType("java.util.Enumeration")" defaultValue=""enumeration"" alwaysStopAt="true" />
<variable name="TYPE" expression="rightSideType()" defaultValue=""Object"" alwaysStopAt="true" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="CAST" expression="castToLeftSideType()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="itit" value="while($ITER$.hasNext()){ $TYPE$ $VAR$ = $CAST$ $ITER$.next(); $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.itit" toReformat="true" toShortenFQNames="true">
<variable name="ITER" expression="variableOfType("java.util.Iterator")" defaultValue=""iterator"" alwaysStopAt="true"/>
<variable name="TYPE" expression="rightSideType()" defaultValue=""Object"" alwaysStopAt="true"/>
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true"/>
<variable name="CAST" expression="castToLeftSideType()" defaultValue="" alwaysStopAt="false"/>
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="itli" value="for (int $INDEX$ = 0; $INDEX$ < $LIST$.size(); $INDEX$++) { $ELEMENT_TYPE$ $VAR$ = $CAST$ $LIST$.get($INDEX$); $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.itli" toReformat="true" toShortenFQNames="true">
<variable name="INDEX" expression="suggestIndexName()" defaultValue="" alwaysStopAt="true" />
<variable name="LIST" expression="variableOfType("java.util.List")" defaultValue=""list"" alwaysStopAt="true" />
<variable name="ELEMENT_TYPE" expression="guessElementType(LIST)" defaultValue=""Object"" alwaysStopAt="true" />
<variable name="VAR" expression="suggestVariableName()" defaultValue=""o"" alwaysStopAt="true" />
<variable name="CAST" expression="castToLeftSideType()" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="ittok" value="for (java.util.StringTokenizer $TOKENIZER$ = new java.util.StringTokenizer($STRING$); $TOKENIZER$.hasMoreTokens(); ) { String $VAR$ = $TOKENIZER_COPY$.nextToken(); $END$ } "
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.ittok" toReformat="true" toShortenFQNames="true">
<variable name="TOKENIZER" expression="suggestVariableName()" defaultValue=""tokenizer"" alwaysStopAt="true" />
<variable name="STRING" expression="variableOfType("java.lang.String")" defaultValue="" alwaysStopAt="true" />
<variable name="VAR" expression="suggestVariableName()" defaultValue=""token"" alwaysStopAt="true" />
<variable name="TOKENIZER_COPY" expression="TOKENIZER " defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="ritar" value="for(int $INDEX$ = $ARRAY$.length - 1; $INDEX$ >= 0; $INDEX$--) { $ELEMENT_TYPE$ $VAR$ = $ARRAY$[$INDEX$]; $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.ritar" toReformat="true" toShortenFQNames="true">
<variable name="INDEX" expression="suggestIndexName()" defaultValue="" alwaysStopAt="true" />
<variable name="ARRAY" expression="arrayVariable()" defaultValue=""array"" alwaysStopAt="true" />
<variable name="ELEMENT_TYPE" expression="componentTypeOf(ARRAY)" defaultValue="" alwaysStopAt="false" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="iter" value="for ($ELEMENT_TYPE$ $VAR$ : $ITERABLE_TYPE$) { $END$ }"
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.iter" toReformat="true" toShortenFQNames="true">
<variable name="ITERABLE_TYPE" expression="iterableVariable()" defaultValue="" alwaysStopAt="true" />
<variable name="ELEMENT_TYPE" expression="iterableComponentType(ITERABLE_TYPE)" defaultValue=""java.lang.Object"" alwaysStopAt="false" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.inst"
name="inst" toReformat="true" toShortenFQNames="true" value="if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }">
<variable alwaysStopAt="true" defaultValue="expr" expression="variableOfType("Object")" name="EXPR" />
<variable alwaysStopAt="true" defaultValue="" expression=""Object"" name="TYPE" />
<variable alwaysStopAt="true" defaultValue="" expression="suggestVariableName()" name="VAR1" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.lst"
name="lst" toReformat="true" toShortenFQNames="true" value="$ARRAY$[$ARRAY$.length - 1]">
<variable alwaysStopAt="true" defaultValue="array" expression="arrayVariable()" name="ARRAY" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_EXPRESSION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.mn"
name="mn" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.min($VAR$, $END$);">
<variable alwaysStopAt="true" defaultValue="" expression="variableOfType("double")" name="VAR" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.mx"
name="mx" toReformat="true" toShortenFQNames="true" value="$VAR$ = Math.max($VAR$, $END$);">
<variable alwaysStopAt="true" defaultValue="" expression="variableOfType("double")" name="VAR" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psvm"
name="psvm" toReformat="true" toShortenFQNames="true" value="public static void main(String[] args){ $END$ }">
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psvm"
name="main" toReformat="true" toShortenFQNames="true" value="public static void main(String[] args){ $END$ }">
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.toar"
name="toar" toReformat="true" toShortenFQNames="true" value="$COLLECTION$.toArray(new $COMPONENT_TYPE$[0])$END$">
<variable alwaysStopAt="true" defaultValue=""Object"" expression="componentTypeOf(expectedType())" name="COMPONENT_TYPE" />
<variable alwaysStopAt="true" defaultValue="collection" expression="variableOfType("java.util.Collection")" name="COLLECTION" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_EXPRESSION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.lazy"
name="lazy" value="if ($VAR$ == null) { $VAR$ = new $TYPE$($END$); }" toReformat="true" toShortenFQNames="true">
<variable name="VAR" expression="variableOfType("java.lang.Object")" defaultValue="" alwaysStopAt="true" />
<variable name="TYPE" expression="subtypes(typeOfVariable(VAR))" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.if.not.null"
name="inn" value="if ($VAR$ != null) { $END$ }" toReformat="true" toShortenFQNames="true">
<variable name="VAR" expression="suggestFirstVariableName("Object")" defaultValue="var" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.if.null"
name="ifn" value="if ($VAR$ == null) { $END$ }" toReformat="true" toShortenFQNames="true">
<variable name="VAR" expression="suggestFirstVariableName("Object")" defaultValue="var" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.geti"
name="geti" toReformat="true" toShortenFQNames="true" value="public static $CLASS_NAME$ getInstance() { return $VALUE$; }">
<variable name="CLASS_NAME" expression="className" defaultValue="" alwaysStopAt="false"/>
<variable name="VALUE" expression="variableOfType(CLASS_NAME)" defaultValue="null" alwaysStopAt="true"/>
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.st"
name="St" toReformat="false" toShortenFQNames="false" value="String ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
<option name="JAVA_DECLARATION" value="true" />
<option name="JAVA_EXPRESSION" value="false" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psf"
name="psf" toReformat="false" toShortenFQNames="false" value="public static final ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.prsf"
name="prsf" toReformat="false" toShortenFQNames="false" value="private static final ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psfi"
name="psfi" toReformat="false" toShortenFQNames="false" value="public static final int ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.psfs"
name="psfs" toReformat="false" toShortenFQNames="false" value="public static final String ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.thr"
name="thr" toReformat="false" toShortenFQNames="false" value="throw new ">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.serr"
name="serr" toReformat="true" toShortenFQNames="true" value="System.err.println($END$);">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template description="System.err::println" name="serrc" toReformat="true" toShortenFQNames="true" value="System.err::println">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_CONSUMER" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.sout"
name="sout" toReformat="true" toShortenFQNames="true" value="System.out.println($END$);">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template description="System.out::println" name="soutc" toReformat="true" toShortenFQNames="true" value="System.out::println">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_CONSUMER" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.souf"
name="souf" toReformat="true" toShortenFQNames="true" value="System.out.printf("$END$");">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.soutm"
name="soutm" toReformat="true" toShortenFQNames="true" value="System.out.println("$CLASS_NAME$.$METHOD_NAME$");">
<variable alwaysStopAt="false" defaultValue="" expression="className()" name="CLASS_NAME" />
<variable alwaysStopAt="false" defaultValue="" expression="methodName()" name="METHOD_NAME" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.soutp"
name="soutp" toReformat="true" toShortenFQNames="true" value="System.out.println($FORMAT$);">
<variable alwaysStopAt="false" defaultValue="" expression="groovyScript("import com.intellij.psi.*;import com.intellij.psi.util.PsiTreeUtil; def file = PsiDocumentManager.getInstance(_editor.project).getPsiFile(_editor.document); PsiMethod method = PsiTreeUtil.findElementOfClassAtOffset(file, _editor.caretModel.offset, PsiMethod.class, false); PsiParameter[] parameters = method == null ? PsiParameter.EMPTY_ARRAY : method.parameterList.parameters; return parameters.size() == 0 ? '' : '\"' + parameters.collect { def prefix = it.name + ' = '; def type = it.type; return type instanceof PsiArrayType ? type.componentType instanceof PsiPrimitiveType ? prefix + '\" + java.util.Arrays.toString(' + it.name + ')' : prefix + '\" + java.util.Arrays.deepToString(' + it.name + ')' : prefix + '\" + ' + it.name }.join(' + \", ')", methodParameters())" name="FORMAT" />
<!--
import com.intellij.psi.*
import com.intellij.psi.util.PsiTreeUtil
def file = PsiDocumentManager.getInstance(_editor.project).getPsiFile(_editor.document)
PsiMethod method = PsiTreeUtil.findElementOfClassAtOffset(file, _editor.caretModel.offset, PsiMethod.class, false)
PsiParameter[] parameters = method == null ? PsiParameter.EMPTY_ARRAY : method.parameterList.parameters
return parameters.size() == 0 ? '' : '"' + parameters.collect {
def prefix = it.name + ' = '
def type = it.type
return type instanceof PsiArrayType
? type.componentType instanceof PsiPrimitiveType
? prefix + '" + java.util.Arrays.toString(' + it.name + ')'
: prefix + '" + java.util.Arrays.deepToString(' + it.name + ')'
: prefix + '" + ' + it.name
}.join(' + ", ')
-->
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.soutv"
name="soutv" toReformat="true" toShortenFQNames="true" value="System.out.println("$EXPR_COPY$ = " + $EXPR$);">
<variable alwaysStopAt="true" defaultValue=""expr"" expression="variableOfType("")" name="EXPR" />
<variable alwaysStopAt="false" defaultValue="" expression="escapeString(EXPR)" name="EXPR_COPY" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="C" resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.surround.with.callable"
value="java.util.concurrent.Callable<$RET$> callable = new java.util.concurrent.Callable<$RET$>() { public $RET$ call() throws Exception { $SELECTION$ $END$ } };"
toReformat="true" toShortenFQNames="true">
<variable name="RET" expression="" defaultValue=""java.lang.Object"" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="RL" resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.surround.with.read.lock"
value="$LOCK$.readLock().lock(); try { $SELECTION$ } finally { $LOCK$.readLock().unlock(); } "
toReformat="true" toShortenFQNames="true">
<variable name="LOCK" expression="variableOfType("java.util.concurrent.locks.ReadWriteLock")" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="WL" resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.surround.with.write.lock"
value="$LOCK$.writeLock().lock(); try { $SELECTION$ } finally { $LOCK$.writeLock().unlock(); } "
toReformat="true" toShortenFQNames="true">
<variable name="LOCK" expression="variableOfType("java.util.concurrent.locks.ReadWriteLock")" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="I" value="for ($ELEMENT_TYPE$ $VAR$ : $SELECTION$) { $END$ } "
resource-bundle="messages.CodeInsightBundle" key="livetemplate.description.iter" toReformat="true" toShortenFQNames="true">
<variable name="ELEMENT_TYPE" expression="iterableComponentType(SELECTION)" defaultValue=""java.lang.Object"" alwaysStopAt="false" />
<variable name="VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
</templateSet>