com.intellij.lang.annotation.HighlightSeverity Java Examples

The following examples show how to use com.intellij.lang.annotation.HighlightSeverity. 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 boolean markActionInvoked(@Nonnull Project project, @Nonnull final Editor editor, @Nonnull IntentionAction action) {
  final int offset = ((EditorEx)editor).getExpectedCaretOffset();

  List<HighlightInfo> infos = new ArrayList<>();
  DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true, new CommonProcessors.CollectProcessor<>(infos));
  boolean removed = false;
  for (HighlightInfo info : infos) {
    if (info.quickFixActionMarkers != null) {
      for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
        HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
        if (actionInGroup.getAction() == action) {
          // no CME because the list is concurrent
          removed |= info.quickFixActionMarkers.remove(pair);
        }
      }
    }
  }
  return removed;
}
 
Example #2
Source File: DaemonCodeAnalyzerEx.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param document
 * @param project
 * @param minSeverity null means all
 * @param startOffset
 * @param endOffset
 * @param processor
 * @return
 */
public static boolean processHighlights(@Nonnull Document document,
                                        @Nonnull Project project,
                                        @javax.annotation.Nullable final HighlightSeverity minSeverity,
                                        final int startOffset,
                                        final int endOffset,
                                        @Nonnull final Processor<HighlightInfo> processor) {
  LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());

  final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
  MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);
  return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, marker -> {
    Object tt = marker.getErrorStripeTooltip();
    if (!(tt instanceof HighlightInfo)) return true;
    HighlightInfo info = (HighlightInfo)tt;
    return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0
           || info.highlighter == null
           || processor.process(info);
  });
}
 
Example #3
Source File: HighlightDisplayLevel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static HighlightDisplayLevel find(String name) {
  for (Map.Entry<HighlightSeverity, HighlightDisplayLevel> entry : ourMap.entrySet()) {
    HighlightSeverity severity = entry.getKey();
    HighlightDisplayLevel displayLevel = entry.getValue();
    if (Comparing.strEqual(severity.getName(), name)) {
      return displayLevel;
    }
  }
  return null;
}
 
Example #4
Source File: HighlightInfoFilterImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean accept(@Nonnull HighlightInfo info, PsiFile file) {
  if (ourTestMode) return true; // Tests need to verify highlighting is applied no matter what attributes are defined for this kind of highlighting

  TextAttributes attributes = info.getTextAttributes(file, null);
  // optimization
   return attributes == TextAttributes.ERASE_MARKER || attributes != null &&
         !(attributes.isEmpty() && info.getSeverity() == HighlightSeverity.INFORMATION && info.getGutterIconRenderer() == null);
}
 
Example #5
Source File: GotoNextErrorHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void gotoNextError(Project project, Editor editor, PsiFile file, int caretOffset) {
  final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
  DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
  int maxSeverity = settings.NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST ? severityRegistrar.getSeveritiesCount() - 1 : 0;

  for (int idx = maxSeverity; idx >= 0; idx--) {
    final HighlightSeverity minSeverity = severityRegistrar.getSeverityByIndex(idx);
    HighlightInfo infoToGo = findInfo(project, editor, caretOffset, minSeverity);
    if (infoToGo != null) {
      navigateToError(project, editor, infoToGo);
      return;
    }
  }
  showMessageWhenNoHighlights(project, file, editor);
}
 
Example #6
Source File: CamelEndpointAnnotatorTestIT.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testAnnotatorConsumerOnly() {
    myFixture.configureByText("AnnotatorTestData.java", getJavaConsumerOnlyTestData());
    myFixture.checkHighlighting(false, false, true, true);

    List<HighlightInfo> list = myFixture.doHighlighting();

    // find the warning from the highlights as checkWarning cannot do that for us for warnings
    boolean found = list.stream().anyMatch(i -> i.getText().equals("fileExist")
        && i.getDescription().equals("Option not applicable in consumer only mode")
        && i.getSeverity().equals(HighlightSeverity.WARNING));
    assertTrue("Should find the warning", found);
}
 
