Java Code Examples for com.intellij.lang.annotation.Annotation#setHighlightType()

The following examples show how to use com.intellij.lang.annotation.Annotation#setHighlightType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InflateViewAnnotator.java    From idea-android-studio-plugin with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {

    InflateContainer inflateContainer = matchInflate(psiElement);
    if(inflateContainer == null) {
        return;
    }

    Annotation inflateLocal = annotationHolder.createWeakWarningAnnotation(psiElement, null);
    inflateLocal.setHighlightType(null);
    inflateLocal.registerFix(new InflateLocalVariableAction(inflateContainer.getPsiLocalVariable(), inflateContainer.getXmlFile()));

    Annotation inflateThis = annotationHolder.createWeakWarningAnnotation(psiElement, null);
    inflateThis.setHighlightType(null);
    inflateThis.registerFix(new InflateThisExpressionAction(inflateContainer.getPsiLocalVariable(), inflateContainer.getXmlFile()));

}
 
Example 2
Source File: UnusedRefAnnotator.java    From intellij-swagger with MIT License 5 votes vote down vote up
private void warn(
    final PsiElement psiElement,
    final AnnotationHolder annotationHolder,
    final PsiElement searchableCurrentElement,
    final String warning) {
  final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst();

  if (first == null) {
    Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning);
    annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
  }
}
 
Example 3
Source File: UnusedRefAnnotator.java    From intellij-swagger with MIT License 5 votes vote down vote up
private void warn(
    final PsiElement psiElement,
    final AnnotationHolder annotationHolder,
    final PsiElement searchableCurrentElement,
    final String warning) {
  final PsiReference first = ReferencesSearch.search(searchableCurrentElement).findFirst();

  if (first == null) {
    Annotation annotation = annotationHolder.createWeakWarningAnnotation(psiElement, warning);
    annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
  }
}
 
Example 4
Source File: ProtoErrorsAnnotator.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
private void markError(ASTNode parent, @Nullable ASTNode node, String message) {
    Annotation annotation;
    if (node == null) {
        annotation = holder.createErrorAnnotation(parent, message);
    } else {
        annotation = holder.createErrorAnnotation(node, message);
    }
    annotation.setHighlightType(ProblemHighlightType.GENERIC_ERROR);
}
 
Example 5
Source File: GhcMod.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
/**
 * Create an annotation from this problem and add it to the annotation holder.
 */
@Override
public void createAnnotations(@NotNull PsiFile psiFile, @NotNull HaskellAnnotationHolder holder) {
    // TODO: There is probably a better way to compare these two file paths.
    // The problem might not be ours; ignore this problem in that case.
    // Note that Windows paths end up with different slashes, so getPresentableUrl() normalizes them.
    final VirtualFile vFile = psiFile.getVirtualFile();
    if (!(file.equals(vFile.getCanonicalPath()) || file.equals(vFile.getPresentableUrl()))) {
        return;
    }
    final TextRange range = getTextRange(psiFile);
    if (range == null) return;
    final Annotation annotation;
    if (isError) {
        annotation = holder.createErrorAnnotation(range, message);
    } else {
        annotation = holder.createWeakWarningAnnotation(range, message);
    }
    if (annotation == null) return;
    if (isUnknownSymbol) {
        annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    } else if (isUnusedSymbol) {
        annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
    } else if (isUnusedImport) {
        annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
    }
    registerFix(psiFile, annotation);
}
 
Example 6
Source File: MisplacedCommentHighlighter.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
public void highlight(PsiElement element, AnnotationHolder holder) {
    XQueryMisplacedComment misplacedComment = PsiTreeUtil.getTopmostParentOfType(element, XQueryMisplacedComment.class);
    if (isTheStartingElementOfMisplacedComment(element, misplacedComment)) {
        Annotation annotation = holder.createErrorAnnotation(misplacedComment, "Comments cannot be used here.");
        annotation.setHighlightType(ProblemHighlightType.GENERIC_ERROR);
    }
}