Search in sources :

Example 6 with Variable

use of org.eclipse.xtext.ui.codetemplates.templates.Variable in project xtext-eclipse by eclipse.

the class TemplateValidator method checkTemplate.

@Check
public void checkTemplate(TemplateBody template) {
    EList<TemplatePart> parts = template.getParts();
    boolean cursorDefined = false;
    for (TemplatePart templatePart : parts) {
        if (templatePart instanceof Variable) {
            if ("cursor".equals(((Variable) templatePart).getName())) {
                if (cursorDefined) {
                    warning("More than one cursor was defined", templatePart, TemplatesPackage.Literals.VARIABLE__NAME);
                } else {
                    cursorDefined = true;
                }
            }
        }
    }
}
Also used : TemplatePart(org.eclipse.xtext.ui.codetemplates.templates.TemplatePart) Variable(org.eclipse.xtext.ui.codetemplates.templates.Variable) Check(org.eclipse.xtext.validation.Check)

Aggregations

Variable (org.eclipse.xtext.ui.codetemplates.templates.Variable)6 Codetemplate (org.eclipse.xtext.ui.codetemplates.templates.Codetemplate)3 Codetemplates (org.eclipse.xtext.ui.codetemplates.templates.Codetemplates)3 TemplateBody (org.eclipse.xtext.ui.codetemplates.templates.TemplateBody)3 EPackage (org.eclipse.emf.ecore.EPackage)2 ContextTypeRegistry (org.eclipse.jface.text.templates.ContextTypeRegistry)2 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)2 TemplateVariableResolver (org.eclipse.jface.text.templates.TemplateVariableResolver)2 Action (org.eclipse.xtext.Action)2 Parameter (org.eclipse.xtext.Parameter)2 ParserRule (org.eclipse.xtext.ParserRule)2 Dollar (org.eclipse.xtext.ui.codetemplates.templates.Dollar)2 Literal (org.eclipse.xtext.ui.codetemplates.templates.Literal)2 TemplatePart (org.eclipse.xtext.ui.codetemplates.templates.TemplatePart)2 ContextTypeIdHelper (org.eclipse.xtext.ui.editor.templates.ContextTypeIdHelper)2 ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)1 CharStream (org.antlr.runtime.CharStream)1 EObject (org.eclipse.emf.ecore.EObject)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 StyledString (org.eclipse.jface.viewers.StyledString)1