Example #7
Source File: SeverityRegistrar.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static OrderMap fromList(@Nonnull List<HighlightSeverity> orderList) {
  TObjectIntHashMap<HighlightSeverity> map = new TObjectIntHashMap<HighlightSeverity>();
  for (int i = 0; i < orderList.size(); i++) {
    HighlightSeverity severity = orderList.get(i);
    map.put(severity, i);
  }
  return new OrderMap(map);
}
 
Example #8
Source File: InspectionProfileImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public Set<HighlightSeverity> getUsedSeverities() {
  LOG.assertTrue(myInitialized);
  final Set<HighlightSeverity> result = new HashSet<HighlightSeverity>();
  for (Tools tools : myTools.values()) {
    for (ScopeToolState state : tools.getTools()) {
      result.add(state.getLevel().getSeverity());
    }
  }
  return result;
}
 
Example #9
Source File: CamelBeanMethodAnnotatorTestIT.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Test if the annotator mark the bean call "thisIsVeryPrivate","methodDoesNotExist" as errors
 */
public void testAnnotatorJavaBeanWithAbstractMethod() {
    myFixture.configureByFiles("AnnotatorJavaBeanRoute2TestData.java", "AnnotatorJavaBeanTestData.java", "AnnotatorJavaBeanSuperClassTestData.java");
    myFixture.checkHighlighting(false, false, false, true);

    List<HighlightInfo> list = myFixture.doHighlighting();

    verifyHighlight(list, "\"letsDoThis\"", "Can not resolve method 'letsDoThis' in bean 'testData.annotator.method.AnnotatorJavaBeanSuperClassTestData'", HighlightSeverity.ERROR);
    verifyHighlight(list, "(beanTestData, \"mySuperAbstractMethod\")", "Cannot resolve method 'bean(testData.annotator.method.AnnotatorJavaBeanSuperClassTestData, java.lang.String)'", HighlightSeverity.ERROR);
    verifyHighlight(list, "\"thisIsVeryPrivate\"", "Can not resolve method 'thisIsVeryPrivate' in bean 'testData.annotator.method.AnnotatorJavaBeanSuperClassTestData'", HighlightSeverity.ERROR);
}
 
Example #10
Source File: UnusedParameterOrStateAnnotator.java    From bamboo-soy with Apache License 2.0 5 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder annotationHolder) {
  if (element instanceof TemplateBlockMixin) {
    // Abort if values are passed with data="...", parameter are sometimes defined for the sake
    // of added documentation even when not technically used directly in the template body.
    if (element.getText().contains("data=")) {
      return;
    }

    Collection<? extends Variable> variables = Streams
        .concat(ParamUtils.getParamDefinitions(element).stream(),
            ParamUtils.getStateDefinitions(element).stream()).collect(
            ImmutableList.toImmutableList());

    Set<String> usedVariableIdentifiers =
        PsiTreeUtil.findChildrenOfType(element, IdentifierElement.class)
            .stream()
            .map(IdentifierElement::getReferences)
            .flatMap(Arrays::stream)
            .map(PsiReference::getCanonicalText)
            .collect(ImmutableSet.toImmutableSet());

    for (Variable variable : variables) {
      if (!usedVariableIdentifiers.contains(variable.name)) {
        Annotation annotation = annotationHolder
            .createAnnotation(((TemplateBlockMixin) element).isElementBlock() ?
                    HighlightSeverity.WEAK_WARNING : HighlightSeverity.ERROR,
                variable.element.getTextRange(),
                variableType(variable) + " " + variable.name + " is unused.");
        annotation.registerFix(isParameter(variable)
            ? new RemoveUnusedParameterFix(variable.name)
            : new RemoveUnusedStateVarFix(variable.name));
      }
    }
  }
}
 
