Yes, in fact, you can and there is an example on the right in the default set.
If you go to your settings -> Java -> Code Style -> Code Templates, you can Export all the provided Java templates. There you will see the following file template (formatted for readability):
<template autoinsert="true" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment"> /** * */ </template>
and a little further down, a new type that uses this file template:
<template autoinsert="true" context="newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.newtype" name="newtype"> ${filecomment} ${package_declaration} ${typecomment} ${type_declaration} </template>
So, if you want the template to use another, the main form is to refer to the identifier of your subpattern with the dollar sign prefix. For example:
<template autoinsert="true" context="BobOuter_context" deleted="false" description="Bob example outer template" enabled="true" id="bob.example.outertemplate" name="BobOuter"> BobOuterBegins Insert inner template ${bob.example.innertemplate} BobOuterEnds </template> <template autoinsert="true" context="BobInner_context" deleted="false" description="Bob example inner template" enabled="true" id="bob.example.innertemplate" name="BobInner"> BobInnerBegins Super awesome content goes here BobInnerEnds </template>
Bob cross
source share