Search in sources :

Example 11 with MacroCallNode

use of com.intellij.codeInsight.template.impl.MacroCallNode in project intellij-community by JetBrains.

the class XmlTagInsertHandler method completeTagTail.

private static void completeTagTail(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context, boolean firstLevel) {
    boolean completeIt = !firstLevel || descriptor.getAttributesDescriptors(null).length == 0;
    switch(descriptor.getContentType()) {
        case XmlElementDescriptor.CONTENT_TYPE_UNKNOWN:
            return;
        case XmlElementDescriptor.CONTENT_TYPE_EMPTY:
            if (completeIt) {
                template.addTextSegment("/>");
            }
            break;
        case XmlElementDescriptor.CONTENT_TYPE_MIXED:
            if (completeIt) {
                template.addTextSegment(">");
                if (firstLevel) {
                    template.addEndVariable();
                } else {
                    template.addVariable(new MacroCallNode(new CompleteMacro()), true);
                }
                addTagEnd(template, descriptor, context);
            }
            break;
        default:
            if (!addRequiredSubTags(template, descriptor, file, context)) {
                if (completeIt) {
                    template.addTextSegment(">");
                    template.addEndVariable();
                    addTagEnd(template, descriptor, context);
                }
            }
            break;
    }
}
Also used : MacroCallNode(com.intellij.codeInsight.template.impl.MacroCallNode) CompleteMacro(com.intellij.codeInsight.template.macro.CompleteMacro)

Aggregations

MacroCallNode (com.intellij.codeInsight.template.impl.MacroCallNode)11 CompleteMacro (com.intellij.codeInsight.template.macro.CompleteMacro)5 SuggestVariableNameMacro (com.intellij.codeInsight.template.macro.SuggestVariableNameMacro)5 Template (com.intellij.codeInsight.template.Template)4 TemplateBuilderImpl (com.intellij.codeInsight.template.TemplateBuilderImpl)4 TemplateManager (com.intellij.codeInsight.template.TemplateManager)4 Project (com.intellij.openapi.project.Project)3 PsiElement (com.intellij.psi.PsiElement)3 Expression (com.intellij.codeInsight.template.Expression)2 Editor (com.intellij.openapi.editor.Editor)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 TextRange (com.intellij.openapi.util.TextRange)2 PsiReference (com.intellij.psi.PsiReference)2 XmlAttribute (com.intellij.psi.xml.XmlAttribute)2 XmlTag (com.intellij.psi.xml.XmlTag)2 TypeExpression (com.intellij.codeInsight.intention.impl.TypeExpression)1 TextExpression (com.intellij.codeInsight.template.impl.TextExpression)1 VariableNode (com.intellij.codeInsight.template.impl.VariableNode)1 CompleteSmartMacro (com.intellij.codeInsight.template.macro.CompleteSmartMacro)1 IterableComponentTypeMacro (com.intellij.codeInsight.template.macro.IterableComponentTypeMacro)1