Example #11
Source File: LocalInspectionsPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addHighlightsFromResults(@Nonnull List<HighlightInfo> outInfos, @Nonnull ProgressIndicator indicator) {
  InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(myProject).getInspectionProfile();
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
  InjectedLanguageManager ilManager = InjectedLanguageManager.getInstance(myProject);
  Set<Pair<TextRange, String>> emptyActionRegistered = new THashSet<>();

  for (Map.Entry<PsiFile, List<InspectionResult>> entry : result.entrySet()) {
    indicator.checkCanceled();
    PsiFile file = entry.getKey();
    Document documentRange = documentManager.getDocument(file);
    if (documentRange == null) continue;
    List<InspectionResult> resultList = entry.getValue();
    synchronized (resultList) {
      for (InspectionResult inspectionResult : resultList) {
        indicator.checkCanceled();
        LocalInspectionToolWrapper tool = inspectionResult.tool;
        HighlightSeverity severity = inspectionProfile.getErrorLevel(HighlightDisplayKey.find(tool.getShortName()), file).getSeverity();
        for (ProblemDescriptor descriptor : inspectionResult.foundProblems) {
          indicator.checkCanceled();
          PsiElement element = descriptor.getPsiElement();
          if (element != null) {
            createHighlightsForDescriptor(outInfos, emptyActionRegistered, ilManager, file, documentRange, tool, severity, descriptor, element);
          }
        }
      }
    }
  }
}
 
Example #12
Source File: LoadStatementAnnotatorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorForPrivateSymbols() {
  BuildFile file =
      createBuildFile(
          new WorkspacePath("java/com/google/BUILD"), "load(':skylark.bzl', '_local_symbol')");
  assertHasAnnotation(
      file, "Symbol '_local_symbol' is private and cannot be imported.", HighlightSeverity.ERROR);
}
 
Example #13
Source File: HighlightDisplayLevel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void registerSeverity(@Nonnull HighlightSeverity severity, final TextAttributesKey key, @javax.annotation.Nullable Icon icon) {
  Icon severityIcon = icon != null ? icon : createBoxIcon(key);
  final HighlightDisplayLevel level = ourMap.get(severity);
  if (level == null) {
    new HighlightDisplayLevel(severity, severityIcon);
  }
  else {
    level.myIcon = severityIcon;
  }
}
 
Example #14
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 #15
Source File: SeverityRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static SeverityRenderer create(final InspectionProfileImpl inspectionProfile, @Nullable final Runnable onClose) {
  final SortedSet<HighlightSeverity> severities =
          LevelChooserAction.getSeverities(((SeverityProvider)inspectionProfile.getProfileManager()).getOwnSeverityRegistrar());
  return new SeverityRenderer(ContainerUtil.map2Array(severities, new SeverityState[severities.size()], new Function<HighlightSeverity, SeverityState>() {
    @Override
    public SeverityState fun(HighlightSeverity severity) {
      return new SeverityState(severity, true, false);
    }
  }), onClose);
}
 
Example #16
Source File: LoadStatementAnnotatorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private void assertHasAnnotation(BuildFile file, String message, HighlightSeverity type) {
  assertThat(
          validateFile(file)
              .stream()
              .filter(ann -> ann.getSeverity().equals(type))
              .map(Annotation::getMessage)
              .collect(Collectors.toList()))
      .contains(message);
}
 
Example #17
Source File: DocumentationUtil.java    From arma-intellij-plugin with MIT License 5 votes vote down vote up
/**
 * Annotates the given comment so that tags like @command, @bis, and @fnc (Arma Intellij Plugin specific tags) are properly annotated
 *
 * @param annotator the annotator
 * @param comment   the comment
 */
public static void annotateDocumentationWithArmaPluginTags(@NotNull AnnotationHolder annotator, @NotNull PsiComment comment) {
	List<String> allowedTags = new ArrayList<>(3);
	allowedTags.add("command");
	allowedTags.add("bis");
	allowedTags.add("fnc");
	Pattern patternTag = Pattern.compile("@([a-zA-Z]+) ([a-zA-Z_0-9]+)");
	Matcher matcher = patternTag.matcher(comment.getText());
	String tag;
	Annotation annotation;
	int startTag, endTag, startArg, endArg;
	while (matcher.find()) {
		if (matcher.groupCount() < 2) {
			continue;
		}
		tag = matcher.group(1);
		if (!allowedTags.contains(tag)) {
			continue;
		}
		startTag = matcher.start(1);
		endTag = matcher.end(1);
		startArg = matcher.start(2);
		endArg = matcher.end(2);
		annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startTag - 1, comment.getTextOffset() + endTag), null);
		annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG);
		annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startArg, comment.getTextOffset() + endArg), null);
		annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG_VALUE);
	}
}
 
