public boolean isProperSetting(HighlightDisplayKey key) {
   final Map<String, Boolean> diffMap = getDisplayLevelMap();
   if (diffMap != null) {
     final ToolsImpl tools = myBaseProfile.getTools(key.toString());
     final ToolsImpl currentTools = myTools.get(key.toString());
     if (tools != null && currentTools != null) {
       diffMap.put(key.toString(), tools.equalTo(currentTools));
     } else {
       diffMap.put(key.toString(), tools == currentTools);
     }
     return !diffMap.get(key.toString()).booleanValue();
   }
   return false;
 }
 public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) {
   if (key == null) {
     return false;
   }
   final Tools toolState = getTools(key.toString());
   return toolState != null && toolState.isEnabled(element);
 }
 private HighlightDisplayLevel getErrorLevel(@NotNull HighlightDisplayKey key) {
   final ToolsImpl tools = getTools(key.toString());
   LOG.assertTrue(
       tools != null,
       "profile name: "
           + myName
           + " base profile: "
           + (myBaseProfile != null ? myBaseProfile.getName() : "-")
           + " key: "
           + key);
   return tools != null ? tools.getLevel() : HighlightDisplayLevel.WARNING;
 }
 public HighlightDisplayLevel getErrorLevel(
     @NotNull HighlightDisplayKey inspectionToolKey, PsiElement element) {
   final ToolsImpl tools = getTools(inspectionToolKey.toString());
   HighlightDisplayLevel level =
       tools != null ? tools.getLevel(element) : HighlightDisplayLevel.WARNING;
   if (!((SeverityProvider) getProfileManager())
       .getOwnSeverityRegistrar()
       .isSeverityValid(level.getSeverity().toString())) {
     level = HighlightDisplayLevel.WARNING;
     setErrorLevel(inspectionToolKey, level);
   }
   return level;
 }
 public boolean canCleanup(@NotNull PsiElement element) {
   if (myCanCleanup == null) {
     InspectionProfile profile =
         InspectionProjectProfileManager.getInstance(element.getProject())
             .getInspectionProfile();
     final HighlightDisplayKey key = myKey;
     if (key == null) {
       myCanCleanup = false;
     } else {
       InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element);
       myCanCleanup = toolWrapper != null && toolWrapper.isCleanupTool();
     }
   }
   return myCanCleanup;
 }
    @Nullable
    public List<IntentionAction> getOptions(@NotNull PsiElement element, @Nullable Editor editor) {
      if (editor != null
          && Boolean.FALSE.equals(
              editor.getUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY))) {
        return null;
      }
      List<IntentionAction> options = myOptions;
      HighlightDisplayKey key = myKey;
      if (myProblemGroup != null) {
        String problemName = myProblemGroup.getProblemName();
        HighlightDisplayKey problemGroupKey =
            problemName != null ? HighlightDisplayKey.findById(problemName) : null;
        if (problemGroupKey != null) {
          key = problemGroupKey;
        }
      }
      if (options != null || key == null) {
        return options;
      }
      IntentionManager intentionManager = IntentionManager.getInstance();
      List<IntentionAction> newOptions = intentionManager.getStandardIntentionOptions(key, element);
      InspectionProfile profile =
          InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile();
      InspectionToolWrapper toolWrapper = profile.getInspectionTool(key.toString(), element);
      if (!(toolWrapper instanceof LocalInspectionToolWrapper)) {
        HighlightDisplayKey idkey = HighlightDisplayKey.findById(key.toString());
        if (idkey != null) {
          toolWrapper = profile.getInspectionTool(idkey.toString(), element);
        }
      }
      if (toolWrapper != null) {

        myCanCleanup = toolWrapper.isCleanupTool();

        ContainerUtil.addIfNotNull(
            newOptions, intentionManager.createFixAllIntention(toolWrapper, myAction));
        InspectionProfileEntry wrappedTool =
            toolWrapper instanceof LocalInspectionToolWrapper
                ? ((LocalInspectionToolWrapper) toolWrapper).getTool()
                : ((GlobalInspectionToolWrapper) toolWrapper).getTool();
        if (wrappedTool instanceof CustomSuppressableInspectionTool) {
          final IntentionAction[] suppressActions =
              ((CustomSuppressableInspectionTool) wrappedTool).getSuppressActions(element);
          if (suppressActions != null) {
            ContainerUtil.addAll(newOptions, suppressActions);
          }
        } else {
          SuppressQuickFix[] suppressFixes = wrappedTool.getBatchSuppressActions(element);
          if (suppressFixes.length > 0) {
            ContainerUtil.addAll(
                newOptions,
                ContainerUtil.map(
                    suppressFixes,
                    new Function<SuppressQuickFix, IntentionAction>() {
                      @Override
                      public IntentionAction fun(SuppressQuickFix fix) {
                        return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction(
                            fix);
                      }
                    }));
          }
        }
      }
      if (myProblemGroup instanceof SuppressableProblemGroup) {
        final IntentionAction[] suppressActions =
            ((SuppressableProblemGroup) myProblemGroup).getSuppressActions(element);
        ContainerUtil.addAll(newOptions, suppressActions);
      }

      synchronized (this) {
        options = myOptions;
        if (options == null) {
          myOptions = options = newOptions;
        }
        myKey = null;
      }
      return options;
    }
    @Nullable
    public List<IntentionAction> getOptions(@NotNull PsiElement element, @Nullable Editor editor) {
      if (editor != null
          && Boolean.FALSE.equals(
              editor.getUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY))) {
        return null;
      }
      List<IntentionAction> options = myOptions;
      HighlightDisplayKey key = myKey;
      if (options != null || key == null) {
        return options;
      }
      List<IntentionAction> newOptions =
          IntentionManager.getInstance().getStandardIntentionOptions(key, element);
      InspectionProfile profile =
          InspectionProjectProfileManager.getInstance(element.getProject()).getInspectionProfile();
      InspectionProfileEntry tool = profile.getInspectionTool(key.toString(), element);
      if (!(tool instanceof LocalInspectionToolWrapper)) {
        HighlightDisplayKey idkey = HighlightDisplayKey.findById(key.toString());
        if (idkey != null) {
          tool = profile.getInspectionTool(idkey.toString(), element);
        }
      }
      InspectionProfileEntry wrappedTool = tool;
      if (tool instanceof LocalInspectionToolWrapper) {
        wrappedTool = ((LocalInspectionToolWrapper) tool).getTool();
        Class aClass = myAction.getClass();
        if (myAction instanceof QuickFixWrapper) {
          aClass = ((QuickFixWrapper) myAction).getFix().getClass();
        }
        newOptions.add(new CleanupInspectionIntention((LocalInspectionToolWrapper) tool, aClass));
      } else if (tool instanceof GlobalInspectionToolWrapper) {
        wrappedTool = ((GlobalInspectionToolWrapper) tool).getTool();
        if (wrappedTool instanceof GlobalSimpleInspectionTool
            && (myAction instanceof LocalQuickFix || myAction instanceof QuickFixWrapper)) {
          Class aClass = myAction.getClass();
          if (myAction instanceof QuickFixWrapper) {
            aClass = ((QuickFixWrapper) myAction).getFix().getClass();
          }
          newOptions.add(
              new CleanupInspectionIntention((GlobalInspectionToolWrapper) tool, aClass));
        }
      }

      if (wrappedTool instanceof CustomSuppressableInspectionTool) {
        final IntentionAction[] suppressActions =
            ((CustomSuppressableInspectionTool) wrappedTool).getSuppressActions(element);
        if (suppressActions != null) {
          ContainerUtil.addAll(newOptions, suppressActions);
        }
      }
      if (wrappedTool instanceof BatchSuppressableTool) {
        final SuppressQuickFix[] suppressActions =
            ((BatchSuppressableTool) wrappedTool).getBatchSuppressActions(element);
        ContainerUtil.addAll(
            newOptions,
            ContainerUtil.map(
                suppressActions,
                new Function<SuppressQuickFix, IntentionAction>() {
                  @Override
                  public IntentionAction fun(SuppressQuickFix fix) {
                    return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix);
                  }
                }));
      }

      synchronized (this) {
        options = myOptions;
        if (options == null) {
          myOptions = options = newOptions;
        }
        myKey = null;
      }
      return options;
    }
 @Override
 public boolean isToolEnabled(HighlightDisplayKey key, PsiElement element) {
   return myUseSpellCheck && SPELL_CHECK_TOOLS.containsKey(key.toString());
 }
 public void setErrorLevel(HighlightDisplayKey key, HighlightDisplayLevel level, int scopeIdx) {
   getTools(key.toString()).setLevel(level, scopeIdx);
 }
 public HighlightDisplayLevel getErrorLevel(HighlightDisplayKey key, NamedScope scope) {
   final ToolsImpl tools = getTools(key.toString());
   return tools != null ? tools.getLevel(scope) : HighlightDisplayLevel.WARNING;
 }
 public boolean isToolEnabled(HighlightDisplayKey key, NamedScope namedScope) {
   return getTools(key.toString()).isEnabled(namedScope);
 }
 public boolean isToolEnabled(HighlightDisplayKey key) {
   final Tools toolState = getTools(key.toString());
   return toolState != null && toolState.isEnabled();
 }