Editor Template

org.eclipse.ui.editors.templates

3.0

Templates are snippets of text or code which help the user enter reoccurring patterns into a text editor. Templates may contain variables which are resolved in the context where the template is inserted.

<!ELEMENT extension (template* , resolver* , contextType* , include*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT contextType EMPTY>

<!ATTLIST contextType

id    CDATA #REQUIRED

class CDATA #REQUIRED

name  CDATA #IMPLIED>

A context type defines a context within which templates are evaluated. A context type uses its resolvers to resolve a template.



<!ELEMENT resolver EMPTY>

<!ATTLIST resolver

contextTypeId CDATA #REQUIRED

type          CDATA #REQUIRED

class         CDATA #REQUIRED

description   CDATA #IMPLIED

name          CDATA #IMPLIED

icon          CDATA #IMPLIED>

A template variable resolver can resolve a template variable in a certain context.



<!ELEMENT template (pattern)>

<!ATTLIST template

id            CDATA #REQUIRED

contextTypeId CDATA #REQUIRED

name          CDATA #REQUIRED

description   CDATA #IMPLIED

icon          CDATA #IMPLIED>

A template is a snippet of code or text that will be evaluated in a given context. Variables which will be resolved in that context can be specified using the ${variable_type} notation.



<!ELEMENT pattern (#CDATA)>

The template pattern.



<!ELEMENT include EMPTY>

<!ATTLIST include

file         CDATA #REQUIRED

translations CDATA #IMPLIED>

A collection of templates encoded as XML can be included as a whole via this element.



   

<extension point=

"org.eclipse.ui.examples.templateeditor.template"

>

<template name=

"javac"

context=

"ant"

editorId=

"org.eclipse.ui.examples.templateeditor.editors.TemplateEditor"

description=

"%ant.tasks.javac.description"

>

<pattern>

<javac srcdir=

"${src}"

destdir=

"${dst}"

classpath=

"${classpath}"

debug=

"${debug}"

/>

</pattern>

</template>

<resolver context=

"ant"

type=

"src"

editorId=

"org.eclipse.ui.examples.templateeditor.editors.TemplateEditor"

class=

"org.eclipse.ui.examples.templateeditor.editors.AntVariableResolver"

>

</resolver>

<resolver context=

"ant"

type=

"dst"

editorId=

"org.eclipse.ui.examples.templateeditor.editors.TemplateEditor"

class=

"org.eclipse.ui.examples.templateeditor.editors.AntVariableResolver"

>

</resolver>

</extension>

See the org.eclipse.jface.text.templates package in the org.eclipse.text plug-in for the relevant API.

See the org.eclipse.jface.text.templates package in the org.eclipse.text plug-in for the relevant classes.