Example #18
Source File: DaemonCodeAnalyzerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
static boolean processHighlightsNearOffset(@Nonnull Document document,
                                           @Nonnull Project project,
                                           @Nonnull final HighlightSeverity minSeverity,
                                           final int offset,
                                           final boolean includeFixRange,
                                           @Nonnull final Processor<? super HighlightInfo> processor) {
  return processHighlights(document, project, null, 0, document.getTextLength(), info -> {
    if (!isOffsetInsideHighlightInfo(offset, info, includeFixRange)) return true;

    int compare = info.getSeverity().compareTo(minSeverity);
    return compare < 0 || processor.process(info);
  });
}
 
Example #19
Source File: SeverityRegistrar.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public HighlightSeverity getSeverity(@Nonnull String name) {
  final HighlightInfoType type = STANDARD_SEVERITIES.get(name);
  if (type != null) return type.getSeverity(null);
  final SeverityBasedTextAttributes attributes = myMap.get(name);
  if (attributes != null) return attributes.getSeverity();
  return null;
}
 
Example #20
Source File: ESLintExternalAnnotator.java    From eslint-plugin with MIT License 5 votes vote down vote up
@Override
public void apply(@NotNull PsiFile file, ExternalLintAnnotationResult<Result> annotationResult, @NotNull AnnotationHolder holder) {
    if (annotationResult == null) {
        return;
    }
    InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
    SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
    HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
    EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;

    Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
        return;
    }
    ESLintProjectComponent component = annotationResult.input.project.getComponent(ESLintProjectComponent.class);
    for (VerifyMessage warn : annotationResult.result.warns) {
        HighlightSeverity severity = getHighlightSeverity(warn, component.treatAsWarnings);
        TextAttributes forcedTextAttributes = JSLinterUtil.getTextAttributes(colorsScheme, severityRegistrar, severity);
        Annotation annotation = createAnnotation(holder, file, document, warn, severity, forcedTextAttributes, false);
        if (annotation != null) {
            int offset = StringUtil.lineColToOffset(document.getText(), warn.line - 1, warn.column);
            PsiElement lit = PsiUtil.getElementAtOffset(file, offset);
            BaseActionFix actionFix = Fixes.getFixForRule(warn.ruleId, lit);
            if (actionFix != null) {
                annotation.registerFix(actionFix, null, inspectionKey);
            }
            annotation.registerFix(new SuppressActionFix(warn.ruleId, lit), null, inspectionKey);
            annotation.registerFix(new SuppressLineActionFix(warn.ruleId, lit), null, inspectionKey);
        }
    }
}
 
Example #21
Source File: HighlightInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
public IntentionActionDescriptor(@Nonnull IntentionAction action,
                                 @Nullable List<IntentionAction> options,
                                 @Nullable String displayName,
                                 @Nullable consulo.ui.image.Image icon,
                                 @Nullable HighlightDisplayKey key,
                                 @Nullable ProblemGroup problemGroup,
                                 @Nullable HighlightSeverity severity) {
  myAction = action;
  myOptions = options;
  myDisplayName = displayName;
  myIcon = icon;
  myKey = key;
  myProblemGroup = problemGroup;
  mySeverity = severity;
}
 
Example #22
Source File: HaskellAnnotationHolder.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@Nullable
private Annotation createAnnotation(@NotNull HighlightSeverity severity, @NotNull TextRange range, @Nullable String message) {
    // Skip duplicate messages.
    if (!messages.add(message)) return null;
    String tooltip = message == null ? null : XmlStringUtil.wrapInHtml(escapeSpacesForHtml(XmlStringUtil.escapeString(message)));
    return holder.createAnnotation(severity, range, message, tooltip);
}
 
