Search in sources :

Example 61 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class DomInvocationHandler method createChildTag.

protected final XmlTag createChildTag(final EvaluatedXmlName tagName) {
    final String localName = tagName.getXmlName().getLocalName();
    if (localName.contains(":")) {
        try {
            return XmlElementFactory.getInstance(myManager.getProject()).createTagFromText("<" + localName + "/>");
        } catch (IncorrectOperationException e) {
            LOG.error(e);
        }
    }
    final XmlElement element = getXmlElement();
    assert element != null;
    return getXmlTag().createChildTag(localName, tagName.getNamespace(element, getFile()), null, false);
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement)

Example 62 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class PhysicalDomParentStrategy method strategyEquals.

public static boolean strategyEquals(DomParentStrategy strategy, final Object o) {
    if (strategy == o)
        return true;
    if (!(o instanceof DomParentStrategy))
        return false;
    final XmlElement thatElement = ((DomParentStrategy) o).getXmlElement();
    if (thatElement == null)
        return false;
    XmlElement element = strategy.getXmlElement();
    if (element == null)
        return false;
    if (xmlElementsEqual(element, thatElement)) {
        if (element != thatElement) {
            final PsiElement nav1 = element.getNavigationElement();
            final PsiElement nav2 = thatElement.getNavigationElement();
            if (nav1 != nav2) {
                PsiElement curContext = findIncluder(element);
                PsiElement navContext = findIncluder(nav1);
                LOG.error(LogMessageEx.createEvent("x:include processing error", "nav1,nav2=" + nav1 + ", " + nav2 + ";\n" + nav1.getContainingFile() + ":" + nav1.getTextRange().getStartOffset() + "!=" + nav2.getContainingFile() + ":" + nav2.getTextRange().getStartOffset() + ";\n" + (nav1 == element) + ";" + (nav2 == thatElement) + ";\n" + "contexts equal: " + (curContext == navContext) + ";\n" + "curContext?.physical=" + (curContext != null && curContext.isPhysical()) + ";\n" + "navContext?.physical=" + (navContext != null && navContext.isPhysical()) + ";\n" + "myElement.physical=" + element.isPhysical() + ";\n" + "thatElement.physical=" + thatElement.isPhysical() + "\n" + DebugUtil.currentStackTrace(), new Attachment("Including tag text 1.xml", curContext == null ? "null" : curContext.getText()), new Attachment("Including tag text 2.xml", navContext == null ? "null" : navContext.getText())));
                throw new AssertionError();
            }
        }
        return true;
    }
    return false;
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement) Attachment(com.intellij.openapi.diagnostic.Attachment) PsiElement(com.intellij.psi.PsiElement)

Example 63 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class XmlElementImpl method findElementByTokenType.

public XmlElement findElementByTokenType(final IElementType type) {
    final XmlElement[] result = new XmlElement[1];
    result[0] = null;
    processElements(new PsiElementProcessor() {

        @Override
        public boolean execute(@NotNull PsiElement element) {
            if (element instanceof TreeElement && ((ASTNode) element).getElementType() == type) {
                result[0] = (XmlElement) element;
                return false;
            }
            return true;
        }
    }, this);
    return result[0];
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement) PsiElementProcessor(com.intellij.psi.search.PsiElementProcessor) PsiElement(com.intellij.psi.PsiElement) CompositePsiElement(com.intellij.psi.impl.source.tree.CompositePsiElement) TreeElement(com.intellij.psi.impl.source.tree.TreeElement)

Example 64 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class XmlElementImpl method getNavigationElement.

@Override
@NotNull
public PsiElement getNavigationElement() {
    if (!isPhysical()) {
        final XmlElement including = getUserData(INCLUDING_ELEMENT);
        if (including != null) {
            return including;
        }
        PsiElement astParent = getAstParent();
        PsiElement parentNavigation = astParent.getNavigationElement();
        if (parentNavigation.getTextOffset() == getTextOffset())
            return parentNavigation;
        return this;
    }
    return super.getNavigationElement();
}
Also used : XmlElement(com.intellij.psi.xml.XmlElement) PsiElement(com.intellij.psi.PsiElement) CompositePsiElement(com.intellij.psi.impl.source.tree.CompositePsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 65 with XmlElement

use of com.intellij.psi.xml.XmlElement in project intellij-community by JetBrains.

the class XmlEnumeratedTypeImpl method getEnumeratedValues.

@Override
public XmlElement[] getEnumeratedValues() {
    final List<XmlElement> result = new ArrayList<>();
    processElements(new FilterElementProcessor(new XmlTokenTypeFilter(XmlTokenType.XML_NAME), result), this);
    return result.toArray(new XmlElement[result.size()]);
}
Also used : FilterElementProcessor(com.intellij.psi.scope.processor.FilterElementProcessor) XmlTokenTypeFilter(com.intellij.psi.filters.position.XmlTokenTypeFilter) ArrayList(java.util.ArrayList) XmlElement(com.intellij.psi.xml.XmlElement)

Aggregations

XmlElement (com.intellij.psi.xml.XmlElement)69 PsiElement (com.intellij.psi.PsiElement)16 NotNull (org.jetbrains.annotations.NotNull)16 Nullable (org.jetbrains.annotations.Nullable)11 XmlTag (com.intellij.psi.xml.XmlTag)10 PsiFile (com.intellij.psi.PsiFile)7 PsiReference (com.intellij.psi.PsiReference)6 XmlAttribute (com.intellij.psi.xml.XmlAttribute)6 XmlFile (com.intellij.psi.xml.XmlFile)6 Manifest (org.jetbrains.android.dom.manifest.Manifest)5 Module (com.intellij.openapi.module.Module)4 Project (com.intellij.openapi.project.Project)4 DomElement (com.intellij.util.xml.DomElement)4 ArrayList (java.util.ArrayList)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 CompositePsiElement (com.intellij.psi.impl.source.tree.CompositePsiElement)3 SmartList (com.intellij.util.SmartList)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 ResourceType (com.android.resources.ResourceType)2 Result (com.intellij.openapi.application.Result)2