Szablon edytora

org.eclipse.ui.editors.templates

3.0

Szablony to fragmenty tekstu lub kodu, które pomagają użytkownikowi we wprowadzaniu powtarzających się wzorców w edytorze tekstu. Szablony mogą zawierać zmienne, które są interpretowane w kontekście, w którym wstawiany jest szablon.

<!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>

Typ kontekstu definiuje kontekst, w którym wartościowane są szablony. Do interpretacji szablonu typ kontekstu używa własnych procedur tłumaczących.



<!ELEMENT resolver EMPTY>

<!ATTLIST resolver

contextTypeId CDATA #REQUIRED

type          CDATA #REQUIRED

class         CDATA #REQUIRED

description   CDATA #IMPLIED

name          CDATA #IMPLIED

icon          CDATA #IMPLIED>

Procedura tłumacząca zmienne szablonu może zinterpretować zmienną szablonu w określonym kontekście.



<!ELEMENT template (pattern)>

<!ATTLIST template

id            CDATA #REQUIRED

contextTypeId CDATA #REQUIRED

name          CDATA #REQUIRED

description   CDATA #IMPLIED

icon          CDATA #IMPLIED

autoinsert    (true | false) "true">

Szablon jest fragmentem kodu lub tekstu, który będzie wartościowany w podanym kontekście. Zmienne, które będą interpretowane w tym kontekście, można określać przy użyciu notacji ${typ_zmiennej}.



<!ELEMENT pattern (#PCDATA)>

Wzorzec szablonu.



<!ELEMENT include EMPTY>

<!ATTLIST include

file         CDATA #REQUIRED

translations CDATA #IMPLIED>

Ten element umożliwia dołączenie kolekcji szablonów zapisanych w formacie XML jako całości.



   

<extension point=

"org.eclipse.ui.editors.templates"

>

<template name=

"%ant.tasks.javac.name"

contextTypeId=

"org.eclipse.ui.examples.templateeditor.antcontext"

id=

"org.eclipse.ui.examples.templateeditor.templates.javac"

description=

"%ant.tasks.javac.description"

>

<pattern>

<javac srcdir=

"${src}"

destdir=

"${dst}"

classpath=

"${classpath}"

debug=

"${debug}"

/>

</pattern>

</template>

<resolver contextTypeId=

"org.eclipse.ui.examples.templateeditor.antcontext"

type=

"src"

class=

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

>

</resolver>

<resolver contextTypeId=

"org.eclipse.ui.examples.templateeditor.antcontext"

type=

"dst"

class=

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

>

</resolver>

</extension>

Odpowiedni interfejs API można znaleźć w pakiecie org.eclipse.jface.text.template w module dodatkowym org.eclipse.text.

Odpowiednie klasy można znaleźć w pakiecie org.eclipse.jface.text.templates w module dodatkowym org.eclipse.text.