Search in sources :

Example 1 with ScopeToolState

use of com.intellij.codeInspection.ex.ScopeToolState in project intellij-community by JetBrains.

the class InspectionsFilter method matches.

public boolean matches(@NotNull Tools tools, final InspectionConfigTreeNode node) {
    if (myShowOnlyCleanupInspections && !tools.getTool().isCleanupTool()) {
        return false;
    }
    if (mySuitableInspectionsStates != null && mySuitableInspectionsStates != tools.isEnabled()) {
        return false;
    }
    if (myAvailableOnlyForAnalyze && !isAvailableOnlyForAnalyze(tools)) {
        return false;
    }
    if (!mySuitableSeverities.isEmpty()) {
        boolean suitable = false;
        for (final ScopeToolState state : tools.getTools()) {
            if (mySuitableInspectionsStates != null && mySuitableInspectionsStates != state.isEnabled()) {
                continue;
            }
            if (mySuitableSeverities.contains(tools.getDefaultState().getLevel().getSeverity())) {
                suitable = true;
                break;
            }
        }
        if (!suitable) {
            return false;
        }
    }
    final String languageId = tools.getDefaultState().getTool().getLanguage();
    final boolean containsInSuitableLanguages = mySuitableLanguageIds.isEmpty() || mySuitableLanguageIds.contains(languageId);
    if (!containsInSuitableLanguages) {
        return false;
    }
    return !myShowOnlyModifiedInspections || node.isProperSetting();
}
Also used : ScopeToolState(com.intellij.codeInspection.ex.ScopeToolState)

Example 2 with ScopeToolState

use of com.intellij.codeInspection.ex.ScopeToolState in project intellij-community by JetBrains.

the class ExportHTMLAction method getWorkedTools.

@NotNull
private Set<InspectionToolWrapper> getWorkedTools(@NotNull InspectionNode node) {
    final Set<InspectionToolWrapper> result = new HashSet<>();
    final InspectionToolWrapper wrapper = node.getToolWrapper();
    if (myView.getCurrentProfileName() == null) {
        result.add(wrapper);
        return result;
    }
    final String shortName = wrapper.getShortName();
    final GlobalInspectionContextImpl context = myView.getGlobalInspectionContext();
    final Tools tools = context.getTools().get(shortName);
    if (tools != null) {
        //dummy entry points tool
        for (ScopeToolState state : tools.getTools()) {
            InspectionToolWrapper toolWrapper = state.getTool();
            result.add(toolWrapper);
        }
    }
    return result;
}
Also used : GlobalInspectionContextImpl(com.intellij.codeInspection.ex.GlobalInspectionContextImpl) ScopeToolState(com.intellij.codeInspection.ex.ScopeToolState) Tools(com.intellij.codeInspection.ex.Tools) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper) THashSet(gnu.trove.THashSet) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ScopeToolState

use of com.intellij.codeInspection.ex.ScopeToolState in project intellij-community by JetBrains.

the class ToolDescriptors method fromScopeToolState.

public static ToolDescriptors fromScopeToolState(final ScopeToolState state, @NotNull InspectionProfileModifiableModel profile, final Project project) {
    List<ScopeToolState> nonDefaultTools = profile.getNonDefaultTools(state.getTool().getShortName(), project);
    ArrayList<Descriptor> descriptors = new ArrayList<>(nonDefaultTools.size());
    for (final ScopeToolState nonDefaultToolState : nonDefaultTools) {
        descriptors.add(new Descriptor(nonDefaultToolState, profile, project));
    }
    return new ToolDescriptors(new Descriptor(state, profile, project), descriptors);
}
Also used : ScopeToolState(com.intellij.codeInspection.ex.ScopeToolState) ArrayList(java.util.ArrayList) Descriptor(com.intellij.codeInspection.ex.Descriptor)

Example 4 with ScopeToolState

use of com.intellij.codeInspection.ex.ScopeToolState in project intellij-community by JetBrains.

the class InspectionFilterAction method tune.

private void tune(InspectionProfileImpl profile, Project project) {
    addAction(new ResetFilterAction());
    addSeparator();
    if (ApplicationNamesInfo.getInstance().getProductName().contains("IDEA")) {
        // minor IDEs don't have "New in XXX" in inspection descriptions
        addAction(new ShowNewInspectionsAction());
    }
    addSeparator();
    addAction(new ShowEnabledOrDisabledInspectionsAction(true));
    addAction(new ShowEnabledOrDisabledInspectionsAction(false));
    addAction(new ShowOnlyModifiedInspectionsAction());
    addSeparator();
    for (final HighlightSeverity severity : LevelChooserAction.getSeverities(mySeverityRegistrar)) {
        add(new ShowWithSpecifiedSeverityInspectionsAction(severity));
    }
    addSeparator();
    final Set<String> languageIds = new THashSet<>();
    for (ScopeToolState state : profile.getDefaultStates(project)) {
        languageIds.add(state.getTool().getLanguage());
    }
    final List<Language> languages = new SmartList<>();
    for (String id : languageIds) {
        if (id != null) {
            final Language language = Language.findLanguageByID(id);
            if (language != null) {
                languages.add(language);
            }
        }
    }
    if (!languages.isEmpty()) {
        final DefaultActionGroup languageActionGroupParent = new DefaultActionGroup("Filter by Language", languages.size() >= MIN_LANGUAGE_COUNT_TO_WRAP);
        add(languageActionGroupParent);
        Collections.sort(languages, Comparator.comparing(Language::getDisplayName));
        for (Language language : languages) {
            languageActionGroupParent.add(new LanguageFilterAction(language));
        }
        languageActionGroupParent.add(new LanguageFilterAction(null));
        addSeparator();
    }
    add(new ShowAvailableOnlyOnAnalyzeInspectionsAction());
    add(new ShowOnlyCleanupInspectionsAction());
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) ScopeToolState(com.intellij.codeInspection.ex.ScopeToolState) THashSet(gnu.trove.THashSet) Language(com.intellij.lang.Language) SmartList(com.intellij.util.SmartList)

Aggregations

ScopeToolState (com.intellij.codeInspection.ex.ScopeToolState)4 THashSet (gnu.trove.THashSet)2 Descriptor (com.intellij.codeInspection.ex.Descriptor)1 GlobalInspectionContextImpl (com.intellij.codeInspection.ex.GlobalInspectionContextImpl)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 Tools (com.intellij.codeInspection.ex.Tools)1 Language (com.intellij.lang.Language)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1 SmartList (com.intellij.util.SmartList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NotNull (org.jetbrains.annotations.NotNull)1