public static String getErrorDescription(final PsiReference reference) { String message; if (reference instanceof EmptyResolveMessageProvider) { message = ((EmptyResolveMessageProvider) reference).getUnresolvedMessagePattern(); } else { //noinspection UnresolvedPropertyKey message = PsiBundle.message("cannot.resolve.symbol"); } String description; try { description = MessageFormat.format(message, reference.getCanonicalText()); } catch (IllegalArgumentException ex) { // unresolvedMessage provided by third-party reference contains wrong format string (e.g. {}), // tolerate it description = message; LOG.warn( XmlErrorMessages.message( "plugin.reference.message.problem", reference.getClass().getName(), message)); } return description; }