コード例 #1
0
 public static TextAttributes getAttributesByType(
     @Nullable final PsiElement element,
     @NotNull HighlightInfoType type,
     @NotNull TextAttributesScheme colorsScheme) {
   final SeverityRegistrar severityRegistrar =
       SeverityRegistrar.getSeverityRegistrar(element != null ? element.getProject() : null);
   final TextAttributes textAttributes =
       severityRegistrar.getTextAttributesBySeverity(type.getSeverity(element));
   if (textAttributes != null) {
     return textAttributes;
   }
   TextAttributesKey key = type.getAttributesKey();
   return colorsScheme.getAttributes(key);
 }
コード例 #2
0
  public static boolean processHighlightsOverlappingOutside(
      @NotNull Document document,
      @NotNull Project project,
      @Nullable("null means all") final HighlightSeverity minSeverity,
      final int startOffset,
      final int endOffset,
      @NotNull final Processor<HighlightInfo> processor) {
    LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed());

    final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
    MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
    return model.processRangeHighlightersOutside(
        startOffset,
        endOffset,
        new Processor<RangeHighlighterEx>() {
          public boolean process(RangeHighlighterEx 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);
          }
        });
  }