Java Code Examples for com.intellij.codeInsight.daemon.impl.HighlightInfo#getDescription()

The following examples show how to use com.intellij.codeInsight.daemon.impl.HighlightInfo#getDescription() . 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: LombokHighlightErrorFilter.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile file) {
  if (null == file) {
    return true;
  }

  PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset());
  if (null == highlightedElement) {
    return true;
  }

  // check exceptions for highlights
  boolean acceptHighlight = registeredFilters
    .getOrDefault(highlightInfo.getSeverity(), Collections.emptyMap())
    .getOrDefault(highlightInfo.type.getAttributesKey(), Collections.emptyList())
    .stream()
    .filter(filter -> filter.descriptionCheck(highlightInfo.getDescription()))
    .allMatch(filter -> filter.accept(highlightedElement));

  // check if highlight was filtered
  if (!acceptHighlight) {
    return false;
  }

  // handle rest cases
  String description = highlightInfo.getDescription();
  if (HighlightSeverity.ERROR.equals(highlightInfo.getSeverity())) {
    //Handling onX parameters
    if (OnXAnnotationHandler.isOnXParameterAnnotation(highlightInfo, file)
      || OnXAnnotationHandler.isOnXParameterValue(highlightInfo, file)
      || (description != null && LOMBOK_ANY_ANNOTATION_REQUIRED.matcher(description).matches())) {
      return false;
    }
  }

  // register different quick fix for highlight
  registeredHooks
    .getOrDefault(highlightInfo.getSeverity(), Collections.emptyMap())
    .getOrDefault(highlightInfo.type.getAttributesKey(), Collections.emptyList())
    .stream()
    .filter(filter -> filter.descriptionCheck(highlightInfo.getDescription()))
    .forEach(filter -> filter.processHook(highlightedElement, highlightInfo));

  return true;
}
 
Example 2
Source File: ShowErrorDescriptionAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isEnabledForFile(Project project, Editor editor, PsiFile file) {
  DaemonCodeAnalyzer codeAnalyzer = DaemonCodeAnalyzer.getInstance(project);
  HighlightInfo info =
    ((DaemonCodeAnalyzerImpl)codeAnalyzer).findHighlightByOffset(editor.getDocument(), editor.getCaretModel().getOffset(), false);
  return info != null && info.getDescription() != null;
}