Skip to content

Commit 3bfb7bb

Browse files
committed
Update on the JDT templates
1 parent 1744de0 commit 3bfb7bb

File tree

3 files changed

+19
-155
lines changed

3 files changed

+19
-155
lines changed

com.vogella.jdt.templates/plugin.xml

Lines changed: 0 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -6,164 +6,13 @@
66
<!-- =========================================================================== -->
77
<extension
88
point="org.eclipse.ui.editors.templates">
9-
<contextTypeRegistry
10-
id="org.eclipse.jdt.ui.CompilationUnitEditor">
11-
</contextTypeRegistry>
12-
<contextType
13-
name="Java ContextType"
14-
class="org.eclipse.jdt.internal.corext.template.java.JavaContextType"
15-
id="java"
16-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
17-
</contextType>
18-
<contextType
19-
name="Statements"
20-
class="org.eclipse.jdt.internal.corext.template.java.JavaContextType"
21-
id="java-statements"
22-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
23-
</contextType>
24-
<contextType
25-
name="Members"
26-
class="org.eclipse.jdt.internal.corext.template.java.JavaContextType"
27-
id="java-members"
28-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
29-
</contextType>
30-
<contextType
31-
name="SWT Context Type"
32-
class="org.eclipse.jdt.internal.corext.template.java.SWTContextType"
33-
id="swt"
34-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
35-
</contextType>
36-
<contextType
37-
name="SWT Statements"
38-
class="org.eclipse.jdt.internal.corext.template.java.SWTContextType"
39-
id="swt-statements"
40-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
41-
</contextType>
42-
<contextType
43-
name="SWT Members"
44-
class="org.eclipse.jdt.internal.corext.template.java.SWTContextType"
45-
id="swt-members"
46-
registryId="org.eclipse.jdt.ui.CompilationUnitEditor">
47-
</contextType>
489
<include
4910
file="templates/additional-swttemplates.xml"
5011
>
5112
</include>
5213
<include
5314
file="templates/additional-templates.xml">
5415
</include>
55-
<resolver
56-
class="org.eclipse.jdt.internal.corext.template.java.LocalVarResolver"
57-
contextTypeId="e4-members"
58-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:localVar(type[,type]*)}&lt;/b&gt;&lt;br&gt;Evaluates
59-
to a local variable or parameter visible in the current scope that is
60-
a subtype of any of the given types. If no type is specified, any
61-
non-primitive local variable
62-
matches.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${iterable:localVar(java.lang.Iterable)}&lt;/code&gt;"
63-
name="Local Variable"
64-
type="localVar"/>
65-
<resolver
66-
class="org.eclipse.jdt.internal.corext.template.java.VarResolver"
67-
contextTypeId="e4-members"
68-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:var(type[,type]*)}&lt;/b&gt;&lt;br&gt;Evaluates
69-
to a field, local variable or parameter visible in the current scope
70-
that is a subtype of any of the given types. If no type is specified,
71-
any non-primitive variable
72-
matches.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${array:var(&apos;java.lang.Object[]&apos;)}&lt;/code&gt;"
73-
name="Variable"
74-
type="var"/>
75-
<resolver
76-
class="org.eclipse.jdt.internal.corext.template.java.NameResolver"
77-
contextTypeId="e4-members"
78-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:newName(reference)}&lt;/b&gt;&lt;br&gt;Evaluates
79-
to an non-conflicting name for a new local variable of the type
80-
specified by the reference. The reference may either be a Java type
81-
name or the name of another template variable. The generated name
82-
respects the code style
83-
settings.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${index:newName(int)}&lt;/code&gt;
84-
"
85-
name="New Name"
86-
type="newName"/>
87-
<resolver
88-
class="org.eclipse.jdt.internal.corext.template.java.TypeResolver"
89-
contextTypeId="e4-members"
90-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:newType(fullyQualifiedType)}&lt;/b&gt;&lt;br&gt;Evaluates
91-
to a type name given the fully qualified Java type name. Evaluates to
92-
a simple type name and an import if no conflicting type exists.
93-
Evaluates to a fully qualified type name
94-
otherwise.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${type:newType(java.util.Iterator)}&lt;/code&gt;"
95-
name="New Type"
96-
type="newType"/>
97-
<resolver
98-
class="org.eclipse.jdt.internal.corext.template.java.ElementTypeResolver"
99-
contextTypeId="e4-members"
100-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:elemType(variable)}&lt;/b&gt;&lt;br&gt;Evaluates
101-
to the element type of the referenced template variable. The reference
102-
should be the name of another template variable that resolves to an
103-
array or an instance of
104-
&lt;code&gt;java.lang.Iterable&lt;/code&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${t:elemType(a)}
105-
elem = ${a:array};&lt;/code&gt;"
106-
name="Element Type"
107-
type="elemType"/>
108-
<resolver
109-
class="org.eclipse.jdt.internal.corext.template.java.TypeVariableResolver"
110-
contextTypeId="e4-members"
111-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:argType(variable,
112-
n)}&lt;/b&gt;&lt;br&gt; Evaluates to the &lt;em&gt;nth&lt;/em&gt; type
113-
argument of the referenced template variable. The reference should be
114-
the name of another template variable. Resolves to
115-
&lt;code&gt;java.lang.Object&lt;/code&gt; if the referenced variable
116-
cannot be found or is not a parameterized
117-
type.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${type:argType(vector,
118-
0)} ${first:name(type)} =
119-
${vector:var(java.util.Vector)}.get(0);&lt;/code&gt;;"
120-
name="Argument Type"
121-
type="argType"/>
122-
<resolver
123-
class="org.eclipse.jdt.internal.corext.template.java.LinkResolver"
124-
contextTypeId="e4-members"
125-
description="&lt;b&gt;${&lt;i&gt;id&lt;/i&gt;:link([proposal[,proposal]*])}&lt;/b&gt;&lt;br&gt;Evaluates
126-
to &lt;i&gt;id&lt;/i&gt; if the list of proposals is empty, evaluates
127-
to the first proposal otherwise. The evaluated value is put into
128-
linked mode. A proposal window shows all the given
129-
proposals.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example1:&lt;/b&gt;&lt;br&gt;&lt;code&gt;java.util.Collections.${kind:link(EMPTY_SET,
130-
EMPTY_LIST, &apos;EMPTY_MAP.entrySet()&apos;)}&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Example2:&lt;/b&gt;&lt;br&gt;&lt;code&gt;int
131-
${integer:link}; ${integer}= 0;&lt;/code&gt;"
132-
name="Linked Mode"
133-
type="link"/>
134-
<resolver
135-
class="org.eclipse.jdt.internal.corext.template.java.ImportsResolver"
136-
contextTypeId="e4-members"
137-
description="&lt;b&gt;${:import([type[,type]*])}&lt;/b&gt;&lt;br&gt;Adds
138-
an import statement for each type that is not already imported. Does
139-
nothing if a conflicting import exists. Evaluates to
140-
nothing.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${:import(java.util.List,
141-
java.util.Collection)}&lt;/code&gt;
142-
"
143-
name="Import"
144-
type="import"/>
145-
<resolver
146-
class="org.eclipse.jdt.internal.corext.template.java.StaticImportResolver"
147-
contextTypeId="e4-members"
148-
description="&lt;b&gt;${:importStatic([qualifiedName[,qualifiedName]*])}&lt;/b&gt;&lt;br&gt;Adds
149-
a static import statement for each qualified name that is not already
150-
imported. The &lt;code&gt;qualifiedName&lt;/code&gt; is the fully
151-
qualified name of a static field or method, or it is the qualified
152-
name of a type plus a &lt;code&gt;.*&lt;/code&gt; suffix, enclosed in
153-
single quotes &lt;code&gt;&apos;\u0027&lt;/code&gt;. Does nothing if a
154-
conflicting import exists. Evaluates to
155-
nothing.&lt;br&gt;&lt;br&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br&gt;&lt;code&gt;${:importStatic(java.util.Collections.EMPTY_SET,
156-
&apos;java.lang.System.*&apos;)}&lt;/code&gt;
157-
"
158-
name="Import Static"
159-
type="importStatic"/>
160-
<resolver
161-
class="org.eclipse.jdt.internal.corext.template.java.ExceptionVariableNameResolver"
162-
contextTypeId="e4-members"
163-
description="Exception variable name in catch blocks"
164-
name="Exception Variable Name"
165-
type="exception_variable_name">
166-
</resolver>
16716
</extension>
16817

