use of com.intellij.codeInsight.daemon.EmptyResolveMessageProvider in project intellij-community by JetBrains.
the class ReferenceAnnotator method addError.
private void addError(PsiReference reference) {
final TextRange rangeInElement = reference.getRangeInElement();
final TextRange range = TextRange.from(reference.getElement().getTextRange().getStartOffset() + rangeInElement.getStartOffset(), rangeInElement.getLength());
final Annotation annotation;
if (reference instanceof EmptyResolveMessageProvider) {
final String s = ((EmptyResolveMessageProvider) reference).getUnresolvedMessagePattern();
annotation = myHolder.createErrorAnnotation(range, MessageFormat.format(s, reference.getCanonicalText()));
} else {
annotation = myHolder.createErrorAnnotation(range, "Cannot resolve symbol");
}
annotation.setHighlightType(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(), annotation.getMessage(), fix, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, true);
annotation.registerFix(fix, null, null, descriptor);
}
}
}
}
use of com.intellij.codeInsight.daemon.EmptyResolveMessageProvider in project intellij-community by JetBrains.
the class XPathAnnotator method visitXPath2TypeElement.
@Override
public void visitXPath2TypeElement(XPath2TypeElement o) {
final ContextProvider contextProvider = o.getXPathContext();
checkPrefixReferences(myHolder, o, contextProvider);
if (o.getDeclaredType() == XPathType.UNKNOWN) {
final PsiReference[] references = o.getReferences();
for (PsiReference reference : references) {
if (reference instanceof XsltReferenceContributor.SchemaTypeReference) {
if (!reference.isSoft() && reference.resolve() == null) {
final String message = ((EmptyResolveMessageProvider) reference).getUnresolvedMessagePattern();
final Annotation annotation = myHolder.createErrorAnnotation(reference.getRangeInElement().shiftRight(o.getTextOffset()), message);
annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
}
}
}
}
super.visitXPath2TypeElement(o);
}
Aggregations