Java Code Examples for com.intellij.lang.annotation.HighlightSeverity#ERROR

The following examples show how to use com.intellij.lang.annotation.HighlightSeverity#ERROR . 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: ShowIntentionsPass.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void fillIntentionsInfoForHighlightInfo(@Nonnull HighlightInfo infoAtCursor,
                                                      @Nonnull IntentionsInfo intentions,
                                                      @Nonnull List<? extends HighlightInfo.IntentionActionDescriptor> fixes) {
  final boolean isError = infoAtCursor.getSeverity() == HighlightSeverity.ERROR;
  for (HighlightInfo.IntentionActionDescriptor fix : fixes) {
    if (fix.isError() && isError) {
      intentions.errorFixesToShow.add(fix);
    }
    else if (fix.isInformation()) {
      intentions.intentionsToShow.add(fix);
    }
    else {
      intentions.inspectionFixesToShow.add(fix);
    }
  }
}
 
Example 2
Source File: DefaultInspectionToolPresentation.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected static String getTextAttributeKey(@Nonnull Project project,
                                            @Nonnull HighlightSeverity severity,
                                            @Nonnull ProblemHighlightType highlightType) {
  if (highlightType == ProblemHighlightType.LIKE_DEPRECATED) {
    return HighlightInfoType.DEPRECATED.getAttributesKey().getExternalName();
  }
  if (highlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL && severity == HighlightSeverity.ERROR) {
    return HighlightInfoType.WRONG_REF.getAttributesKey().getExternalName();
  }
  if (highlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
    return HighlightInfoType.UNUSED_SYMBOL.getAttributesKey().getExternalName();
  }
  SeverityRegistrar registrar = InspectionProjectProfileManagerImpl.getInstanceImpl(project).getSeverityRegistrar();
  return registrar.getHighlightInfoTypeBySeverity(severity).getAttributesKey().getExternalName();
}
 
Example 3
Source File: CodeAnalysisBeforeCheckinHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static int collectErrors(final List<CodeSmellInfo> codeSmells) {
  int result = 0;
  for (CodeSmellInfo codeSmellInfo : codeSmells) {
    if (codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) result++;
  }
  return result;
}
 
Example 4
Source File: HighlightInfoHolder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean add(@Nullable HighlightInfo info) {
  if (info == null || !accepted(info)) return false;

  HighlightSeverity severity = info.getSeverity();
  if (severity == HighlightSeverity.ERROR) {
    myErrorCount++;
  }

  return myInfos.add(info);
}
 
Example 5
Source File: HighlightInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@SuppressWarnings("deprecation")
public static ProblemHighlightType convertSeverityToProblemHighlight(HighlightSeverity severity) {
  return severity == HighlightSeverity.ERROR
         ? ProblemHighlightType.ERROR
         : severity == HighlightSeverity.WARNING
           ? ProblemHighlightType.WARNING
           : severity == HighlightSeverity.INFO ? ProblemHighlightType.INFO : severity == HighlightSeverity.WEAK_WARNING ? ProblemHighlightType.WEAK_WARNING : ProblemHighlightType.INFORMATION;
}
 
Example 6
Source File: HighlightInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@SuppressWarnings("deprecation")
public static HighlightInfoType convertSeverity(@Nonnull HighlightSeverity severity) {
  return severity == HighlightSeverity.ERROR
         ? HighlightInfoType.ERROR
         : severity == HighlightSeverity.WARNING
           ? HighlightInfoType.WARNING
           : severity == HighlightSeverity.INFO
             ? HighlightInfoType.INFO
             : severity == HighlightSeverity.WEAK_WARNING
               ? HighlightInfoType.WEAK_WARNING
               : severity == HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING ? HighlightInfoType.GENERIC_WARNINGS_OR_ERRORS_FROM_SERVER : HighlightInfoType.INFORMATION;
}
 
Example 7
Source File: GeneralHighlightingPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<Problem> convertToProblems(@Nonnull Collection<? extends HighlightInfo> infos, @Nonnull VirtualFile file, final boolean hasErrorElement) {
  List<Problem> problems = new SmartList<>();
  for (HighlightInfo info : infos) {
    if (info.getSeverity() == HighlightSeverity.ERROR) {
      Problem problem = new ProblemImpl(file, info, hasErrorElement);
      problems.add(problem);
    }
  }
  return problems;
}
 
Example 8
Source File: TestHolder.java    From litho with Apache License 2.0 5 votes vote down vote up
@Override
public Annotation createErrorAnnotation(PsiElement elt, @Nullable String message) {
  errorElements.add(elt);
  errorMessages.add(message);
  Annotation stub = new Annotation(0, 0, HighlightSeverity.ERROR, "", "");
  createdAnnotations.add(stub);
  return stub;
}
 
