예제 #1
0
 @Nullable
 @Override
 public InspectionToolWrapper getEnabledTool(
     @Nullable PsiElement element, boolean includeDoNotShow) {
   if (!myEnabled) return null;
   if (myTools != null && element != null) {
     final Project project = element.getProject();
     final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
     for (ScopeToolState state : myTools) {
       final NamedScope scope = state.getScope(project);
       if (scope != null) {
         final PackageSet set = scope.getValue();
         if (set != null && set.contains(element.getContainingFile(), manager)) {
           return state.isEnabled()
                   && (includeDoNotShow
                       || !HighlightDisplayLevel.DO_NOT_SHOW.equals(state.getLevel()))
               ? state.getTool()
               : null;
         }
       }
     }
   }
   return myDefaultState.isEnabled()
           && (includeDoNotShow
               || !HighlightDisplayLevel.DO_NOT_SHOW.equals(myDefaultState.getLevel()))
       ? myDefaultState.getTool()
       : null;
 }
  private Icon getIcon(DaemonCodeAnalyzerStatus status) {
    if (status == null) {
      return NO_ICON;
    }
    if (status.noHighlightingRoots != null
        && status.noHighlightingRoots.length == status.rootsNumber) {
      return NO_ANALYSIS_ICON;
    }

    Icon icon = HighlightDisplayLevel.DO_NOT_SHOW.getIcon();
    for (int i = status.errorCount.length - 1; i >= 0; i--) {
      if (status.errorCount[i] != 0) {
        icon = mySeverityRegistrar.getRendererIconByIndex(i);
        break;
      }
    }

    if (status.errorAnalyzingFinished) {
      if (myProject != null && DumbService.isDumb(myProject)) {
        return new LayeredIcon(NO_ANALYSIS_ICON, icon, STARING_EYE_ICON);
      }

      return icon;
    }
    if (!status.enabled) return NO_ANALYSIS_ICON;

    double progress = getOverallProgress(status);
    TruncatingIcon trunc =
        new TruncatingIcon(icon, icon.getIconWidth(), (int) (icon.getIconHeight() * progress));

    return new LayeredIcon(NO_ANALYSIS_ICON, trunc, STARING_EYE_ICON);
  }