mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup, notnull
This commit is contained in:
+2
-1
@@ -1100,8 +1100,9 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool {
|
||||
super.updateContent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InspectionNode createToolNode(@NotNull final InspectionRVContentProvider provider, final InspectionTreeNode parentNode, final boolean showStructure) {
|
||||
public InspectionNode createToolNode(@NotNull final InspectionRVContentProvider provider, @NotNull final InspectionTreeNode parentNode, final boolean showStructure) {
|
||||
final InspectionNode toolNode = super.createToolNode(provider, parentNode, showStructure);
|
||||
final EntryPointsNode entryPointsNode = new EntryPointsNode(this);
|
||||
provider.appendToolNodeContent(entryPointsNode, toolNode, showStructure);
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.util.List;
|
||||
* @see RefManager
|
||||
*/
|
||||
public interface RefEntity extends UserDataHolder {
|
||||
RefEntity[] EMPTY_ELEMENTS_ARRAY = new RefEntity[0];
|
||||
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
|
||||
+5
-4
@@ -407,13 +407,14 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public QuickFixAction[] getQuickFixes(@NotNull final RefEntity[] refElements) {
|
||||
return extractActiveFixes(refElements, getQuickFixActions());
|
||||
}
|
||||
|
||||
public QuickFixAction[] extractActiveFixes(final RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) {
|
||||
if (refElements == null) return null;
|
||||
Map<Class, QuickFixAction> result = new java.util.HashMap<Class, QuickFixAction>();
|
||||
@Nullable
|
||||
public QuickFixAction[] extractActiveFixes(@NotNull RefEntity[] refElements, @NotNull Map<RefEntity, Set<QuickFix>> actions) {
|
||||
Map<Class, QuickFixAction> result = new HashMap<Class, QuickFixAction>();
|
||||
for (RefEntity refElement : refElements) {
|
||||
final Set<QuickFix> localQuickFixes = actions.get(refElement);
|
||||
if (localQuickFixes == null) continue;
|
||||
@@ -445,7 +446,7 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem
|
||||
return getProblemToElements().get(descriptor);
|
||||
}
|
||||
|
||||
public void ignoreProblem(final CommonProblemDescriptor descriptor, final QuickFix fix) {
|
||||
public void ignoreProblem(@NotNull CommonProblemDescriptor descriptor, @NotNull QuickFix fix) {
|
||||
RefEntity refElement = getProblemToElements().get(descriptor);
|
||||
if (refElement != null) {
|
||||
final QuickFix[] fixes = descriptor.getFixes();
|
||||
|
||||
@@ -73,11 +73,11 @@ public class LocalQuickFixWrapper extends QuickFixAction {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected QuickFix getWorkingQuickFix(QuickFix[] fixes) {
|
||||
protected QuickFix getWorkingQuickFix(@NotNull QuickFix[] fixes) {
|
||||
for (QuickFix fix : fixes) {
|
||||
if (!myFix.getClass().isInstance(fix)) continue;
|
||||
if (myFix instanceof IntentionWrapper && fix instanceof IntentionWrapper &&
|
||||
!(((IntentionWrapper)myFix).getAction().getClass().isInstance(((IntentionWrapper)fix).getAction()))) {
|
||||
!((IntentionWrapper)myFix).getAction().getClass().isInstance(((IntentionWrapper)fix).getAction())) {
|
||||
continue;
|
||||
}
|
||||
return fix;
|
||||
@@ -91,7 +91,9 @@ public class LocalQuickFixWrapper extends QuickFixAction {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyFix(final Project project, final CommonProblemDescriptor[] descriptors, final Set<PsiElement> ignoredElements) {
|
||||
protected void applyFix(@NotNull final Project project,
|
||||
@NotNull final CommonProblemDescriptor[] descriptors,
|
||||
@NotNull final Set<PsiElement> ignoredElements) {
|
||||
final PsiModificationTracker tracker = PsiManager.getInstance(project).getModificationTracker();
|
||||
if (myFix instanceof BatchQuickFix) {
|
||||
final ArrayList<PsiElement> collectedElementsToIgnore = new ArrayList<PsiElement>();
|
||||
@@ -139,7 +141,7 @@ public class LocalQuickFixWrapper extends QuickFixAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void ignore(Set<PsiElement> ignoredElements, CommonProblemDescriptor descriptor, QuickFix fix) {
|
||||
private void ignore(@NotNull Set<PsiElement> ignoredElements, @NotNull CommonProblemDescriptor descriptor, @Nullable QuickFix fix) {
|
||||
if (fix != null) {
|
||||
((DescriptorProviderInspection)myTool).ignoreProblem(descriptor, fix);
|
||||
}
|
||||
|
||||
@@ -117,9 +117,12 @@ public class QuickFixAction extends AnAction {
|
||||
}
|
||||
|
||||
|
||||
protected void applyFix(Project project, CommonProblemDescriptor[] descriptors, Set<PsiElement> ignoredElements) {}
|
||||
private void doApplyFix(final Project project,
|
||||
final CommonProblemDescriptor[] descriptors) {
|
||||
protected void applyFix(@NotNull Project project,
|
||||
@NotNull CommonProblemDescriptor[] descriptors,
|
||||
@NotNull Set<PsiElement> ignoredElements) {
|
||||
}
|
||||
|
||||
private void doApplyFix(@NotNull final Project project, @NotNull final CommonProblemDescriptor[] descriptors) {
|
||||
final Set<VirtualFile> readOnlyFiles = new THashSet<VirtualFile>();
|
||||
for (CommonProblemDescriptor descriptor : descriptors) {
|
||||
final PsiElement psiElement = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
|
||||
@@ -133,7 +136,7 @@ public class QuickFixAction extends AnAction {
|
||||
if (operationStatus.hasReadonlyFiles()) return;
|
||||
}
|
||||
|
||||
final RefManagerImpl refManager = ((RefManagerImpl)myTool.getContext().getRefManager());
|
||||
final RefManagerImpl refManager = (RefManagerImpl)myTool.getContext().getRefManager();
|
||||
|
||||
final boolean initial = refManager.isInProcess();
|
||||
|
||||
@@ -167,7 +170,7 @@ public class QuickFixAction extends AnAction {
|
||||
}
|
||||
|
||||
public void doApplyFix(final RefElement[] refElements, InspectionResultsView view) {
|
||||
final RefManagerImpl refManager = ((RefManagerImpl)myTool.getContext().getRefManager());
|
||||
final RefManagerImpl refManager = (RefManagerImpl)myTool.getContext().getRefManager();
|
||||
|
||||
final boolean initial = refManager.isInProcess();
|
||||
|
||||
@@ -294,19 +297,21 @@ public class QuickFixAction extends AnAction {
|
||||
}
|
||||
|
||||
private class PerformFixesTask implements SequentialTask {
|
||||
@NotNull
|
||||
private final Project myProject;
|
||||
private final CommonProblemDescriptor[] myDescriptors;
|
||||
@NotNull
|
||||
private final Set<PsiElement> myIgnoredElements;
|
||||
private final SequentialModalProgressTask myTask;
|
||||
private int myCount = 0;
|
||||
|
||||
public PerformFixesTask(Project project,
|
||||
CommonProblemDescriptor[] descriptors,
|
||||
Set<PsiElement> elements,
|
||||
SequentialModalProgressTask task) {
|
||||
public PerformFixesTask(@NotNull Project project,
|
||||
@NotNull CommonProblemDescriptor[] descriptors,
|
||||
@NotNull Set<PsiElement> ignoredElements,
|
||||
@NotNull SequentialModalProgressTask task) {
|
||||
myProject = project;
|
||||
myDescriptors = descriptors;
|
||||
myIgnoredElements = elements;
|
||||
myIgnoredElements = ignoredElements;
|
||||
myTask = task;
|
||||
}
|
||||
|
||||
@@ -324,7 +329,7 @@ public class QuickFixAction extends AnAction {
|
||||
final CommonProblemDescriptor descriptor = myDescriptors[myCount++];
|
||||
ProgressIndicator indicator = myTask.getIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.setFraction(((double)myCount) / myDescriptors.length);
|
||||
indicator.setFraction((double)myCount / myDescriptors.length);
|
||||
if (descriptor instanceof ProblemDescriptor) {
|
||||
final PsiElement psiElement = ((ProblemDescriptor)descriptor).getPsiElement();
|
||||
if (psiElement != null) {
|
||||
|
||||
@@ -512,7 +512,7 @@ class Browser extends JPanel {
|
||||
//CCE here means QuickFix was incorrectly inherited
|
||||
fix.applyFix(myView.getProject(), descriptor);
|
||||
if (startCount != tracker.getModificationCount()) {
|
||||
final DescriptorProviderInspection tool = ((DescriptorProviderInspection)myView.getTree().getSelectedTool());
|
||||
final DescriptorProviderInspection tool = (DescriptorProviderInspection)myView.getTree().getSelectedTool();
|
||||
if (tool != null) {
|
||||
tool.ignoreProblem(element, descriptor, idx);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import java.util.*;
|
||||
public class InspectionTree extends Tree {
|
||||
private final HashSet<Object> myExpandedUserObjects;
|
||||
private SelectionPath mySelectionPath;
|
||||
private static final RefEntity[] EMPTY_ELEMENTS_ARRAY = new RefEntity[0];
|
||||
private static final ProblemDescriptor[] EMPTY_DESCRIPTORS = new ProblemDescriptor[0];
|
||||
|
||||
public InspectionTree(final Project project) {
|
||||
@@ -130,7 +129,7 @@ public class InspectionTree extends Tree {
|
||||
TreePath[] selectionPaths = getSelectionPaths();
|
||||
if (selectionPaths != null) {
|
||||
final InspectionTool selectedTool = getSelectedTool();
|
||||
if (selectedTool == null) return EMPTY_ELEMENTS_ARRAY;
|
||||
if (selectedTool == null) return RefEntity.EMPTY_ELEMENTS_ARRAY;
|
||||
|
||||
List<RefEntity> result = new ArrayList<RefEntity>();
|
||||
for (TreePath selectionPath : selectionPaths) {
|
||||
@@ -139,7 +138,7 @@ public class InspectionTree extends Tree {
|
||||
}
|
||||
return result.toArray(new RefEntity[result.size()]);
|
||||
}
|
||||
return EMPTY_ELEMENTS_ARRAY;
|
||||
return RefEntity.EMPTY_ELEMENTS_ARRAY;
|
||||
}
|
||||
|
||||
private static void addElementsInNode(InspectionTreeNode node, List<RefEntity> out) {
|
||||
|
||||
Reference in New Issue
Block a user