void (PsiReference reference) { final TextRange rangeInElement = reference.getRangeInElement(); final TextRange range = TextRange.from(reference.getElement().getTextRange().getStartOffset() + rangeInElement.getStartOffset(), rangeInElement.getLength()); String message; if (reference instanceof EmptyResolveMessageProvider) { message = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern(); } else { //noinspection UnresolvedPropertyKey message = AnalysisBundle.message("cannot.resolve.symbol"); } String description; try { description = BundleBase.format(message, reference.getCanonicalText()); // avoid double formatting NON-NLS } catch (IllegalArgumentException ex) { // unresolvedMessage provided by third-party reference contains wrong format string (e.g. {}), tolerate it description = message; } AnnotationBuilder builder = myHolder.newAnnotation(HighlightSeverity.ERROR, description).range(range) .highlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); if (reference instanceof LocalQuickFixProvider) { LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes(); if (fixes != null) { InspectionManager inspectionManager = InspectionManager.getInstance(reference.getElement().getProject()); for (LocalQuickFix fix : fixes) { ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(reference.getElement(), message, fix, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, true); builder = builder.newLocalQuickFix(fix, descriptor).registerFix(); } } } builder.create(); }