Search in sources :

Example 1 with EmptyResolveMessageProvider

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);
            }
        }
    }
}
Also used : EmptyResolveMessageProvider(com.intellij.codeInsight.daemon.EmptyResolveMessageProvider) TextRange(com.intellij.openapi.util.TextRange) Annotation(com.intellij.lang.annotation.Annotation)

Example 2 with EmptyResolveMessageProvider

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);
}
Also used : EmptyResolveMessageProvider(com.intellij.codeInsight.daemon.EmptyResolveMessageProvider) PsiReference(com.intellij.psi.PsiReference) ContextProvider(org.intellij.lang.xpath.context.ContextProvider) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

EmptyResolveMessageProvider (com.intellij.codeInsight.daemon.EmptyResolveMessageProvider)2 Annotation (com.intellij.lang.annotation.Annotation)2 TextRange (com.intellij.openapi.util.TextRange)1 PsiReference (com.intellij.psi.PsiReference)1 ContextProvider (org.intellij.lang.xpath.context.ContextProvider)1