public PsiFile resolve() { final PsiFile referencedFile = getReferencedFile(); if (referencedFile != null) { return referencedFile; } if (myPsiFile != null) { final PsiElement psiElement = myPsiFile.findElementAt(myLinkInfo.offset); if (psiElement != null) { final PsiElement parent = psiElement.getParent(); if (parent instanceof XmlTag) { final XmlAttribute attribute = ((XmlTag) parent).getAttribute(HREF_ATTR); if (attribute != null) { final XmlAttributeValue value = attribute.getValueElement(); if (value != null) { final PsiReference[] references = value.getReferences(); for (PsiReference reference : references) { final PsiElement element = reference.resolve(); if (element instanceof PsiFile) { return (PsiFile) element; } } } } } } } return null; }
@NotNull public XPathType getExpectedType(XPathExpression expr) { final XmlTag tag = PsiTreeUtil.getContextOfType(expr, XmlTag.class, true); if (tag != null && XsltSupport.isXsltTag(tag)) { final XsltElement element = XsltElementFactory.getInstance().wrapElement(tag, XsltElement.class); if (element instanceof XsltVariable) { return ((XsltVariable) element).getType(); } else { final XmlAttribute attr = PsiTreeUtil.getContextOfType(expr, XmlAttribute.class, true); if (attr != null) { if (element instanceof XsltWithParam) { final XmlAttribute nameAttr = tag.getAttribute("name", null); if (nameAttr != null) { final XmlAttributeValue valueElement = nameAttr.getValueElement(); if (valueElement != null) { final PsiReference[] references = valueElement.getReferences(); for (PsiReference reference : references) { final PsiElement psiElement = reference.resolve(); if (psiElement instanceof XsltVariable) { return ((XsltVariable) psiElement).getType(); } } } } } else { final String name = attr.getName(); return getTypeForTag(tag, name); } } } } return XPathType.UNKNOWN; }