diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java index f46a5cd26aea..8696d3e04a65 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfile.java @@ -88,7 +88,13 @@ public interface InspectionProfile extends Profile { boolean isExecutable(Project project); - boolean isEditable(); + /** + * @see {@link ModifiableModel#setSingleTool(String)} + * + * @return tool short name when inspection profile corresponds to synthetic profile for single inspection run + */ + @Nullable + String getSingleTool(); @NotNull String getDisplayName(); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java index 763d14aa6d50..302ee306b9a2 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ModifiableModel.java @@ -78,7 +78,10 @@ public interface ModifiableModel extends Profile { void copyFrom(@NotNull InspectionProfile profile); - void setEditable(String toolDisplayName); + /** + * @see InspectionProfile#getSingleTool() + */ + void setSingleTool(@NotNull String toolShortName); void save() throws IOException; diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 0fa97e3f29c8..185825abc85c 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -39,7 +39,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; -import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.StringInterner; @@ -82,7 +81,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, @Attribute("is_locked") private boolean myLockedProfile; private final InspectionProfileImpl myBaseProfile; - private String myEnabledTool = null; + private volatile String myToolShortName = null; private String[] myScopesOrder; private String myDescription; private boolean myModified; @@ -452,20 +451,21 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, InspectionProfileManager.getInstance().fireProfileChanged(this); } + @Nullable @Override - public boolean isEditable() { - return myEnabledTool == null; + public String getSingleTool() { + return myToolShortName; } @Override - public void setEditable(final String displayName) { - myEnabledTool = displayName; + public void setSingleTool(@NotNull final String toolShortName) { + myToolShortName = toolShortName; } @Override @NotNull public String getDisplayName() { - return isEditable() ? getName() : myEnabledTool; + return getName(); } @Override diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java index 5f9252522516..05fcc4ed8bec 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/RunInspectionIntention.java @@ -144,7 +144,7 @@ public class RunInspectionIntention implements IntentionAction, HighPriorityActi } catch (InvalidDataException ignored) { } - model.setEditable(toolWrapper.getDisplayName()); + model.setSingleTool(toolWrapper.getShortName()); final GlobalInspectionContextImpl inspectionContext = managerEx.createNewGlobalContext(false); inspectionContext.setExternalProfile(model); return inspectionContext; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java index 4650c0a7ff92..eb90df5e05c7 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java @@ -47,7 +47,6 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Computable; @@ -57,7 +56,6 @@ import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.PsiElement; import com.intellij.util.PlatformUtils; -import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -181,17 +179,6 @@ public class ViewOfflineResultsAction extends AnAction { public HighlightDisplayLevel getErrorLevel(@NotNull final HighlightDisplayKey key, PsiElement element) { return ((InspectionProfile)InspectionProfileManager.getInstance().getRootProfile()).getErrorLevel(key, element); } - - @Override - public boolean isEditable() { - return false; - } - - @NotNull - @Override - public String getDisplayName() { - return getName(); - } }; } return showOfflineView(project, resMap, inspectionProfile, title); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 7081deb07333..dd1d3c6fb90b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -153,12 +153,10 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp } public void addView(@NotNull InspectionResultsView view) { - addView(view, view.getCurrentProfileName() == null - ? InspectionsBundle.message("inspection.results.title") - : InspectionsBundle.message(!getCurrentProfile().isEditable() ? - "inspection.results.for.inspection.toolwindow.title" : - "inspection.results.for.profile.toolwindow.title", - view.getCurrentProfileName(), getCurrentScope().getShortenName()), false); + addView(view, InspectionsBundle.message(view.isSingleInspectionRun() ? + "inspection.results.for.inspection.toolwindow.title" : + "inspection.results.for.profile.toolwindow.title", + view.getCurrentProfileName(), getCurrentScope().getShortenName()), false); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java index ac7d9941f6a5..438a877261cd 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/DefaultInspectionToolPresentation.java @@ -222,7 +222,7 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro final AnalysisUIOptions uiOptions = context.getUIOptions(); toolNode = myToolNode == null ? view.addTool(myToolWrapper, HighlightDisplayLevel.find(getSeverity((RefElement)refElement)), - uiOptions.GROUP_BY_SEVERITY, !view.getCurrentProfile().isEditable()) : myToolNode; + uiOptions.GROUP_BY_SEVERITY, view.isSingleInspectionRun()) : myToolNode; final Map problems = new HashMap(); problems.put(refElement, descriptors); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index a560beeb0dc2..5d7bec48f576 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -145,7 +145,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren myGlobalInspectionContext = globalInspectionContext; myProvider = provider; myExcludedInspectionTreeNodesManager = new ExcludedInspectionTreeNodesManager(provider instanceof OfflineInspectionRVContentProvider, - !myInspectionProfile.isEditable()); + isSingleInspectionRun()); myTree = new InspectionTree(myProject, globalInspectionContext, this); initTreeListeners(); @@ -625,11 +625,12 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren return myExcludedInspectionTreeNodesManager; } - @Nullable + @NotNull public String getCurrentProfileName() { - return myInspectionProfile == null ? null : myInspectionProfile.getDisplayName(); + return myInspectionProfile.getDisplayName(); } + @NotNull public InspectionProfile getCurrentProfile() { return myInspectionProfile; } @@ -696,7 +697,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren synchronized (myTreeStructureUpdateLock) { InspectionProfileImpl profile = (InspectionProfileImpl)myInspectionProfile; boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY; - boolean singleInspectionRun = !myInspectionProfile.isEditable(); + boolean singleInspectionRun = isSingleInspectionRun(); for (Tools currentTools : tools) { InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool(); if (myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS && @@ -953,8 +954,8 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren return rerun; } - public boolean isProfileDefined() { - return myInspectionProfile != null && myInspectionProfile.isEditable(); + public boolean isSingleInspectionRun() { + return myInspectionProfile.getSingleTool() != null; } public static void showPopup(AnActionEvent e, JBPopup popup) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java index 0fe131239f2c..4a2c3a54a64c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java @@ -48,7 +48,7 @@ public class EditSettingsAction extends InspectionViewActionBase { final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(view.getProject()); final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(false); InspectionProfile inspectionProfile = view.getCurrentProfile(); - final boolean profileIsDefined = view.isProfileDefined(); + final boolean profileIsDefined = view.isSingleInspectionRun(); if (!profileIsDefined) { inspectionProfile = guessProfileToSelect(view, profileManager); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java index 4be8fb95a714..10da5ee3a891 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java @@ -90,7 +90,7 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB @Override protected void actionPerformed(@NotNull InspectionResultsView view, @NotNull HighlightDisplayKey key) { try { - if (view.isProfileDefined()) { + if (view.isSingleInspectionRun()) { final ModifiableModel model = view.getCurrentProfile().getModifiableModel(); model.disableTool(key.toString(), view.getProject()); model.commit();