@NotNull
  public XmlFile getContainingFile(@NotNull DomElement domElement) {
    if (domElement instanceof DomFileElement) {
      return ((DomFileElement) domElement).getFile();
    }
    DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(domElement);
    assert handler != null : domElement;
    while (handler != null
        && !(handler instanceof DomRootInvocationHandler)
        && handler.getXmlTag() == null) {
      handler = handler.getParentHandler();
    }
    if (handler instanceof DomRootInvocationHandler) {
      return ((DomRootInvocationHandler) handler).getParent().getFile();
    }
    assert handler != null;
    XmlTag tag = handler.getXmlTag();
    assert tag != null;
    while (true) {
      final PsiElement parentTag = PhysicalDomParentStrategy.getParentTagCandidate(tag);
      if (!(parentTag instanceof XmlTag)) {
        return (XmlFile) tag.getContainingFile();
      }

      tag = (XmlTag) parentTag;
    }
  }
 @Override
 @NotNull
 public XmlFile getContainingFile(@NotNull DomElement domElement) {
   if (domElement instanceof DomFileElement) {
     return ((DomFileElement) domElement).getFile();
   }
   return DomManagerImpl.getNotNullHandler(domElement).getFile();
 }
예제 #3
0
  public static void assertValidity(DomElement element, String msg) {
    if (element instanceof DomFileElementImpl) {
      final String s = ((DomFileElementImpl) element).checkValidity();
      if (s != null) {
        throw new AssertionError(s);
      }
      return;
    }

    final DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(element);
    assert handler != null;
    try {
      handler.assertValid();
    } catch (AssertionError e) {
      throw new AssertionError(msg + e.getMessage());
    }
  }
예제 #4
0
  static XmlFile getFile(DomElement domElement) {
    if (domElement instanceof DomFileElement) {
      return ((DomFileElement) domElement).getFile();
    }
    DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(domElement);
    assert handler != null : domElement;
    while (true) {
      if (handler instanceof DomRootInvocationHandler) {
        return ((DomRootInvocationHandler) handler).getParent().getFile();
      }

      XmlTag tag = handler.getXmlTag();
      if (tag != null) {
        return getContainingFile(tag);
      }
      DomInvocationHandler parent = handler.getParentHandler();
      if (parent == null) {
        throw new AssertionError("No parent for " + handler.toStringEx());
      }
      handler = parent;
    }
  }
 @NotNull
 public EvaluatedXmlName getEvaluatedXmlName(@NotNull final DomElement element) {
   return DomManagerImpl.getDomInvocationHandler(element).getXmlName();
 }
 @Override
 @NotNull
 public EvaluatedXmlName getEvaluatedXmlName(@NotNull final DomElement element) {
   return DomManagerImpl.getNotNullHandler(element).getXmlName();
 }