code cleanup (initial)

This commit is contained in:
Anna Kozlova
2014-05-12 11:42:18 +04:00
parent 246bf70658
commit 2a25c8c58a
35 changed files with 348 additions and 69 deletions
@@ -19,17 +19,14 @@ import com.intellij.codeInsight.daemon.JavaErrorMessages;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil;
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil;
import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.*;
import com.intellij.psi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class AccessStaticViaInstanceBase extends BaseJavaBatchLocalInspectionTool {
public class AccessStaticViaInstanceBase extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@NonNls public static final String ACCESS_STATIC_VIA_INSTANCE = "AccessStaticViaInstance";
@Override
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class DuplicateThrowsInspection extends BaseJavaBatchLocalInspectionTool {
public class DuplicateThrowsInspection extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@SuppressWarnings("PublicField")
public boolean ignoreSubclassing = false;
@@ -15,10 +15,7 @@
*/
package com.intellij.codeInspection.miscGenerics;
import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.*;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -31,7 +28,7 @@ import java.util.List;
/**
* @author ven
*/
public abstract class GenericsInspectionToolBase extends BaseJavaBatchLocalInspectionTool {
public abstract class GenericsInspectionToolBase extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@Override
public boolean isEnabledByDefault() {
return true;
@@ -33,7 +33,7 @@ import java.util.Set;
* @author anna
* @since 15-Nov-2005
*/
public class RedundantThrowsDeclaration extends BaseJavaBatchLocalInspectionTool {
public class RedundantThrowsDeclaration extends BaseJavaBatchLocalInspectionTool implements CleanupLocalInspectionTool {
@Override
@NotNull
public String getGroupDisplayName() {
@@ -0,0 +1,19 @@
/*
* Copyright 2000-2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection;
public interface CleanupLocalInspectionTool {
}
@@ -0,0 +1,184 @@
/*
* Copyright 2000-2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInspection.actions;
import com.intellij.analysis.AnalysisScope;
import com.intellij.analysis.BaseAnalysisAction;
import com.intellij.analysis.BaseAnalysisActionDialog;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoProcessor;
import com.intellij.codeInsight.daemon.impl.LocalInspectionsPass;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ex.*;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.ui.ErrorsConfigurable;
import com.intellij.profile.codeInspection.ui.IDEInspectionToolsConfigurable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiFile;
import com.intellij.ui.ComboboxWithBrowseButton;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.util.SequentialModalProgressTask;
import com.intellij.util.SequentialTask;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;
public class CodeCleanupAction extends BaseAnalysisAction {
public CodeCleanupAction() {
super("Code Cleanup", "Code Cleanup");
}
@Override
protected void analyze(@NotNull final Project project, @NotNull final AnalysisScope scope) {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
final List<LocalInspectionToolWrapper> lTools = new ArrayList<LocalInspectionToolWrapper>();
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
final LinkedHashMap<PsiFile, List<HighlightInfo>> results = new LinkedHashMap<PsiFile, List<HighlightInfo>>();
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Inspect code...", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
scope.accept(new PsiElementVisitor() {
@Override
public void visitFile(PsiFile file) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return;
for (final Tools tools : profile.getAllEnabledInspectionTools(project)) {
if (tools.getTool().getTool() instanceof CleanupLocalInspectionTool) {
final InspectionToolWrapper tool = tools.getEnabledTool(file);
if (tool instanceof LocalInspectionToolWrapper) {
lTools.add((LocalInspectionToolWrapper)tool);
tool.initialize(context);
}
}
}
if (!lTools.isEmpty()) {
final LocalInspectionsPass pass = new LocalInspectionsPass(file, PsiDocumentManager.getInstance(project).getDocument(file), 0,
file.getTextLength(), LocalInspectionsPass.EMPTY_PRIORITY_RANGE, true,
HighlightInfoProcessor.getEmpty());
Runnable runnable = new Runnable() {
public void run() {
pass.doInspectInBatch(context, managerEx, lTools);
}
};
ApplicationManager.getApplication().runReadAction(runnable);
results.put(file, pass.getInfos());
}
}
});
}
@Override
public void onSuccess() {
if (!FileModificationService.getInstance().preparePsiElementsForWrite(results.keySet())) return;
final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, "Code Cleanup", true);
progressTask.setMinIterationTime(200);
progressTask.setTask(new SequentialCleanupTask(project, results, progressTask));
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().run(progressTask);
}
});
}
}, getTemplatePresentation().getText(), null);
}
});
}
}
class SequentialCleanupTask implements SequentialTask {
private final Project myProject;
private final LinkedHashMap<PsiFile, List<HighlightInfo>> myResults;
private Iterator<PsiFile> myFileIterator;
private final SequentialModalProgressTask myProgressTask;
private int myCount = 0;
public SequentialCleanupTask(Project project, LinkedHashMap<PsiFile, List<HighlightInfo>> results, SequentialModalProgressTask task) {
myProject = project;
myResults = results;
myProgressTask = task;
myFileIterator = myResults.keySet().iterator();
}
@Override
public void prepare() {}
@Override
public boolean isDone() {
return myFileIterator == null || !myFileIterator.hasNext();
}
@Override
public boolean iteration() {
final ProgressIndicator indicator = myProgressTask.getIndicator();
if (indicator != null) {
indicator.setFraction((double) myCount++/myResults.size());
}
final PsiFile file = myFileIterator.next();
final List<HighlightInfo> infos = myResults.get(file);
Collections.reverse(infos); //sort bottom - top
for (HighlightInfo info : infos) {
for (final Pair<HighlightInfo.IntentionActionDescriptor, TextRange> actionRange : info.quickFixActionRanges) {
actionRange.getFirst().getAction().invoke(myProject, null, file);
}
}
return true;
}
@Override
public void stop() {
myFileIterator = null;
}
}
@@ -40,14 +40,17 @@ import java.awt.*;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
public class GotoActionAction extends GotoActionBase implements DumbAware {
public static final Comparator<MatchResult> ELEMENTS_COMPARATOR = new Comparator<MatchResult>() {
@Override
public int compare(MatchResult o1, MatchResult o2) {
if (o1.elementName.equals(GotoActionModel.INTENTIONS_KEY)) return -1;
if (o2.elementName.equals(GotoActionModel.INTENTIONS_KEY)) return 1;
if (o1.elementName.equals(GotoActionModel.SETTINGS_KEY)) return 1;
if (o2.elementName.equals(GotoActionModel.SETTINGS_KEY)) return -1;
return o1.elementName.compareToIgnoreCase(o2.elementName);
}
};
@@ -103,7 +106,7 @@ public class GotoActionAction extends GotoActionBase implements DumbAware {
}
else {
//element could be AnAction (SearchEverywhere)
final AnAction action = element instanceof AnAction ? ((AnAction)element) : (AnAction)((Map.Entry)element).getKey();
final AnAction action = element instanceof AnAction ? ((AnAction)element) : ((GotoActionModel.ActionWrapper)element).getAction();
if (action != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
@@ -1718,9 +1718,9 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
private GotoActionModel createActionModel() {
return new GotoActionModel(project, myFocusComponent, myEditor, myFile) {
@Override
protected boolean actionMatches(String pattern, @NotNull AnAction anAction) {
protected MatchMode actionMatches(String pattern, @NotNull AnAction anAction) {
return NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE)
.matches(anAction.getTemplatePresentation().getText());
.matches(anAction.getTemplatePresentation().getText()) ? MatchMode.NAME : MatchMode.NONE;
}
};
}
@@ -48,6 +48,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.List;
public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, Comparator<Object> {
@NonNls public static final String SETTINGS_KEY = "$$$SETTINGS$$$";
@@ -154,11 +155,11 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
panel.setBackground(bg);
if (value instanceof Map.Entry) {
if (value instanceof ActionWrapper) {
final Map.Entry actionWithParentGroup = (Map.Entry)value;
final ActionWrapper actionWithParentGroup = (ActionWrapper)value;
final AnAction anAction = (AnAction)actionWithParentGroup.getKey();
final AnAction anAction = actionWithParentGroup.getAction();
final Presentation templatePresentation = anAction.getTemplatePresentation();
final Icon icon = templatePresentation.getIcon();
@@ -169,10 +170,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
final Color fg = defaultActionForeground(isSelected, presentation);
final JLabel actionLabel = createActionLabel(anAction, templatePresentation.getText(), fg, bg, icon);
final JLabel actionLabel = createActionLabel(anAction, templatePresentation.getText() + "::" + actionWithParentGroup.getMode(), fg, bg, icon);
panel.add(actionLabel, BorderLayout.WEST);
final String groupName = (String)actionWithParentGroup.getValue();
final String groupName = actionWithParentGroup.getGroupName();
if (groupName != null) {
final JLabel groupLabel = new JLabel(groupName);
groupLabel.setBackground(bg);
@@ -249,12 +250,20 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
@Override
public int compare(Object o1, Object o2) {
if (o1 instanceof Map.Entry && !(o2 instanceof Map.Entry)) {
return -1;
}
if (o2 instanceof Map.Entry && !(o1 instanceof Map.Entry)) {
if (o1 instanceof OptionDescription && !(o2 instanceof OptionDescription)) {
return 1;
}
if (o2 instanceof OptionDescription && !(o1 instanceof OptionDescription)) {
return 1;
}
if (o1 instanceof OptionDescription) {
return ((OptionDescription)o1).compareTo(o2);
}
if (o1 instanceof ActionWrapper && o2 instanceof ActionWrapper) {
return ((ActionWrapper)o1).compareTo((ActionWrapper)o2);
}
return StringUtil.compare(getFullName(o1), getFullName(o2), true);
}
@@ -301,10 +310,15 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
@Override
@NotNull
public Object[] getElementsByName(final String id, final boolean checkBoxState, final String pattern) {
final HashMap<AnAction, String> map = new HashMap<AnAction, String>();
List<Object> objects = new ArrayList<Object>();
final AnAction act = myActionManager.getAction(id);
if (act != null) {
map.put(act, myActionsMap.get(act));
final HashMap<AnAction, String> map = new HashMap<AnAction, String>();
final MatchMode matchMode = actionMatches(pattern, act);
final String groupName = myActionsMap.get(act);
if (map.put(act, groupName) == null) {
objects.add(new ActionWrapper(act, groupName, matchMode));
}
if (checkBoxState) {
final Set<String> ids = ((ActionManagerImpl)myActionManager).getActionIds();
for (AnAction action : map.keySet()) { //do not add already included actions
@@ -313,17 +327,19 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
if (ids.contains(id)) {
final AnAction anAction = myActionManager.getAction(id);
map.put(anAction, null);
if (anAction != null) {
objects.add(new ActionWrapper(anAction, null, MatchMode.NON_MENU));
}
}
}
} else if (Comparing.strEqual(id, INTENTIONS_KEY)) {
for (String intentionText : myIntentions.keySet()) {
final ApplyIntentionAction intentionAction = myIntentions.get(intentionText);
if (actionMatches(pattern, intentionAction)) {
map.put(intentionAction, intentionText);
if (actionMatches(pattern, intentionAction) != MatchMode.NONE) {
objects.add(new ActionWrapper(intentionAction, intentionText, MatchMode.INTENTION));
}
}
}
Object[] objects = map.entrySet().toArray(new Map.Entry[map.size()]);
if (Comparing.strEqual(id, SETTINGS_KEY)) {
final Set<String> words = myIndex.getProcessedWords(pattern);
Set<OptionDescription> optionDescriptions = null;
@@ -359,12 +375,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
iterator.remove();
}
}
final Object[] descriptions = optionDescriptions.toArray();
Arrays.sort(descriptions);
objects = ArrayUtil.mergeArrays(objects, descriptions);
objects.addAll(optionDescriptions);
}
}
return objects;
return objects.toArray(new Object[objects.size()]);
}
private void collectActions(Map<AnAction, String> result, ActionGroup group, final String containingGroupName) {
@@ -427,29 +441,31 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
@Override
public String getElementName(final Object element) {
if (element instanceof OptionDescription) return ((OptionDescription)element).getHit();
if (!(element instanceof Map.Entry)) return null;
return ((AnAction)((Map.Entry)element).getKey()).getTemplatePresentation().getText();
if (!(element instanceof ActionWrapper)) return null;
return ((ActionWrapper)element).getAction().getTemplatePresentation().getText();
}
@Override
public boolean matches(@NotNull final String name, @NotNull final String pattern) {
final AnAction anAction = myActionManager.getAction(name);
if (anAction == null) return true;
return actionMatches(pattern, anAction);
return actionMatches(pattern, anAction) != MatchMode.NONE;
}
protected boolean actionMatches(String pattern, @NotNull AnAction anAction) {
protected MatchMode actionMatches(String pattern, @NotNull AnAction anAction) {
final Pattern compiledPattern = getPattern(pattern);
final Presentation presentation = anAction.getTemplatePresentation();
final String text = presentation.getText();
final String description = presentation.getDescription();
PatternMatcher matcher = getMatcher();
if (text != null && matcher.matches(text, compiledPattern) ||
description != null && !description.equals(text) && matcher.matches(description, compiledPattern)) {
return true;
if (text != null && matcher.matches(text, compiledPattern)) {
return MatchMode.NAME;
}
else if (description != null && !description.equals(text) && matcher.matches(description, compiledPattern)) {
return MatchMode.DESCRIPTION;
}
final String groupName = myActionsMap.get(anAction);
return groupName != null && text != null && matcher.matches(groupName + " " + text, compiledPattern);
return groupName != null && text != null && matcher.matches(groupName + " " + text, compiledPattern) ? MatchMode.GROUP : MatchMode.NONE;
}
@Nullable
@@ -480,6 +496,10 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
return compiledPattern;
}
protected enum MatchMode {
NONE, INTENTION, NAME, DESCRIPTION, GROUP, NON_MENU
}
private String convertPattern(String pattern) {
final int eol = pattern.indexOf('\n');
if (eol != -1) {
@@ -587,4 +607,40 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
private PatternMatcher getMatcher() {
return myMatcher.get();
}
public static class ActionWrapper implements Comparable<ActionWrapper>{
private AnAction myAction;
private MatchMode myMode;
private String myGroupName;
public ActionWrapper(AnAction action, String groupName, MatchMode mode) {
myAction = action;
myMode = mode;
myGroupName = groupName;
}
public AnAction getAction() {
return myAction;
}
public MatchMode getMode() {
return myMode;
}
@Override
public int compareTo(ActionWrapper o) {
final int compared = myMode.compareTo(o.getMode());
return compared != 0
? compared
: StringUtil.compare(myAction.getTemplatePresentation().getText(), o.getAction().getTemplatePresentation().getText(), true);
}
public String getGroupName() {
return myGroupName;
}
public void setGroupName(String groupName) {
myGroupName = groupName;
}
}
}
@@ -520,6 +520,8 @@ action.MoveLineDown.description=Move selected lines one line down
action.MoveLineUp.text=Move Line _Up
action.MoveLineUp.description=Move selected lines one line up
group.AnalyzeMenu.text=Analy_ze
action.CodeCleanup.text=_Code Cleanup...
action.CodeCleanup.description=Run cleanup inspections and apply quick fixes
action.InspectCode.text=_Inspect Code...
action.InspectCode.description=Inspect code
action.InferNullity.text=Infer _Nullity...
@@ -42,6 +42,7 @@
<group id="InspectCodeGroup">
<separator/>
<action id="InspectCode" class="com.intellij.codeInspection.actions.CodeInspectionAction"/>
<action id="CodeCleanup" class="com.intellij.codeInspection.actions.CodeCleanupAction" internal="true"/>
<action id="RunInspection" class="com.intellij.codeInspection.actions.RunInspectionAction" />
<action id="PopupHector" class="com.intellij.codeInsight.daemon.impl.PopupHectorAction"/>
<action id="ViewOfflineInspection" class="com.intellij.codeInspection.actions.ViewOfflineResultsAction"/>
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.imports;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.psi.*;
import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
@@ -26,7 +27,7 @@ import com.intellij.psi.util.FileTypeUtils;
import com.siyeh.ig.psiutils.ImportUtils;
import org.jetbrains.annotations.NotNull;
public class JavaLangImportInspection extends BaseInspection {
public class JavaLangImportInspection extends BaseInspection implements CleanupLocalInspectionTool{
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.imports;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.psi.*;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -24,7 +25,7 @@ import com.siyeh.ig.fixes.DeleteImportFix;
import com.intellij.psi.util.FileTypeUtils;
import org.jetbrains.annotations.NotNull;
public class SamePackageImportInspection extends BaseInspection {
public class SamePackageImportInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
@@ -31,7 +32,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
public class MissortedModifiersInspection extends BaseInspection {
public class MissortedModifiersInspection extends BaseInspection implements CleanupLocalInspectionTool{
/**
* @noinspection PublicField
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
@@ -31,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class RedundantFieldInitializationInspection extends BaseInspection {
public class RedundantFieldInitializationInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings("PublicField")
public boolean onlyWarnOnNull = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
@@ -28,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class RedundantImplementsInspection extends BaseInspection {
public class RedundantImplementsInspection extends BaseInspection implements CleanupLocalInspectionTool{
@SuppressWarnings({"PublicField"})
public boolean ignoreSerializable = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
@@ -32,8 +33,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class UnnecessarilyQualifiedInnerClassAccessInspection
extends BaseInspection {
public class UnnecessarilyQualifiedInnerClassAccessInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings({"PublicField"})
public boolean ignoreReferencesNeedingImport = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
@@ -32,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class UnnecessarilyQualifiedStaticUsageInspection extends BaseInspection {
public class UnnecessarilyQualifiedStaticUsageInspection extends BaseInspection implements CleanupLocalInspectionTool{
/**
* @noinspection PublicField
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.project.Project;
@@ -30,7 +31,7 @@ import com.siyeh.ig.psiutils.ImportUtils;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
public class UnnecessarilyQualifiedStaticallyImportedElementInspection extends BaseInspection {
public class UnnecessarilyQualifiedStaticallyImportedElementInspection extends BaseInspection implements CleanupLocalInspectionTool{
@Nls
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
@@ -30,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class UnnecessaryBlockStatementInspection extends BaseInspection {
public class UnnecessaryBlockStatementInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings({"PublicField"})
public boolean ignoreSwitchBranches = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -32,7 +33,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessaryCallToStringValueOfInspection extends BaseInspection {
public class UnnecessaryCallToStringValueOfInspection extends BaseInspection implements CleanupLocalInspectionTool{
@Override
@Nls
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -26,8 +27,7 @@ import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessaryConstantArrayCreationExpressionInspection
extends BaseInspection {
public class UnnecessaryConstantArrayCreationExpressionInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
@@ -29,7 +30,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class UnnecessaryConstructorInspection extends BaseInspection {
public class UnnecessaryConstructorInspection extends BaseInspection implements CleanupLocalInspectionTool {
@NonNls
private static final String SUPER_CALL_TEXT = PsiKeyword.SUPER + "();";
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -26,7 +27,7 @@ import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.ClassUtils;
import org.jetbrains.annotations.NotNull;
public class UnnecessaryEnumModifierInspection extends BaseInspection {
public class UnnecessaryEnumModifierInspection extends BaseInspection implements CleanupLocalInspectionTool{
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
@@ -31,7 +32,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class UnnecessaryFinalOnLocalVariableOrParameterInspection extends BaseInspection {
public class UnnecessaryFinalOnLocalVariableOrParameterInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings({"PublicField"})
public boolean onlyWarnOnAbstractMethods = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -29,7 +30,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class UnnecessaryInterfaceModifierInspection extends BaseInspection {
public class UnnecessaryInterfaceModifierInspection extends BaseInspection implements CleanupLocalInspectionTool{
private static final Set<String> INTERFACE_REDUNDANT_MODIFIERS =
new HashSet<String>(Arrays.asList(PsiModifier.ABSTRACT, PsiModifier.STATIC));
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
import com.intellij.openapi.project.Project;
@@ -28,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class UnnecessaryParenthesesInspection extends BaseInspection {
public class UnnecessaryParenthesesInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings({"PublicField"})
public boolean ignoreClarifyingParentheses = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.project.Project;
@@ -28,8 +29,7 @@ import com.siyeh.ig.PsiReplacementUtil;
import com.siyeh.ig.psiutils.ClassUtils;
import org.jetbrains.annotations.NotNull;
public class UnnecessaryQualifierForThisInspection
extends BaseInspection {
public class UnnecessaryQualifierForThisInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -29,7 +30,7 @@ import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessarySemicolonInspection extends BaseInspection {
public class UnnecessarySemicolonInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.project.Project;
@@ -26,8 +27,7 @@ import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import org.jetbrains.annotations.NotNull;
public class UnnecessarySuperConstructorInspection
extends BaseInspection {
public class UnnecessarySuperConstructorInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@NotNull
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.openapi.project.Project;
@@ -29,7 +30,7 @@ import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessarySuperQualifierInspection extends BaseInspection {
public class UnnecessarySuperQualifierInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@Nls
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
@@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public class UnnecessaryThisInspection extends BaseInspection {
public class UnnecessaryThisInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings("PublicField")
public boolean ignoreAssignments = false;
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
@@ -30,7 +31,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class UnnecessaryToStringCallInspection extends BaseInspection {
public class UnnecessaryToStringCallInspection extends BaseInspection implements CleanupLocalInspectionTool {
@Override
@Nls
@@ -15,6 +15,7 @@
*/
package com.siyeh.ig.style;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -42,7 +43,7 @@ import java.util.List;
/**
* @see com.siyeh.ipp.fqnames.ReplaceFullyQualifiedNameWithImportIntention
*/
public class UnnecessaryFullyQualifiedNameInspection extends BaseInspection {
public class UnnecessaryFullyQualifiedNameInspection extends BaseInspection implements CleanupLocalInspectionTool {
@SuppressWarnings("PublicField")
public boolean m_ignoreJavadoc = false; // left here to prevent changes to project files.
@@ -87,6 +87,7 @@
<group id="InspectCodeGroup" text="Inspect Code Actions">
<action id="InspectCode" class="com.intellij.codeInspection.actions.CodeInspectionAction"/>
<action id="CodeCleanup" class="com.intellij.codeInspection.actions.CodeCleanupAction" internal="true"/>
<action id="RunInspection" class="com.intellij.codeInspection.actions.RunInspectionAction"/>
<action id="PopupHector" class="com.intellij.codeInsight.daemon.impl.PopupHectorAction"/>
<action id="ViewOfflineInspection" class="com.intellij.codeInspection.actions.ViewOfflineResultsAction"/>