Search in sources :

Example 6 with EvaluatedXmlName

use of com.intellij.util.xml.EvaluatedXmlName in project intellij-community by JetBrains.

the class DomSemContributor method findChildrenDescription.

@Nullable
private static <T extends DomChildrenDescription> T findChildrenDescription(List<T> descriptions, XmlTag tag, DomInvocationHandler parent) {
    final String localName = tag.getLocalName();
    String namespace = null;
    final String qName = tag.getName();
    final XmlFile file = parent.getFile();
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = descriptions.size(); i < size; i++) {
        final T description = descriptions.get(i);
        final XmlName xmlName = description.getXmlName();
        if (localName.equals(xmlName.getLocalName()) || qName.equals(xmlName.getLocalName())) {
            final EvaluatedXmlName evaluatedXmlName = parent.createEvaluatedXmlName(xmlName);
            if (DomImplUtil.isNameSuitable(evaluatedXmlName, localName, qName, namespace == null ? namespace = tag.getNamespace() : namespace, file)) {
                return description;
            }
        }
    }
    return null;
}
Also used : EvaluatedXmlName(com.intellij.util.xml.EvaluatedXmlName) XmlFile(com.intellij.psi.xml.XmlFile) EvaluatedXmlName(com.intellij.util.xml.EvaluatedXmlName) XmlName(com.intellij.util.xml.XmlName) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with EvaluatedXmlName

use of com.intellij.util.xml.EvaluatedXmlName in project intellij-community by JetBrains.

the class IndexedElementInvocationHandler method undefineInternal.

@Override
public void undefineInternal() {
    final DomInvocationHandler parent = getParentHandler();
    assert parent != null : "write operations should be performed on the DOM having a parent, your DOM may be not very fresh";
    final XmlTag parentTag = parent.getXmlTag();
    if (parentTag == null)
        return;
    final EvaluatedXmlName xmlElementName = getXmlName();
    final FixedChildDescriptionImpl description = getChildDescription();
    final int totalCount = description.getCount();
    final List<XmlTag> subTags = DomImplUtil.findSubTags(parentTag, xmlElementName, getFile());
    if (subTags.size() <= myIndex) {
        return;
    }
    XmlTag tag = getXmlTag();
    if (tag == null)
        return;
    final boolean changing = getManager().setChanging(true);
    try {
        detach();
        if (totalCount == myIndex + 1 && subTags.size() >= myIndex + 1) {
            for (int i = myIndex; i < subTags.size(); i++) {
                subTags.get(i).delete();
            }
        } else if (subTags.size() == myIndex + 1) {
            tag.delete();
        } else {
            setXmlElement((XmlTag) tag.replace(parent.createChildTag(getXmlName())));
        }
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    } finally {
        getManager().setChanging(changing);
    }
    fireUndefinedEvent();
}
Also used : EvaluatedXmlName(com.intellij.util.xml.EvaluatedXmlName) IncorrectOperationException(com.intellij.util.IncorrectOperationException) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

EvaluatedXmlName (com.intellij.util.xml.EvaluatedXmlName)7 XmlTag (com.intellij.psi.xml.XmlTag)4 XmlFile (com.intellij.psi.xml.XmlFile)3 XmlName (com.intellij.util.xml.XmlName)3 DomElement (com.intellij.util.xml.DomElement)2 CustomDomChildrenDescription (com.intellij.util.xml.reflect.CustomDomChildrenDescription)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 NullableComputable (com.intellij.openapi.util.NullableComputable)1 RecursionGuard (com.intellij.openapi.util.RecursionGuard)1 PomTarget (com.intellij.pom.PomTarget)1 PsiElement (com.intellij.psi.PsiElement)1 XmlElementType (com.intellij.psi.xml.XmlElementType)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 EvaluatedXmlNameImpl (com.intellij.util.xml.EvaluatedXmlNameImpl)1 AttributeChildDescriptionImpl (com.intellij.util.xml.impl.AttributeChildDescriptionImpl)1 AbstractDomChildrenDescription (com.intellij.util.xml.reflect.AbstractDomChildrenDescription)1 DomCollectionChildDescription (com.intellij.util.xml.reflect.DomCollectionChildDescription)1 DomFixedChildDescription (com.intellij.util.xml.reflect.DomFixedChildDescription)1 DomStub (com.intellij.util.xml.stubs.DomStub)1