Access (final @NotNull PsiElement referencedElement, final @NotNull PsiReference reference) { PsiElement refElement = reference.getElement(); return refElement instanceof XmlAttributeValue && (!(referencedElement instanceof XmlTag) || refElement.getParent().getParent() == referencedElement) || refElement instanceof XmlElementDecl || refElement instanceof XmlComment // e.g. <!--@elvariable name="xxx" type="yyy"--> ? Access.Write : Access.Read; }