Example 9
Source File: ProblemDescriptorUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static HighlightInfoType highlightTypeFromDescriptor(@Nonnull ProblemDescriptor problemDescriptor,
                                                            @Nonnull HighlightSeverity severity,
                                                            @Nonnull SeverityRegistrar severityRegistrar) {
  final ProblemHighlightType highlightType = problemDescriptor.getHighlightType();
  switch (highlightType) {
    case GENERIC_ERROR_OR_WARNING:
      return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
    case LIKE_DEPRECATED:
      return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.DEPRECATED.getAttributesKey());
    case LIKE_UNKNOWN_SYMBOL:
      if (severity == HighlightSeverity.ERROR) {
        return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.WRONG_REF.getAttributesKey());
      }
      if (severity == HighlightSeverity.WARNING) {
        return new HighlightInfoType.HighlightInfoTypeImpl(severity, CodeInsightColors.WEAK_WARNING_ATTRIBUTES);
      }
      return severityRegistrar.getHighlightInfoTypeBySeverity(severity);
    case LIKE_UNUSED_SYMBOL:
      return new HighlightInfoType.HighlightInfoTypeImpl(severity, HighlightInfoType.UNUSED_SYMBOL.getAttributesKey());
    case INFO:
      return HighlightInfoType.INFO;
    case WEAK_WARNING:
      return HighlightInfoType.WEAK_WARNING;
    case ERROR:
      return HighlightInfoType.WRONG_REF;
    case GENERIC_ERROR:
      return HighlightInfoType.ERROR;
    case INFORMATION:
      final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes();
      if (attributes != null) {
        return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, attributes);
      }
      return HighlightInfoType.INFORMATION;
  }
  throw new RuntimeException("Cannot map " + highlightType);
}
 
Example 10
Source File: DiffPsiFileSupport.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean accept(@Nonnull HighlightInfo info, @Nullable PsiFile file) {
  if (!isDiffFile(file)) return true;
  if (info.getSeverity() == HighlightSeverity.ERROR) return false;
  return true;
}
 
Example 11
Source File: HaxeStandardAnnotation.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public static HaxeAnnotation typeMismatch(PsiElement incompatibleElement, String incompatibleType, String correctType) {
  String message = HaxeBundle.message("haxe.semantic.incompatible.type.0.should.be.1", incompatibleType, correctType);

  return new HaxeAnnotation(HighlightSeverity.ERROR, incompatibleElement.getTextRange(), message, null);
}
 
Example 12
Source File: HaxeExpressionEvaluatorContext.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
private Annotation createDummyAnnotation() {
  return new Annotation(0, 0, HighlightSeverity.ERROR, "", "");
}
 
Example 13
Source File: ESLintExternalAnnotator.java    From eslint-plugin with MIT License 4 votes vote down vote up
private static HighlightSeverity getHighlightSeverity(VerifyMessage warn, boolean treatAsWarnings) {
    if (treatAsWarnings) {
        return HighlightSeverity.WARNING;
    }
    return warn.severity == 2 ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
 
Example 14
Source File: RTExternalAnnotator.java    From react-templates-plugin with MIT License 4 votes vote down vote up
private static HighlightSeverity getHighlightSeverity(VerifyMessage warn, boolean treatAsWarnings) {
    if (treatAsWarnings) {
        return HighlightSeverity.WARNING;
    }
    return warn.level.equals("ERROR") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
 
Example 15
Source File: RTExternalAnnotator.java    From react-templates-plugin with MIT License 4 votes vote down vote up
private static HighlightSeverity getHighlightSeverity(VerifyMessage warn, boolean treatAsWarnings) {
    if (treatAsWarnings) {
        return HighlightSeverity.WARNING;
    }
    return warn.level.equals("ERROR") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}
 
Example 16
Source File: ContentResourceChangeListener.java    From aem-ide-tooling-4-intellij with Apache License 2.0 4 votes vote down vote up
private void executeMakeInUIThread(final VirtualFileEvent event) {
    if(project.isInitialized() && !project.isDisposed() && project.isOpen()) {
        final CompilerManager compilerManager = CompilerManager.getInstance(project);
        if(!compilerManager.isCompilationActive() &&
            !compilerManager.isExcludedFromCompilation(event.getFile()) // &&
        ) {
            // Check first if there are no errors in the code
            CodeSmellDetector codeSmellDetector = CodeSmellDetector.getInstance(project);
            boolean isOk = true;
            if(codeSmellDetector != null) {
                List<CodeSmellInfo> codeSmellInfoList = codeSmellDetector.findCodeSmells(Arrays.asList(event.getFile()));
                for(CodeSmellInfo codeSmellInfo: codeSmellInfoList) {
                    if(codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) {
                        isOk = false;
                        break;
                    }
                }
            }
            if(isOk) {
                // Changed file found in module. Make it.
                final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW);
                final boolean isShown = tw != null && tw.isVisible();
                compilerManager.compile(
                    new VirtualFile[]{event.getFile()},
                    new CompileStatusNotification() {
                        @Override
                        public void finished(boolean b, int i, int i1, CompileContext compileContext) {
                            if (tw != null && tw.isVisible()) {
                                // Close / Hide the Build Message Window after we did the build if it wasn't shown
                                if(!isShown) {
                                    tw.hide(null);
                                }
                            }
                        }
                    }
                );
            } else {
                MessageManager messageManager = ComponentProvider.getComponent(project, MessageManager.class);
                if(messageManager != null) {
                    messageManager.sendErrorNotification(
                        "server.update.file.change.with.error",
                        event.getFile()
                    );
                }
            }
        }
    }
}
 
Example 17
Source File: SassLintExternalAnnotator.java    From sass-lint-plugin with MIT License 4 votes vote down vote up
private static HighlightSeverity getHighlightSeverity(SassLint.Issue warn, boolean treatAsWarnings) {
    if (treatAsWarnings) {
        return HighlightSeverity.WARNING;
    }
    return warn.severity.equals("error") ? HighlightSeverity.ERROR : HighlightSeverity.WARNING;
}