avoid InspectionProfileImpl class cast

This commit is contained in:
Vladimir Krivosheev
2016-10-27 16:30:27 +02:00
parent a91e9b852c
commit 6dbe6b27f5
32 changed files with 108 additions and 134 deletions
@@ -22,7 +22,6 @@ package com.intellij.codeInsight.highlighting;
import com.intellij.codeInsight.daemon.impl.*;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.ex.*;
import com.intellij.codeInspection.reference.RefManagerImpl;
import com.intellij.openapi.diagnostic.Logger;
@@ -113,14 +112,13 @@ class HighlightSuppressedWarningsHandler extends HighlightUsagesHandlerBase<PsiL
parent.getTextRange().getStartOffset(), parent.getTextRange().getEndOffset(),
myPriorityRange,
false, HighlightInfoProcessor.getEmpty());
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
InspectionProfileImpl inspectionProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
for (PsiLiteralExpression target : targets) {
final Object value = target.getValue();
if (!(value instanceof String)) {
continue;
}
List<InspectionToolWrapper> tools = ((InspectionProfileImpl)inspectionProfile).findToolsById((String)value, target);
List<InspectionToolWrapper> tools = inspectionProfile.findToolsById((String)value, target);
if (tools == null) {
continue;
}
@@ -24,7 +24,6 @@ import com.intellij.codeInspection.dataFlow.DataFlowInspection;
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.BaseInspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
@@ -220,7 +219,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
"</profile>");
InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo"));
profile.readExternal(element);
ModifiableModel model = profile.getModifiableModel();
InspectionProfileImpl model = profile.getModifiableModel();
model.commit();
assertThat(profile.writeScheme()).isEqualTo(element);
@@ -268,7 +267,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
profile = createProfile(new InspectionProfileImpl("foo"));
profile.readExternal(unusedProfile);
model = profile.getModifiableModel();
InspectionToolWrapper toolWrapper = ((InspectionProfileImpl)model).getInspectionTool("unused", getProject());
InspectionToolWrapper toolWrapper = model.getInspectionTool("unused", getProject());
UnusedDeclarationInspectionBase tool = (UnusedDeclarationInspectionBase)toolWrapper.getTool();
tool.ADD_NONJAVA_TO_ENTRIES = true;
UnusedSymbolLocalInspectionBase inspectionTool = tool.getSharedLocalInspectionTool();
@@ -566,7 +565,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
foo.initInspectionTools(getProject());
assertEquals(0, countInitializedTools(foo));
ModifiableModel model = foo.getModifiableModel();
InspectionProfileImpl model = foo.getModifiableModel();
assertEquals(0, countInitializedTools(model));
model.commit();
assertEquals(0, countInitializedTools(model));
@@ -574,7 +573,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
model = foo.getModifiableModel();
assertEquals(0, countInitializedTools(model));
List<ScopeToolState> tools = ((InspectionProfileImpl)model).getAllTools(getProject());
List<ScopeToolState> tools = model.getAllTools(getProject());
for (ScopeToolState tool : tools) {
if (!tool.isEnabled()) {
tool.setEnabled(true);
@@ -623,8 +622,8 @@ public class InspectionProfileTest extends LightIdeaTestCase {
assertEquals(1, countInitializedTools(foo));
}
public static int countInitializedTools(@NotNull Profile foo) {
return getInitializedTools((InspectionProfileImpl)foo).size();
public static int countInitializedTools(@NotNull InspectionProfileImpl foo) {
return getInitializedTools(foo).size();
}
@NotNull
@@ -52,7 +52,7 @@ class InspectionSchemeTest {
profileManager.initProfiles()
assertThat(profileManager.profiles).hasSize(1)
val scheme = profileManager.profiles.first() as InspectionProfileImpl
val scheme = profileManager.profiles.first()
assertThat(scheme.name).isEqualTo("Bar")
runInInitMode { scheme.initInspectionTools(null) }
@@ -24,7 +24,6 @@ import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.IntentionManager;
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.codeInspection.InspectionToolProvider;
import com.intellij.codeInspection.LocalInspectionTool;
@@ -152,9 +151,9 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase {
}
protected void disableInspectionTool(@NotNull String shortName){
InspectionProfile profile = InspectionProjectProfileManager.getInstance(getProject()).getCurrentProfile();
InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(getProject()).getCurrentProfile();
if (profile.getInspectionTool(shortName, getProject()) != null) {
((InspectionProfileImpl)profile).disableTool(shortName, getProject());
profile.disableTool(shortName, getProject());
}
}
@@ -116,7 +116,7 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G
ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstanceImpl(myProject);
InspectionProfileImpl profile = profileManager.getProfile(currentProfile, false);
if (profile == null) {
profile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getProfile(currentProfile);
profile = InspectionProfileManager.getInstance().getProfile(currentProfile);
if (profile != null) {
return profile;
}
@@ -195,7 +195,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
}
@Override
public InspectionProfile getParentProfile() {
public InspectionProfileImpl getParentProfile() {
return mySource;
}
@@ -878,7 +878,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
for (Element scopeElement : scopes.getChildren(SCOPE)) {
final String profile = scopeElement.getAttributeValue(PROFILE);
InspectionProfileImpl inspectionProfile = profile == null ? null : (InspectionProfileImpl)getProfileManager().getProfile(profile);
InspectionProfileImpl inspectionProfile = profile == null ? null : getProfileManager().getProfile(profile);
NamedScope scope = inspectionProfile == null ? null : getProfileManager().getScopesManager().getScope(scopeElement.getAttributeValue(NAME));
if (scope == null) {
continue;
@@ -16,7 +16,7 @@
package com.intellij.profile.codeInspection;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
@@ -32,7 +32,7 @@ public interface InspectionProfileManager {
String INSPECTION_DIR = "inspection";
@NotNull
Collection<InspectionProfile> getProfiles();
Collection<InspectionProfileImpl> getProfiles();
default NamedScopesHolder getScopesManager() {
return null;
@@ -61,11 +61,11 @@ public interface InspectionProfileManager {
}
@NotNull
InspectionProfile getCurrentProfile();
InspectionProfileImpl getCurrentProfile();
InspectionProfile getProfile(@NotNull String name, boolean returnRootProfileIfNamedIsAbsent);
InspectionProfileImpl getProfile(@NotNull String name, boolean returnRootProfileIfNamedIsAbsent);
default InspectionProfile getProfile(@NotNull String name) {
default InspectionProfileImpl getProfile(@NotNull String name) {
return getProfile(name, true);
}
@@ -36,10 +36,10 @@ public abstract class InspectionProjectProfileManager implements InspectionProfi
}
/**
* @deprecated use {@link #getCurrentProfile()} instead
* @deprecated use {@link #getCurrentProfile()} instead
*/
@NotNull
public InspectionProfile getInspectionProfile(PsiElement element){
public InspectionProfile getInspectionProfile(PsiElement element) {
return getCurrentProfile();
}
@@ -263,7 +263,7 @@ class ProjectInspectionProfileManager(val project: Project,
override fun getScopesManager() = scopeManager
@Synchronized override fun getProfiles(): Collection<InspectionProfile> {
@Synchronized override fun getProfiles(): Collection<InspectionProfileImpl> {
currentProfile
return schemeManager.allSchemes
}
@@ -297,7 +297,7 @@ class ProjectInspectionProfileManager(val project: Project,
if (!state.useProjectProfile) {
return (state.projectProfile?.let {
applicationProfileManager.getProfile(it, false)
} ?: applicationProfileManager.currentProfile) as InspectionProfileImpl
} ?: applicationProfileManager.currentProfile)
}
var currentScheme = schemeManager.currentScheme
@@ -330,6 +330,6 @@ class ProjectInspectionProfileManager(val project: Project,
@Synchronized override fun getProfile(name: String, returnRootProfileIfNamedIsAbsent: Boolean): InspectionProfileImpl? {
val profile = schemeManager.findSchemeByName(name)
return profile ?: applicationProfileManager.getProfile(name, returnRootProfileIfNamedIsAbsent) as InspectionProfileImpl?
return profile ?: applicationProfileManager.getProfile(name, returnRootProfileIfNamedIsAbsent)
}
}
@@ -36,7 +36,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiManager;
@@ -149,12 +148,12 @@ public class InspectionApplication {
logMessageLn(1, InspectionsBundle.message("inspection.done"));
logMessage(1, InspectionsBundle.message("inspection.application.initializing.project"));
Profile inspectionProfile = loadInspectionProfile();
InspectionProfileImpl inspectionProfile = loadInspectionProfile();
if (inspectionProfile == null) return;
final InspectionManagerEx im = (InspectionManagerEx)InspectionManager.getInstance(myProject);
im.createNewGlobalContext(true).setExternalProfile((InspectionProfileImpl)inspectionProfile);
im.createNewGlobalContext(true).setExternalProfile(inspectionProfile);
im.setProfile(inspectionProfile.getName());
final AnalysisScope scope;
@@ -257,7 +256,7 @@ public class InspectionApplication {
final String descriptionsFile = resultsDataPath + File.separatorChar + DESCRIPTIONS + XML_EXTENSION;
describeInspections(descriptionsFile,
myRunWithEditorSettings ? null : inspectionProfile.getName(),
(InspectionProfile)inspectionProfile);
inspectionProfile);
inspectionsResults.add(new File(descriptionsFile));
// convert report
if (reportConverter != null) {
@@ -339,7 +338,7 @@ public class InspectionApplication {
if (inspectionProfile != null) return inspectionProfile;
}
inspectionProfile = (InspectionProfileImpl)InspectionProjectProfileManager.getInstance(myProject).getCurrentProfile();
inspectionProfile = InspectionProjectProfileManager.getInstance(myProject).getCurrentProfile();
logError("Using default project profile");
}
return inspectionProfile;
@@ -356,16 +355,15 @@ public class InspectionApplication {
@Nullable
private InspectionProfileImpl loadProfileByName(final String profileName) {
InspectionProfileImpl inspectionProfile =
(InspectionProfileImpl)InspectionProjectProfileManager.getInstance(myProject).getProfile(profileName, false);
InspectionProfileImpl inspectionProfile = InspectionProjectProfileManager.getInstance(myProject).getProfile(profileName, false);
if (inspectionProfile != null) {
logMessageLn(1, "Loaded shared project profile \'" + profileName + "\'");
}
else {
//check if ide profile is used for project
for (InspectionProfile profile : InspectionProjectProfileManager.getInstance(myProject).getProfiles()) {
for (InspectionProfileImpl profile : InspectionProjectProfileManager.getInstance(myProject).getProfiles()) {
if (Comparing.strEqual(profile.getName(), profileName)) {
inspectionProfile = (InspectionProfileImpl)profile;
inspectionProfile = profile;
logMessageLn(1, "Loaded local profile \'" + profileName + "\'");
break;
}
@@ -158,7 +158,7 @@ public class CodeInspectionAction extends BaseAnalysisAction {
@Override
protected void addProfile(InspectionProfileImpl model) {
super.addProfile(model);
myProfilesCombo.addProfile((InspectionProfileImpl)model.getParentProfile());
myProfilesCombo.addProfile(model.getParentProfile());
}
@Override
@@ -178,12 +178,12 @@ public class CodeInspectionAction extends BaseAnalysisAction {
InspectionProfileManager inspectionProfileManager,
InspectionProjectProfileManager inspectionProjectProfileManager,
InspectionManagerEx inspectionManager) {
final InspectionProfile selectedProfile = getGlobalInspectionContext(inspectionManager.getProject()).getCurrentProfile();
List<Profile> profiles = new ArrayList<>();
InspectionProfileImpl selectedProfile = getGlobalInspectionContext(inspectionManager.getProject()).getCurrentProfile();
List<InspectionProfileImpl> profiles = new ArrayList<>();
profiles.addAll(inspectionProfileManager.getProfiles());
profiles.addAll(inspectionProjectProfileManager.getProfiles());
profilesCombo.reset(profiles);
profilesCombo.selectProfile((InspectionProfileImpl)selectedProfile);
profilesCombo.selectProfile(selectedProfile);
}
private static class AdditionalPanel {
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
import com.intellij.codeInspection.ex.InspectionManagerEx;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -50,7 +49,7 @@ public class CodeInspectionOnEditorAction extends AnAction {
final AnalysisScope scope = new AnalysisScope(psiFile);
final GlobalInspectionContextImpl inspectionContext = inspectionManagerEx.createNewGlobalContext(false);
inspectionContext.setCurrentScope(scope);
inspectionContext.setExternalProfile((InspectionProfileImpl)InspectionProjectProfileManager.getInstance(project).getCurrentProfile());
inspectionContext.setExternalProfile(InspectionProjectProfileManager.getInstance(project).getCurrentProfile());
inspectionContext.doInspections(scope);
}
@@ -42,7 +42,7 @@ public class GotoInspectionModel extends SimpleChooseByNameModel {
public GotoInspectionModel(Project project) {
super(project, IdeBundle.message("prompt.goto.inspection.enter.name"), "goto.inspection.help.id");
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getCurrentProfile();
final InspectionProfileImpl rootProfile = InspectionProfileManager.getInstance().getCurrentProfile();
for (ScopeToolState state : rootProfile.getAllTools(project)) {
InspectionToolWrapper tool = LocalInspectionToolWrapper.findTool2RunInBatch(project, null, rootProfile, state.getTool());
if (tool != null) {
@@ -135,7 +135,7 @@ public class RunInspectionIntention implements IntentionAction, HighPriorityActi
public static InspectionProfileImpl createProfile(@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionManagerEx managerEx,
@Nullable PsiElement psiElement) {
InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getCurrentProfile();
InspectionProfileImpl rootProfile = InspectionProfileManager.getInstance().getCurrentProfile();
LinkedHashSet<InspectionToolWrapper> allWrappers = new LinkedHashSet<>();
allWrappers.add(toolWrapper);
rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.getProject());
@@ -49,7 +49,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
@@ -146,7 +145,7 @@ public class ViewOfflineResultsAction extends AnAction {
final String profileName,
@NotNull final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
@NotNull String title) {
Profile profile;
InspectionProfileImpl profile;
if (profileName != null) {
profile = InspectionProjectProfileManager.getInstance(project).getProfile(profileName, false);
if (profile == null) {
@@ -158,7 +157,7 @@ public class ViewOfflineResultsAction extends AnAction {
}
final InspectionProfileImpl inspectionProfile;
if (profile != null) {
inspectionProfile = (InspectionProfileImpl)profile;
inspectionProfile = profile;
}
else {
inspectionProfile = new InspectionProfileImpl(profileName != null ? profileName : "Server Side") {
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeveritiesProvider;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.configurationStore.BundledSchemeEP;
import com.intellij.configurationStore.SchemeDataHolder;
@@ -149,7 +148,7 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
@Override
@NotNull
public Collection<InspectionProfile> getProfiles() {
public Collection<InspectionProfileImpl> getProfiles() {
initProfiles();
return Collections.unmodifiableList(mySchemeManager.getAllSchemes());
}
@@ -19,9 +19,7 @@ package com.intellij.codeInspection.ex;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
@@ -46,10 +44,6 @@ import java.util.function.Consumer;
public class EditInspectionToolsSettingsAction implements IntentionAction, Iconable, HighPriorityAction {
private final String myShortName;
public EditInspectionToolsSettingsAction(@NotNull LocalInspectionTool tool) {
myShortName = tool.getShortName();
}
public EditInspectionToolsSettingsAction(@NotNull HighlightDisplayKey key) {
myShortName = key.toString();
}
@@ -74,31 +68,27 @@ public class EditInspectionToolsSettingsAction implements IntentionAction, Icona
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
InspectionProfile inspectionProfile = projectProfileManager.getCurrentProfile();
InspectionProfileImpl inspectionProfile = projectProfileManager.getCurrentProfile();
editToolSettings(project,
inspectionProfile, true,
inspectionProfile,
myShortName);
}
public boolean editToolSettings(final Project project,
final InspectionProfileImpl inspectionProfile,
final boolean canChooseDifferentProfiles) {
final InspectionProfileImpl inspectionProfile) {
return editToolSettings(project,
inspectionProfile,
canChooseDifferentProfiles,
myShortName);
}
public static boolean editToolSettings(final Project project,
final InspectionProfile inspectionProfile,
final boolean canChooseDifferentProfile,
final InspectionProfileImpl inspectionProfile,
final String selectedToolShortName) {
return editSettings(project, inspectionProfile, canChooseDifferentProfile, c -> c.selectInspectionTool(selectedToolShortName));
return editSettings(project, inspectionProfile, c -> c.selectInspectionTool(selectedToolShortName));
}
public static boolean editSettings(final Project project,
final InspectionProfile inspectionProfile,
final boolean canChooseDifferentProfile,
final InspectionProfileImpl inspectionProfile,
final Consumer<ErrorsConfigurable> configurableAction) {
final ShowSettingsUtil settingsUtil = ShowSettingsUtil.getInstance();
final ErrorsConfigurable errorsConfigurable = new ProjectInspectionToolsConfigurable(ProjectInspectionProfileManager.getInstanceImpl(project)) {
@@ -90,7 +90,7 @@ public class EditInspectionToolsSettingsInSuppressedPlaceIntention implements In
@Nullable
private InspectionToolWrapper getTool(final Project project, final PsiFile file) {
final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getCurrentProfile();
final InspectionProfileImpl inspectionProfile = projectProfileManager.getCurrentProfile();
return inspectionProfile.getToolById(myId, file);
}
@@ -99,8 +99,8 @@ public class EditInspectionToolsSettingsInSuppressedPlaceIntention implements In
InspectionToolWrapper toolWrapper = getTool(project, file);
if (toolWrapper == null) return;
final InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)projectProfileManager.getCurrentProfile();
EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, false, toolWrapper.getShortName());
final InspectionProfileImpl inspectionProfile = projectProfileManager.getCurrentProfile();
EditInspectionToolsSettingsAction.editToolSettings(project, inspectionProfile, toolWrapper.getShortName());
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package com.intellij.codeInspection.ui;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.ToolsImpl;
@@ -29,9 +28,9 @@ import org.jetbrains.annotations.Nullable;
public class InspectionNode extends InspectionTreeNode {
@NotNull private final InspectionProfileImpl myProfile;
public InspectionNode(@NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionProfile profile) {
public InspectionNode(@NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionProfileImpl profile) {
super(toolWrapper);
myProfile = (InspectionProfileImpl)profile;
myProfile = profile;
}
public String toString() {
@@ -50,8 +50,7 @@ public class InspectionNodeInfo extends JPanel {
setBorder(IdeBorderFactory.createEmptyBorder(11, 0, 0, 0));
final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(false);
LOG.assertTrue(toolWrapper != null);
InspectionProfileImpl currentProfile =
(InspectionProfileImpl)InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
InspectionProfileImpl currentProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final ToolsImpl tools = currentProfile.getTools(toolWrapper.getShortName(), project);
boolean enabled = tools.isEnabled();
@@ -701,7 +701,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
return myInspectionProfile == null ? null : myInspectionProfile.getDisplayName();
}
public InspectionProfile getCurrentProfile() {
public InspectionProfileImpl getCurrentProfile() {
return myInspectionProfile;
}
@@ -1130,7 +1130,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
public void updateCurrentProfile() {
final String name = myInspectionProfile.getName();
myInspectionProfile = (InspectionProfileImpl)myInspectionProfile.getProfileManager().getProfile(name);
myInspectionProfile = myInspectionProfile.getProfileManager().getProfile(name);
}
private class RerunAction extends AnAction {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
myElement = element;
myDescriptor = descriptor;
myToolWrapper = toolWrapper;
final InspectionProfileImpl profile = (InspectionProfileImpl)presentation.getContext().getCurrentProfile();
final InspectionProfileImpl profile = presentation.getContext().getCurrentProfile();
myLevel = descriptor instanceof ProblemDescriptor
? profile
.getErrorLevel(HighlightDisplayKey.find(toolWrapper.getShortName()), ((ProblemDescriptor)descriptor).getStartElement())
@@ -16,7 +16,6 @@
package com.intellij.codeInspection.ui.actions;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
@@ -44,7 +43,7 @@ public class EditSettingsAction extends InspectionViewActionBase {
@Override
public void actionPerformed(AnActionEvent e) {
final InspectionResultsView view = getView(e);
InspectionProfile inspectionProfile = view.getCurrentProfile();
InspectionProfileImpl inspectionProfile = view.getCurrentProfile();
if (view.isSingleInspectionRun()) {
InspectionToolWrapper tool = inspectionProfile.getInspectionTool(inspectionProfile.getSingleTool(), view.getProject());
@@ -80,7 +79,7 @@ public class EditSettingsAction extends InspectionViewActionBase {
if (toolWrapper != null) {
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); //do not search for dead code entry point tool
if (key != null) {
if (new EditInspectionToolsSettingsAction(key).editToolSettings(view.getProject(), (InspectionProfileImpl)inspectionProfile, false)) {
if (new EditInspectionToolsSettingsAction(key).editToolSettings(view.getProject(), inspectionProfile)) {
view.updateCurrentProfile();
}
return;
@@ -88,7 +87,7 @@ public class EditSettingsAction extends InspectionViewActionBase {
}
final String[] path = view.getTree().getSelectedGroupPath();
if (EditInspectionToolsSettingsAction.editSettings(view.getProject(), inspectionProfile, false, (c) -> {
if (EditInspectionToolsSettingsAction.editSettings(view.getProject(), inspectionProfile, (c) -> {
if (path != null) {
c.selectInspectionGroup(path);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,22 +16,22 @@
package com.intellij.profile.codeInspection.ui;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ex.ConfigurableExtensionPointUtil;
import com.intellij.openapi.project.Project;
import com.intellij.profile.Profile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Marker interface for the configurable which is used to configure the current inspection profile.
* Marker interface for the configurable which is used to configure the current inspection profile.
*
* @author yole
*/
public interface ErrorsConfigurable extends Configurable {
void selectProfile(final Profile profile);
void selectProfile(InspectionProfileImpl profile);
void selectInspectionTool(final String selectedToolShortName);
void selectInspectionGroup(final String[] groupPath);
@Nullable
Object getSelectedObject();
}
@@ -22,7 +22,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ModifiableModel;
import com.intellij.codeInspection.ex.*;
import com.intellij.icons.AllIcons;
import com.intellij.ide.CommonActionsManager;
@@ -124,10 +123,10 @@ public class SingleInspectionProfilePanel extends JPanel {
};
public SingleInspectionProfilePanel(@NotNull ProjectInspectionProfileManager projectProfileManager,
@NotNull ModifiableModel profile) {
@NotNull InspectionProfileImpl profile) {
super(new BorderLayout());
myProjectProfileManager = projectProfileManager;
myProfile = (InspectionProfileImpl)profile;
myProfile = profile;
}
public Map<HighlightDisplayKey, ToolDescriptors> getInitialToolDescriptors() {
@@ -608,7 +607,7 @@ public class SingleInspectionProfilePanel extends JPanel {
if (!myIsInRestore) {
InspectionProfileImpl selected = myProfile;
if (selected != null) {
InspectionProfileImpl baseProfile = (InspectionProfileImpl)selected.getParentProfile();
InspectionProfileImpl baseProfile = selected.getParentProfile();
if (baseProfile != null) {
getExpandedNodes(baseProfile).setSelectionPaths(myTreeTable.getTree().getSelectionPaths());
}
@@ -655,7 +654,7 @@ public class SingleInspectionProfilePanel extends JPanel {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
InspectionProfileImpl selected = myProfile;
final InspectionProfileImpl parentProfile = (InspectionProfileImpl)selected.getParentProfile();
final InspectionProfileImpl parentProfile = selected.getParentProfile();
if (parentProfile != null) {
getExpandedNodes(parentProfile).saveVisibleState(myTreeTable.getTree());
}
@@ -667,7 +666,7 @@ public class SingleInspectionProfilePanel extends JPanel {
InspectionProfileImpl selected = myProfile;
if (selected != null) {
final InspectionConfigTreeNode node = (InspectionConfigTreeNode)event.getPath().getLastPathComponent();
final InspectionProfileImpl parentProfile = (InspectionProfileImpl)selected.getParentProfile();
final InspectionProfileImpl parentProfile = selected.getParentProfile();
if (parentProfile != null) {
getExpandedNodes(parentProfile).expandNode(node);
}
@@ -1018,9 +1017,11 @@ public class SingleInspectionProfilePanel extends JPanel {
return myProfile;
}
private void setProfile(final ModifiableModel modifiableModel) {
if (myProfile == modifiableModel) return;
myProfile = (InspectionProfileImpl)modifiableModel;
private void setProfile(InspectionProfileImpl modifiableModel) {
if (myProfile == modifiableModel) {
return;
}
myProfile = modifiableModel;
initToolStates();
}
@@ -1120,7 +1121,7 @@ public class SingleInspectionProfilePanel extends JPanel {
final InspectionProfileImpl selectedProfile = getProfile();
BaseInspectionProfileManager profileManager = selectedProfile.isProjectLevel() ? myProjectProfileManager : (BaseInspectionProfileManager)InspectionProfileManager.getInstance();
InspectionProfileImpl parentProfile = (InspectionProfileImpl)selectedProfile.getParentProfile();
InspectionProfileImpl parentProfile = selectedProfile.getParentProfile();
if (parentProfile.getProfileManager().getProfile(parentProfile.getName(), false) == parentProfile) {
parentProfile.getProfileManager().deleteProfile(parentProfile.getName());
@@ -18,7 +18,6 @@ package com.intellij.profile.codeInspection.ui.header;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
import com.intellij.codeInspection.ModifiableModel;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
@@ -46,7 +45,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.BaseInspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager;
@@ -380,9 +378,9 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
myProfiles.getProfilesComboBox().removeProfile(existed.getProfile());
myPanels.remove(existed);
}
final ModifiableModel model = profile.getModifiableModel();
InspectionProfileImpl model = profile.getModifiableModel();
model.setModified(true);
addProfile((InspectionProfileImpl)model);
addProfile(model);
selectProfile(model);
//TODO myDeletedProfiles ? really need this
@@ -539,11 +537,11 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
private void doReset() {
myDeletedProfiles.clear();
disposeUIResources();
final Collection<Profile> profiles = getProfiles();
final Collection<InspectionProfileImpl> profiles = getProfiles();
final List<InspectionProfileImpl> modifiableProfiles = new ArrayList<>(profiles.size());
for (Profile profile : profiles) {
final ModifiableModel modifiableProfile = ((InspectionProfileImpl)profile).getModifiableModel();
final InspectionProfileImpl inspectionProfile = (InspectionProfileImpl)modifiableProfile;
for (InspectionProfileImpl profile : profiles) {
InspectionProfileImpl modifiableProfile = profile.getModifiableModel();
final InspectionProfileImpl inspectionProfile = modifiableProfile;
modifiableProfiles.add(inspectionProfile);
final SingleInspectionProfilePanel panel = createPanel(inspectionProfile);
myPanels.add(panel);
@@ -587,8 +585,8 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
return inspectionProfile.getProfileManager() == myProjectProfileManager ? projectProfileFound : ideProfileFound;
}
protected Collection<Profile> getProfiles() {
final Collection<Profile> result = new ArrayList<>();
protected Collection<InspectionProfileImpl> getProfiles() {
final Collection<InspectionProfileImpl> result = new ArrayList<>();
result.addAll(new TreeSet<>(myApplicationProfileManager.getProfiles()));
result.addAll(myProjectProfileManager.getProfiles());
return result;
@@ -607,8 +605,8 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
}
@Override
public void selectProfile(Profile profile) {
myProfiles.getProfilesComboBox().selectProfile((InspectionProfileImpl)profile);
public void selectProfile(InspectionProfileImpl profile) {
myProfiles.getProfilesComboBox().selectProfile(profile);
}
private SingleInspectionProfilePanel getProfilePanel(InspectionProfileImpl profile) {
@@ -18,7 +18,6 @@ package com.intellij.profile.codeInspection.ui.header;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.profile.Profile;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.SortedComboBoxModel;
@@ -50,7 +49,7 @@ public abstract class ProfilesComboBox extends ComboBox<InspectionProfileImpl> {
myComboModel = new SortedComboBoxModel<>(comparator);
setModel(myComboModel);
//noinspection GtkPreferredJComboBoxRenderer
setRenderer(new ListCellRenderer<Object>() {
setRenderer(new ListCellRenderer<InspectionProfileImpl>() {
ListCellRendererWrapper<InspectionProfileImpl> baseRenderer = new ListCellRendererWrapper<InspectionProfileImpl>() {
@Override
public void customize(final JList list,
@@ -67,25 +66,24 @@ public abstract class ProfilesComboBox extends ComboBox<InspectionProfileImpl> {
@Override
public Component getListCellRendererComponent(JList list,
Object o,
InspectionProfileImpl o,
int index,
boolean isSelected,
boolean cellHasFocus) {
InspectionProfileImpl value = (InspectionProfileImpl)o;
TitledSeparator separator = null;
if (index != -1) {
if (!value.isProjectLevel()) {
if (value == myFirstGlobalProfile) {
if (!o.isProjectLevel()) {
if (o == myFirstGlobalProfile) {
separator = new TitledSeparator(GLOBAL_LEVEL_SEPARATOR_TEXT);
}
}
else {
if (value == myComboModel.get(0)) {
if (o == myComboModel.get(0)) {
separator = new TitledSeparator(PROJECT_LEVEL_SEPARATOR_TEXT);
}
}
}
Component renderedComponent = baseRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Component renderedComponent = baseRenderer.getListCellRendererComponent(list, o, index, isSelected, cellHasFocus);
if (separator == null) {
return renderedComponent;
}
@@ -119,10 +117,10 @@ public abstract class ProfilesComboBox extends ComboBox<InspectionProfileImpl> {
setSelectedItem(inspectionProfile);
}
public void reset(final Collection<? extends Profile> profiles) {
public void reset(final Collection<InspectionProfileImpl> profiles) {
myComboModel.clear();
for (Profile profile : profiles) {
myComboModel.add((InspectionProfileImpl)profile);
for (InspectionProfileImpl profile : profiles) {
myComboModel.add(profile);
}
findFirstGlobalProfile();
setSelectedIndex(0);
@@ -58,7 +58,6 @@ import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
@@ -354,7 +353,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
@Override
public void disableInspections(@NotNull InspectionProfileEntry... inspections) {
InspectionProfileImpl profile = (InspectionProfileImpl)InspectionProjectProfileManager.getInstance(getProject()).getCurrentProfile();
InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(getProject()).getCurrentProfile();
for (InspectionProfileEntry inspection : inspections) {
profile.disableTool(inspection.getShortName(), getProject());
}
@@ -214,7 +214,7 @@ public abstract class BaseInspection extends BaseJavaBatchLocalInspectionTool {
public static boolean isInspectionEnabled(@NonNls String shortName, PsiElement context) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(context.getProject());
final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getCurrentProfile();
final InspectionProfileImpl profile = profileManager.getCurrentProfile();
return profile.isToolEnabled(HighlightDisplayKey.find(shortName), context);
}
}
@@ -85,7 +85,7 @@ public class SuppressForTestsScopeFix extends InspectionGadgetsFix {
private void addRemoveTestsScope(Project project, boolean add) {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getCurrentProfile();
final InspectionProfileImpl profile = profileManager.getCurrentProfile();
final String shortName = myInspection.getShortName();
final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
if (tool == null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.Nullable;
@@ -32,7 +32,7 @@ public class EqualsReplaceableByObjectsCallInspectionTest extends LightInspectio
@Override
public void setUp() throws Exception {
super.setUp();
final InspectionProfileImpl profile = (InspectionProfileImpl)InspectionProjectProfileManager.getInstance(getProject()).getInspectionProfile();
final InspectionProfileImpl profile = InspectionProfileManager.getInstance(getProject()).getCurrentProfile();
profile.setErrorLevel(HighlightDisplayKey.find("EqualsReplaceableByObjectsCall"), HighlightDisplayLevel.WARNING, getProject());
}
@@ -158,7 +158,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
}
private static void enableVersions(@NotNull Project project, @NotNull PsiElement file, @NotNull List<LanguageLevel> versions) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final String shortName = getCompatibilityInspectionShortName();
final InspectionToolWrapper tool = profile.getInspectionTool(shortName, project);
if (tool != null) {
@@ -166,7 +166,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
final PyCompatibilityInspection inspection = (PyCompatibilityInspection)model.getUnwrappedTool(shortName, file);
inspection.ourVersions.addAll(ContainerUtil.map(versions, LanguageLevel::toString));
});
EditInspectionToolsSettingsAction.editToolSettings(project, profile, true, shortName);
EditInspectionToolsSettingsAction.editToolSettings(project, profile, shortName);
}
}
@@ -231,7 +231,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
}
private static void enableCompatibilityInspection(@NotNull Project project) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionToolWrapper tool = profile.getInspectionTool(getCompatibilityInspectionShortName(), project);
if (tool != null) {
// Partially copied from JSLinterInspection
@@ -241,7 +241,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
state.setEnabled(true);
}
profile.modifyProfile(model -> model.enableTool(tool.getShortName(), null, project));
EditInspectionToolsSettingsAction.editToolSettings(project, profile, true, getCompatibilityInspectionShortName());
EditInspectionToolsSettingsAction.editToolSettings(project, profile, getCompatibilityInspectionShortName());
}
}