blob: 14a56c7bc345e5c96962121d4b46e73822e3108a [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Robert Roth <robert.roth.off@gmail.com> - [templates] 2 new code templates: finally & lock - https://bugs.eclipse.org/184222
* Lars Vogel <Lars.Vogel@vogella.com> - [templates] Provide templates that check for 'null' - https://bugs.eclipse.org/131445
*******************************************************************************/
-->
<templates>
<template name="for" description="%Templates.for_array" id="org.eclipse.jdt.ui.templates.for_array" context="java-statements" enabled="true" autoinsert="false">for (int ${index} = 0; ${index} &lt; ${array}.length; ${index}++) {
${line_selection}${cursor}
}</template>
<template name="for" description="%Templates.for_temp" id="org.eclipse.jdt.ui.templates.for_temp" context="java-statements" enabled="true" autoinsert="false">for (int ${index} = 0; ${index} &lt; ${array}.length; ${index}++) {
${array_type} ${array_element} = ${array}[${index}];
${cursor}
}</template>
<template name="for" description="%Templates.for_collection" id="org.eclipse.jdt.ui.templates.for_collection" context="java-statements" enabled="true" autoinsert="false">for (${iteratorType:newType(java.util.Iterator)} ${iterator} = ${collection}.iterator(); ${iterator}.hasNext(); ) {
${type:elemType(collection)} ${name:newName(type)} = (${type}) ${iterator}.next();
${cursor}
}</template>
<template name="foreach" description="%Templates.for_iterable" id="org.eclipse.jdt.ui.templates.for_iterable" context="java-statements" enabled="true" autoinsert="false">for (${iterable_type} ${iterable_element} : ${iterable}) {
${cursor}
}</template>
<template name="formap" description="%Templates.for_map" id="org.eclipse.jdt.ui.templates.for_map" context="java-statements" enabled="true" autoinsert="false">for (Map.Entry&lt;${keyType}, ${valType}&gt; ${entry}: ${map}.entrySet()) {
${keyType} ${key} = ${entry}.getKey();
${valType} ${val} = ${entry}.getValue();
${cursor}
}</template>
<template name="while" description="%Templates.while_enumeration" id="org.eclipse.jdt.ui.templates.while_enumeration" context="java-statements" enabled="true" autoinsert="false">while (${en:var(java.util.Enumeration)}.hasMoreElements()) {
${type:argType(en)} ${elem:newName(type)} = (${type}) ${en}.nextElement();
${cursor}
}</template>
<template name="while" description="%Templates.while_iterator" id="org.eclipse.jdt.ui.templates.while_iterator" context="java-statements" enabled="true" autoinsert="false">while (${it:var(java.util.Iterator)}.hasNext()) {
${type:argType(it)} ${elem:newName(type)} = (${type}) ${it}.next();
${cursor}
}</template>
<template name="do" description="%Templates.do" id="org.eclipse.jdt.ui.templates.do" context="java-statements" enabled="true" autoinsert="false">do {
${line_selection}${cursor}
} while (${condition:var(boolean)});</template>
<template name="switch" description="%Templates.switch" id="org.eclipse.jdt.ui.templates.switch" context="java-statements" enabled="true" autoinsert="false">switch (${key}) {
case ${value}:
${cursor}
break;
default:
break;
}</template>
<template name="switch" description="%Templates.switch_labeled" id="org.eclipse.jdt.ui.templates.switch.labeled" context="java-statements" enabled="true" autoinsert="false">switch (${key}) {
case ${value} ->
${cursor}
default ->
throw new IllegalArgumentException("Unexpected value: " + ${key});
}</template>
<template name="switch" description="%Templates.switch_case_expression" id="org.eclipse.jdt.ui.templates.switch.case.expression" context="java" enabled="true" autoinsert="false">switch (${key}) {
case ${value}: {
${cursor}
yield ${type};
}
default:
throw new IllegalArgumentException("Unexpected value: " + ${key});
}</template>
<template name="switch" description="%Templates.switch_labeled_expression" id="org.eclipse.jdt.ui.templates.switch.labeled.expression" context="java" enabled="true" autoinsert="false">switch (${key}) {
case ${value} ->
${cursor}
default ->
throw new IllegalArgumentException("Unexpected value: " + ${key});
}</template>
<template name="if" description="%Templates.if" id="org.eclipse.jdt.ui.templates.if" context="java-statements" enabled="true" autoinsert="false">if (${condition:var(boolean)}) {
${line_selection}${cursor}
}</template>
<template name="ifelse" description="%Templates.ifelse" id="org.eclipse.jdt.ui.templates.ifelse" context="java-statements" enabled="true" autoinsert="false">if (${condition:var(boolean)}) {
${cursor}
} else {
}</template>
<template name="elseif" description="%Templates.elseif" id="org.eclipse.jdt.ui.templates.elseif" context="java-statements" enabled="true" autoinsert="false">else if (${condition:var(boolean)}) {
${cursor}
}</template>
<template name="else" description="%Templates.else" id="org.eclipse.jdt.ui.templates.else" context="java-statements" enabled="true" autoinsert="false">else {
${cursor}
}</template>
<template name="ifNull" description="%Templates.ifnull" id="org.eclipse.jdt.ui.templates.ifnull" context="java-statements" enabled="true" autoinsert="false">if (${name:var} == null) {
${cursor}
}</template>
<template name="ifNotNull" description="%Templates.ifnotnull" id="org.eclipse.jdt.ui.templates.ifnotnull" context="java-statements" enabled="true" autoinsert="false">if (${name:var} != null) {
${cursor}
}</template>
<template name="try_catch" description="%Templates.try" id="org.eclipse.jdt.ui.templates.try" context="java-statements" enabled="true" autoinsert="false">try {
${line_selection}${cursor}
} catch (${Exception} ${exception_variable_name}) {
// ${todo}: handle exception
}</template>
<template name="try_finally" description="%Templates.tryfinally" id="org.eclipse.jdt.ui.templates.tryfinally" context="java-statements" enabled="true" autoinsert="false">try {
${line_selection}${cursor}
} finally {
// ${todo}: handle finally clause
}</template>
<template name="catch" description="%Templates.catch" id="org.eclipse.jdt.ui.templates.catch" context="java-statements" enabled="true" autoinsert="false">catch (${Exception} ${exception_variable_name}) {
${cursor}// ${todo}: handle exception
}</template>
<template name="finally" description="%Templates.finally" id="org.eclipse.jdt.ui.templates.finally" context="java-statements" enabled="true" autoinsert="false">finally {
${cursor}
}</template>
<template name="main" description="%Templates.main" id="org.eclipse.jdt.ui.templates.main" context="java-members" enabled="true" autoinsert="false">public static void main(String[] args) {
${cursor}
}</template>
<template name="public_method" description="%Templates.public_method" id="org.eclipse.jdt.ui.templates.public_method" context="java-members" enabled="true" autoinsert="false">public ${void} ${name}(${}) {
${cursor}
}</template>
<template name="public_static_method" description="%Templates.public_static_method" id="org.eclipse.jdt.ui.templates.public_static_method" context="java-members" enabled="true" autoinsert="false">public static ${void} ${name}(${}) {
${cursor}
}</template>
<template name="protected_method" description="%Templates.protected_method" id="org.eclipse.jdt.ui.templates.protected_method" context="java-members" enabled="true" autoinsert="false">protected ${void} ${name}(${}) {
${cursor}
}</template>
<template name="private_method" description="%Templates.private_method" id="org.eclipse.jdt.ui.templates.private_method" context="java-members" enabled="true" autoinsert="false">private ${void} ${name}(${}) {
${cursor}
}</template>
<template name="private_static_method" description="%Templates.private_static_method" id="org.eclipse.jdt.ui.templates.private_static_method" context="java-members" enabled="true" autoinsert="false">private static ${void} ${name}(${}) {
${cursor}
}</template>
<template name="instanceof" description="%Templates.instanceof" id="org.eclipse.jdt.ui.templates.instanceof" context="java-statements" enabled="true" autoinsert="false">if (${name:var} instanceof ${type}) {
${type} ${new_name} = (${type})${name};
${cursor}
}</template>
<template name="cast" description="%Templates.cast" id="org.eclipse.jdt.ui.templates.cast" context="java-statements" enabled="true" autoinsert="false">${type} ${new_name} = (${type}) ${name};</template>
<template name="new" description="%Templates.new" id="org.eclipse.jdt.ui.templates.new" context="java" enabled="true" autoinsert="false">${type} ${name} = new ${type}(${});</template>
<template name="lazy" description="%Templates.lazy" id="org.eclipse.jdt.ui.templates.lazy" context="java-statements" enabled="true" autoinsert="false">if (${name:var} == null) {
${name} = new ${type}(${arguments});
${cursor}
}
return ${name};</template>
<template name="toarray" description="%Templates.toarray" id="org.eclipse.jdt.ui.templates.toarray" context="java" enabled="true" autoinsert="false">(${type:elemType(collection)}[]) ${collection}.toArray(new ${type}[${collection}.size()])</template>
<template name="sysout" description="%Templates.sysout" id="org.eclipse.jdt.ui.templates.sysout" context="java-statements" enabled="true" autoinsert="true">System.out.println(${word_selection}${});${cursor}</template>
<template name="syserr" description="%Templates.syserr" id="org.eclipse.jdt.ui.templates.syserr" context="java-statements" enabled="true" autoinsert="true">System.err.println(${word_selection}${});${cursor}</template>
<template name="systrace" description="%Templates.systrace" id="org.eclipse.jdt.ui.templates.systrace" context="java-statements" enabled="true" autoinsert="true">System.out.println(&quot;${enclosing_type}.${enclosing_method}()&quot;);</template>
<template name="&lt;code&gt;" description="%Templates.code_tag" id="org.eclipse.jdt.ui.templates.code_tag" context="javadoc" enabled="true" autoinsert="true">&lt;code&gt;${word_selection}${}&lt;/code&gt;${cursor}</template>
<template name="null" description="%Templates.code_tag_null" id="org.eclipse.jdt.ui.templates.code_tag_null" context="javadoc" enabled="true" autoinsert="true">&lt;code&gt;null&lt;/code&gt;</template>
<template name="true" description="%Templates.code_tag_true" id="org.eclipse.jdt.ui.templates.code_tag_true" context="javadoc" enabled="true" autoinsert="true">&lt;code&gt;true&lt;/code&gt;</template>
<template name="false" description="%Templates.code_tag_false" id="org.eclipse.jdt.ui.templates.code_tag_false" context="javadoc" enabled="true" autoinsert="true">&lt;code&gt;false&lt;/code&gt;</template>
<template name="&lt;pre&gt;" description="%Templates.pre_tag" id="org.eclipse.jdt.ui.templates.pre_tag" context="javadoc" enabled="true" autoinsert="true">&lt;pre&gt;${word_selection}${}&lt;/pre&gt;${cursor}</template>
<template name="&lt;b&gt;" description="%Templates.b_tag" id="org.eclipse.jdt.ui.templates.b_tag" context="javadoc" enabled="true" autoinsert="true">&lt;b&gt;${word_selection}${}&lt;/b&gt;${cursor}</template>
<template name="&lt;i&gt;" description="%Templates.i_tag" id="org.eclipse.jdt.ui.templates.i_tag" context="javadoc" enabled="true" autoinsert="true">&lt;i&gt;${word_selection}${}&lt;/i&gt;${cursor}</template>
<template name="@author" description="%Templates.author" id="org.eclipse.jdt.ui.templates.author" context="javadoc" enabled="true" autoinsert="true">@author ${user}</template>
<template name="while" description="%Templates.while_condition" id="org.eclipse.jdt.ui.templates.while_condition" context="java-statements" enabled="true" autoinsert="false">while (${condition:var(boolean)}) {
${line_selection}${cursor}
}</template>
<template name="test3" description="%Templates.test" id="org.eclipse.jdt.ui.templates.test" context="java-members" enabled="true" autoinsert="false">public void test${name}() throws Exception {
${cursor}
}</template>
<template name="test4" description="%Templates.test_junit4" id="org.eclipse.jdt.ui.templates.test_junit4" context="java-members" enabled="true" autoinsert="false">@${testType:newType(org.junit.Test)}
public void ${testName}() throws Exception {
${staticImport:importStatic('org.junit.Assert.*')}${cursor}
}</template>
<template name="test_jupiter" description="%Templates.test_junit5" id="org.eclipse.jdt.ui.templates.test_junit5" context="java-members" enabled="true" autoinsert="false">@${testType:newType(org.junit.jupiter.api.Test)}
void ${testName}() throws Exception {
${staticImport:importStatic('org.junit.jupiter.api.Assertions.*')}${cursor}
}</template>
<template name="test_factory" description="%Templates.testfactory_junit5" id="org.eclipse.jdt.ui.templates.testfactory_junit5" context="java-members" enabled="true" autoinsert="false">@${testfactoryType:newType(org.junit.jupiter.api.TestFactory)}
${returnType:link('DynamicNode', 'Stream&lt;DynamicNode&gt;', 'Collection&lt;DynamicNode&gt;', 'Iterable&lt;DynamicNode&gt;', 'Iterator&lt;DynamicNode&gt;', 'DynamicNode[]')} ${testFactoryName}() throws Exception {
// ${todo}: generate dynamic test cases
${cursor}return null;${typeImports:import('org.junit.jupiter.api.DynamicNode')}${staticImports:importStatic('org.junit.jupiter.api.Assertions.*', 'org.junit.jupiter.api.DynamicContainer.*', 'org.junit.jupiter.api.DynamicTest.*')}
}</template>
<template name="nls" description="%Templates.non-nls" id="org.eclipse.jdt.ui.templates.non-nls" context="java" enabled="true" autoinsert="false">//$$NON-NLS-${N}$$</template>
<template name="fall-through" description="%Templates.fall-through" id="org.eclipse.jdt.ui.templates.fall-through" context="java-statements" enabled="true" autoinsert="false">//$$FALL-THROUGH$$</template>
<template name="synchronized" description="%Templates.synchronized" id="org.eclipse.jdt.ui.templates.synchronized" context="java-statements" enabled="true" autoinsert="false">synchronized (${mutex:var}) {
${line_selection}
}</template>
<template name="lock" description="%Templates.lock" id="org.eclipse.jdt.ui.templates.lock" context="java-statements" enabled="true" autoinsert="false">${lock:var(java.util.concurrent.locks.Lock)}.lock();
try {
${line_selection}${cursor}
} finally {
${lock}.unlock();
}</template>
<template name="runnable" description="%Templates.runnable" id="org.eclipse.jdt.ui.templates.runnable" context="java" enabled="true" autoinsert="false">new Runnable() {
public void run() {
${line_selection}
}
}</template>
<template name="arraymerge" description="%Templates.arraymerge" id="org.eclipse.jdt.ui.templates.arraymerge" context="java-statements" enabled="true" autoinsert="false">${array_type}[] ${result:newName(array1)} = new ${array_type}[${array1:array}.length + ${array}.length];
System.arraycopy(${array1}, 0, ${result}, 0, ${array1}.length);
System.arraycopy(${array}, 0, ${result}, ${array1}.length, ${array}.length);</template>
<template name="arrayadd" description="%Templates.arrayadd" id="org.eclipse.jdt.ui.templates.arrayadd" context="java-statements" enabled="true" autoinsert="false">${array_type}[] ${result:newName(array)} = new ${array_type}[${array}.length + 1];
System.arraycopy(${array}, 0, ${result}, 0, ${array}.length);
${result}[${array}.length]= ${var};</template>
<template name="static_final" description="%Templates.static_final" id="org.eclipse.jdt.ui.templates.static_final" context="java-members" enabled="true" autoinsert="false">${visibility:link('public ','protected ','','private ')}static final ${type:link(String,int)} ${NAME} = ${expr:link('""',0)};</template>
<template name="new_module" description="%Templates.new_module" id="org.eclipse.jdt.ui.templates.new_module" context="module" enabled="true" autoinsert="false">module ${name} {
${cursor}
}</template>
<template name="new_class" description="%Templates.new_class" id="org.eclipse.jdt.ui.templates.new_class" context="java-empty" enabled="true" autoinsert="false">package ${enclosing_package};
public class ${primary_type_name} ${cursor} {
}</template>
<template name="new_iface" description="%Templates.new_iface" id="org.eclipse.jdt.ui.templates.new_iface" context="java-empty" enabled="true" autoinsert="false">package ${enclosing_package};
public interface ${primary_type_name} ${cursor} {
}</template>
<template name="new_enum" description="%Templates.new_enum" id="org.eclipse.jdt.ui.templates.new_enum" context="java-empty" enabled="true" autoinsert="false">package ${enclosing_package};
public enum ${primary_type_name} ${cursor} {
}</template>
<template name="new_record" description="%Templates.new_record" id="org.eclipse.jdt.ui.templates.new_record" context="java-empty" enabled="true" autoinsert="false">package ${enclosing_package};
public record ${primary_type_name}(${cursor}) {
}</template>
</templates>