use of org.eclipse.jface.text.templates.TemplateTranslator in project flux by eclipse.
the class CodeTemplateContext method evaluate.
/*
* @see org.eclipse.jdt.internal.corext.template.TemplateContext#evaluate(org.eclipse.jdt.internal.corext.template.Template)
*/
@Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
// test that all variables are defined
Iterator<TemplateVariableResolver> iterator = getContextType().resolvers();
while (iterator.hasNext()) {
TemplateVariableResolver var = iterator.next();
if (var instanceof CodeTemplateContextType.CodeTemplateVariableResolver) {
//$NON-NLS-1$ //$NON-NLS-2$
Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + "not defined");
}
}
if (!canEvaluate(template))
return null;
String pattern = changeLineDelimiter(template.getPattern(), fLineDelimiter);
TemplateTranslator translator = new TemplateTranslator();
TemplateBuffer buffer = translator.translate(pattern);
getContextType().resolve(buffer, this);
return buffer;
}
use of org.eclipse.jface.text.templates.TemplateTranslator in project KaiZen-OpenAPI-Editor by RepreZen.
the class SwaggerTemplateContext method evaluateForDisplay.
/**
* @since 2.3
*/
public TemplateBuffer evaluateForDisplay(Template template) throws BadLocationException, TemplateException {
if (!canEvaluate(template))
return null;
TemplateTranslator translator = new TemplateTranslator();
TemplateBuffer buffer = translator.translate(template);
getContextType().resolve(buffer, this);
return buffer;
}
Aggregations