@Nullable
 private PsiFile getFile() {
   final XmlElement element = getContextElement();
   if (element == null) {
     return null;
   }
   return element.getContainingFile().getOriginalFile();
 }
 protected XsltContextProviderBase(XmlElement element) {
   final Project project = element.getProject();
   myFileAssociationsManager = FileAssociationsManager.getInstance(project);
   myContextElement =
       SmartPointerManager.getInstance(project).createSmartPsiElementPointer(element);
   attachTo(element);
 }
  private ArrayList<RemoteObject> deserializeArrayAsXml(String queryScope, String input) {
    ArrayList<RemoteObject> objects = new ArrayList<RemoteObject>();

    XmlParser parser = new XmlParser(input);
    XmlElement parent =
        ((XmlElement)
                parser.parse(
                    HttpAdapter.createResponseWrangling(queryScope, this).getCollectionSelector(),
                    XmlElement.class))
            .getParent();
    for (int i = 0; i < parent.getChildCount(); i++) {
      objects.add(deserialize(queryScope, new XmlParser(parent.get(i))));
    }

    return objects;
  }
Esempio n. 4
0
 private static boolean checkHasXml(XmlElement psi, DomElement dom) {
   if (dom != null && !hasXml(dom)) {
     LOG.error("No xml for dom " + dom + "; attr=" + psi + ", physical=" + psi.isPhysical());
     return false;
   }
   return true;
 }
Esempio n. 5
0
  @NotNull
  public static <T extends DomElement> T getOriginalElement(@NotNull final T domElement) {
    final XmlElement psiElement = domElement.getXmlElement();
    if (psiElement == null) return domElement;

    final PsiFile psiFile = psiElement.getContainingFile().getOriginalFile();
    final TextRange range = psiElement.getTextRange();
    final PsiElement element = psiFile.findElementAt(range.getStartOffset());
    final int maxLength = range.getLength();
    final boolean isAttribute = psiElement instanceof XmlAttribute;
    final Class<? extends XmlElement> clazz = isAttribute ? XmlAttribute.class : XmlTag.class;
    final DomManager domManager = domElement.getManager();
    DomElement current = null;
    for (XmlElement next = PsiTreeUtil.getParentOfType(element, clazz, false);
        next != null && next.getTextLength() <= maxLength;
        next = PsiTreeUtil.getParentOfType(next, clazz, true)) {
      current =
          isAttribute
              ? domManager.getDomElement((XmlAttribute) next)
              : domManager.getDomElement((XmlTag) next);
      if (current != null && domElement.getClass() != current.getClass()) current = null;
    }
    return (T) current;
  }