private static boolean isEntity(PsiElement psi) {
    return psi instanceof XmlEntityRef ||
           psi instanceof XmlTokenImpl && ((XmlTokenImpl)psi).getElementType() == XmlTokenType.XML_CHAR_ENTITY_REF;
  }
private static boolean isEntity(PsiElement psi)