Search in sources :

Example 71 with TemplateBuffer

use of org.eclipse.jface.text.templates.TemplateBuffer in project erlide_eclipse by erlang.

the class ModuleElementVariableResolver method resolve.

@Override
public void resolve(final TemplateVariable variable, final TemplateContext theContext) {
    if (reentry) {
        return;
    }
    reentry = true;
    final DocumentTemplateContext context = new DocumentTemplateContext(ErlangSourceContextTypeModule.getDefault(), new Document(fTemplate.getPattern()), 0, fTemplate.getPattern().length());
    TemplateBuffer tb;
    try {
        tb = context.evaluate(fTemplate);
        variable.setValue(tb.getString());
    } catch (final BadLocationException e) {
    } catch (final TemplateException e) {
    }
    reentry = false;
}
Also used : DocumentTemplateContext(org.eclipse.jface.text.templates.DocumentTemplateContext) TemplateException(org.eclipse.jface.text.templates.TemplateException) TemplateBuffer(org.eclipse.jface.text.templates.TemplateBuffer) Document(org.eclipse.jface.text.Document) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

TemplateBuffer (org.eclipse.jface.text.templates.TemplateBuffer)71 TemplateVariable (org.eclipse.jface.text.templates.TemplateVariable)30 BadLocationException (org.eclipse.jface.text.BadLocationException)26 TemplateException (org.eclipse.jface.text.templates.TemplateException)26 Document (org.eclipse.jface.text.Document)23 Template (org.eclipse.jface.text.templates.Template)23 Test (org.junit.Test)22 IDocument (org.eclipse.jface.text.IDocument)21 CoreException (org.eclipse.core.runtime.CoreException)17 DocumentTemplateContext (org.eclipse.jface.text.templates.DocumentTemplateContext)11 TemplateTranslator (org.eclipse.jface.text.templates.TemplateTranslator)11 TemplateContext (org.eclipse.jface.text.templates.TemplateContext)9 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)8 CodeTemplateContext (org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext)6 SimpleDateFormat (com.ibm.icu.text.SimpleDateFormat)4 CodeGenerationTemplate (org.eclipse.jdt.ls.core.internal.preferences.CodeGenerationTemplate)4 ArrayList (java.util.ArrayList)3 ITypeParameter (org.eclipse.jdt.core.ITypeParameter)3 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)3 TypeParameter (org.eclipse.jdt.core.dom.TypeParameter)3