Example #23
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 #24
Source File: SeverityRegistrar.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public TextAttributes getTextAttributesBySeverity(@Nonnull HighlightSeverity severity) {
  final SeverityBasedTextAttributes infoType = getAttributesBySeverity(severity);
  if (infoType != null) {
    return infoType.getAttributes();
  }
  return null;
}
 
Example #25
Source File: SeverityRegistrar.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static List<HighlightSeverity> getOrderAsList(@Nonnull final OrderMap orderMap) {
  List<HighlightSeverity> list = new ArrayList<HighlightSeverity>();
  for (Object o : orderMap.keys()) {
    list.add((HighlightSeverity)o);
  }
  Collections.sort(list, new Comparator<HighlightSeverity>() {
    @Override
    public int compare(HighlightSeverity o1, HighlightSeverity o2) {
      return SeverityRegistrar.compare(o1, o2, orderMap);
    }
  });
  return list;
}
 
Example #26
Source File: HaxeAnnotation.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public HaxeAnnotation(@NotNull HighlightSeverity severity,
                      @NotNull TextRange range,
                      @Nullable String message,
                      @Nullable String tooltip) {
  this.severity = severity;
  this.range = range;
  this.message = message;
  this.tooltip = tooltip;
}
 
Example #27
Source File: HaxeAnnotationHolder.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
private Annotation findAnnotation(@NotNull HighlightSeverity severity,
                                 @NotNull TextRange range,
                                 @Nullable String message) {
  HashMap<Integer, Annotation> remembered = getRememberedAnnotations();
  if (null != remembered) {
    int hashcode = generateAnnotationHash(range.getStartOffset(), range.getEndOffset(), severity, message);
    if (remembered.containsKey(hashcode)) {
      return remembered.get(hashcode);
    }
  }
  return null;
}
 
Example #28
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 #29
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 #30
Source File: HighlightInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected HighlightInfo(@Nullable TextAttributes forcedTextAttributes,
                        @Nullable TextAttributesKey forcedTextAttributesKey,
                        @Nonnull HighlightInfoType type,
                        int startOffset,
                        int endOffset,
                        @Nullable String escapedDescription,
                        @Nullable String escapedToolTip,
                        @Nonnull HighlightSeverity severity,
                        boolean afterEndOfLine,
                        @Nullable Boolean needsUpdateOnTyping,
                        boolean isFileLevelAnnotation,
                        int navigationShift,
                        ProblemGroup problemGroup,
                        @Nullable String inspectionToolId,
                        GutterMark gutterIconRenderer) {
  if (startOffset < 0 || startOffset > endOffset) {
    LOG.error("Incorrect highlightInfo bounds. description=" + escapedDescription + "; startOffset=" + startOffset + "; endOffset=" + endOffset + ";type=" + type);
  }
  this.forcedTextAttributes = forcedTextAttributes;
  this.forcedTextAttributesKey = forcedTextAttributesKey;
  this.type = type;
  this.startOffset = startOffset;
  this.endOffset = endOffset;
  fixStartOffset = startOffset;
  fixEndOffset = endOffset;
  description = escapedDescription;
  // optimization: do not retain extra memory if can recompute
  toolTip = encodeTooltip(escapedToolTip, escapedDescription);
  this.severity = severity;
  setFlag(AFTER_END_OF_LINE_MASK, afterEndOfLine);
  setFlag(NEEDS_UPDATE_ON_TYPING_MASK, calcNeedUpdateOnTyping(needsUpdateOnTyping, type));
  setFlag(FILE_LEVEL_ANNOTATION_MASK, isFileLevelAnnotation);
  this.navigationShift = navigationShift;
  myProblemGroup = problemGroup;
  this.gutterIconRenderer = gutterIconRenderer;
  this.inspectionToolId = inspectionToolId;
}