16918
</plugin>

com.vogella.jdt.templates/templates/additional-swttemplates.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<!--
44
/*******************************************************************************
5-
* Copyright (c) 2012 vogella GmbH and others.
5+
* Copyright (c) 2012, 2014 vogella GmbH and others.
66
* All rights reserved. This program and the accompanying materials
77
* are made available under the terms of the Eclipse Public License v1.0
88
* which accompanies this distribution, and is available at
99
* http://www.eclipse.org/legal/epl-v10.html
1010
*
1111
* Contributors:
12-
* Lars Vogel <lars.vogel@gmail.com> - initial API and implementation
12+
* Lars Vogel <lars.vogel@vogella.com> - initial API and implementation
1313
*******************************************************************************/
1414
-->
1515

com.vogella.jdt.templates/templates/additional-templates.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<!-- /*******************************************************************************
4-
* Copyright (c) 2012 vogella GmbH and others. * All rights reserved. This
4+
* Copyright (c) 2012, 2014 vogella GmbH and others. * All rights reserved. This
55
program and the accompanying materials * are made available under the terms
66
of the Eclipse Public License v1.0 * which accompanies this distribution,
77
and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:
@@ -16,6 +16,12 @@
1616
enabled="true" autoinsert="false">
1717
${variabletype} ${myvar:newName(var)}= new ${variabletype}(${cursor});
1818
</template>
19+
20+
<template name="string" description="String (empty)"
21+
id="org.eclipse.jdt.ui.templates.emptystring" context="java-statements"
22+
enabled="true" autoinsert="false">
23+
String ${myvar:newName(var)}= "";
24+
</template>
1925

2026

2127
<template name="ifnotnull" description="If not null"
@@ -29,11 +35,20 @@
2935
<template name="arrayexample" description="Creates an Array with some example content"
3036
id="org.eclipse.jdt.ui.templates.arrayexample" context="java-statements"
3137
enabled="true" autoinsert="false">
32-
String[] input =
38+
String[] ${myvar:newName(var)} =
3339
new String[]{"Windows 7", "MacOS", "Debian", "Ubuntu", "Redhat",
3440
"Android", "iPhone", "Suse", "Windows XP", "Windows Mobile", "OS/2", "WebOS"};
3541
</template>
3642

43+
<template name="readinputstream"
44+
description="Creates method to read a file"
45+
id="org.eclipse.jdt.ui.templates.readinputsteam"
46+
context="java-members" enabled="true"
47+
autoinsert="false">private String ${readInputStream}(${}) {
48+
${cursor}
49+
}
50+
</template>
51+
3752

3853

3954

0 commit comments

Comments
 (0)