mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspections: methods refactored to be more clear InspectionProfile#isEditable & ModifiableModel#setEditable -> InspectionProfile#getSingleTool & ModifiableModel#setSingleTool
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+7
-7
@@ -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
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
-13
@@ -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);
|
||||
|
||||
+4
-6
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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<RefEntity, CommonProblemDescriptor[]> problems = new HashMap<RefEntity, CommonProblemDescriptor[]>();
|
||||
problems.put(refElement, descriptors);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user