private void copyToolsConfigurations(InspectionProfileImpl profile) { try { for (ToolsImpl toolList : profile.myTools.values()) { final ToolsImpl tools = myTools.get(toolList.getShortName()); final ScopeToolState defaultState = toolList.getDefaultState(); tools.setDefaultState( copyToolSettings((InspectionTool) defaultState.getTool()), defaultState.isEnabled(), defaultState.getLevel()); tools.removeAllScopes(); tools.setEnabled(toolList.isEnabled()); final List<ScopeToolState> nonDefaultToolStates = toolList.getNonDefaultTools(); if (nonDefaultToolStates != null) { for (ScopeToolState state : nonDefaultToolStates) { final InspectionTool inspectionTool = copyToolSettings((InspectionTool) state.getTool()); if (state.getScope() != null) { tools.addTool(state.getScope(), inspectionTool, state.isEnabled(), state.getLevel()); } else { tools.addTool( state.getScopeName(), inspectionTool, state.isEnabled(), state.getLevel()); } } } } } catch (WriteExternalException e) { LOG.error(e); } catch (InvalidDataException e) { LOG.error(e); } }
public void setLevel( @NotNull HighlightDisplayLevel level, @Nullable String scopeName, Project project) { if (scopeName == null) { myDefaultState.setLevel(level); } else { if (myTools == null) { return; } ScopeToolState scopeToolState = null; int index = -1; for (int i = 0; i < myTools.size(); i++) { ScopeToolState tool = myTools.get(i); if (scopeName.equals(tool.getScopeName())) { scopeToolState = tool; myTools.remove(tool); index = i; break; } } if (index < 0) { throw new IllegalStateException("Scope " + scopeName + " not found"); } final InspectionToolWrapper toolWrapper = scopeToolState.getTool(); final NamedScope scope = scopeToolState.getScope(project); if (scope != null) { myTools.add( index, new ScopeToolState(scope, toolWrapper, scopeToolState.isEnabled(), level)); } else { myTools.add( index, new ScopeToolState( scopeToolState.getScopeName(), toolWrapper, scopeToolState.isEnabled(), level)); } } }
public void disableTool(@NotNull PsiElement element) { final Project project = element.getProject(); final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project); if (myTools != null) { for (ScopeToolState state : myTools) { final NamedScope scope = state.getScope(project); if (scope != null) { final PackageSet packageSet = scope.getValue(); if (packageSet != null) { final PsiFile file = element.getContainingFile(); if (file != null) { if (packageSet.contains(file, validationManager)) { state.setEnabled(false); return; } } else { if (packageSet instanceof PackageSetBase && ((PackageSetBase) packageSet) .contains(PsiUtilCore.getVirtualFile(element), project, validationManager)) { state.setEnabled(false); return; } } } } } myDefaultState.setEnabled(false); } else { myDefaultState.setEnabled(false); setEnabled(false); } }
@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; }
@NotNull @Override public InspectionToolWrapper getInspectionTool(PsiElement element) { if (myTools != null) { final PsiFile containingFile = element == null ? null : element.getContainingFile(); final Project project = containingFile == null ? null : containingFile.getProject(); for (ScopeToolState state : myTools) { if (element == null) { return state.getTool(); } NamedScope scope = state.getScope(project); if (scope != null) { final PackageSet packageSet = scope.getValue(); if (packageSet != null) { if (containingFile != null && packageSet.contains( containingFile, DependencyValidationManager.getInstance(project))) { return state.getTool(); } } } } } return myDefaultState.getTool(); }
public void disableTool(NamedScope namedScope, Project project) { if (myTools != null) { for (ScopeToolState state : myTools) { if (Comparing.equal(state.getScope(project), namedScope)) { state.setEnabled(false); } } } }
public boolean isEnabled(NamedScope namedScope, Project project) { if (!myEnabled) return false; if (namedScope != null && myTools != null) { for (ScopeToolState state : myTools) { if (Comparing.equal(namedScope, state.getScope(project))) return state.isEnabled(); } } return myDefaultState.isEnabled(); }
@NotNull public HighlightDisplayLevel getLevel(final NamedScope scope, Project project) { if (myTools != null && scope != null) { for (ScopeToolState state : myTools) { if (Comparing.equal(state.getScope(project), scope)) { return state.getLevel(); } } } return myDefaultState.getLevel(); }
public HighlightDisplayLevel getLevel(PsiElement element) { if (myTools == null || element == null) return myDefaultState.getLevel(); final Project project = element.getProject(); final DependencyValidationManager manager = DependencyValidationManager.getInstance(project); for (ScopeToolState state : myTools) { final NamedScope scope = state.getScope(project); final PackageSet set = scope != null ? scope.getValue() : null; if (set != null && set.contains(element.getContainingFile(), manager)) { return state.getLevel(); } } return myDefaultState.getLevel(); }
@Override public boolean isEnabled(PsiElement element) { if (!myEnabled) return false; if (myTools == null || element == null) return myDefaultState.isEnabled(); 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(); } } } return myDefaultState.isEnabled(); }
private boolean buildTree() { InspectionProfile profile = myInspectionProfile; boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY; myGroups.clear(); final Map<String, Tools> tools = myGlobalInspectionContext.getTools(); boolean resultsFound = false; for (Tools currentTools : tools.values()) { InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool(); final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName()); for (ScopeToolState state : myProvider.getTools(currentTools)) { InspectionToolWrapper toolWrapper = state.getTool(); if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) { addTool( toolWrapper, ((InspectionProfileImpl) profile) .getErrorLevel(key, state.getScope(myProject), myProject), isGroupedBySeverity); resultsFound = true; } } } return resultsFound; }