mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspection tool window: navigate prev/next can navigate to entities with applied fixes
This commit is contained in:
+7
-7
@@ -77,17 +77,17 @@ public abstract class InspectionRVContentProvider {
|
||||
final TreePath[] treePaths = tree.getSelectionPaths();
|
||||
if (treePaths == null) return false;
|
||||
for (TreePath selectionPath : treePaths) {
|
||||
if (!TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
|
||||
@Override
|
||||
public boolean accept(final Object node) {
|
||||
if (!((InspectionTreeNode)node).isValid()) return true;
|
||||
if (node instanceof ProblemDescriptionNode) {
|
||||
final CommonProblemDescriptor descriptor = ((ProblemDescriptionNode)node).getDescriptor();
|
||||
if (!TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), node -> {
|
||||
if (!((InspectionTreeNode) node).isValid()) return true;
|
||||
if (node instanceof ProblemDescriptionNode) {
|
||||
ProblemDescriptionNode problemDescriptionNode = (ProblemDescriptionNode)node;
|
||||
if (!problemDescriptionNode.isQuickFixAppliedFromView()) {
|
||||
final CommonProblemDescriptor descriptor = problemDescriptionNode.getDescriptor();
|
||||
final QuickFix[] fixes = descriptor != null ? descriptor.getFixes() : null;
|
||||
return fixes == null || fixes.length == 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+18
-20
@@ -69,27 +69,25 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi
|
||||
final List<RefEntity> selectedElements = new ArrayList<RefEntity>();
|
||||
final Map<RefEntity, CommonProblemDescriptor[]> actions = new HashMap<>();
|
||||
for (TreePath selectionPath : treePaths) {
|
||||
TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), new TreeUtil.Traverse() {
|
||||
@Override
|
||||
public boolean accept(final Object node) {
|
||||
if (!((InspectionTreeNode)node).isValid()) return true;
|
||||
if (node instanceof OfflineProblemDescriptorNode) {
|
||||
final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node;
|
||||
final RefEntity element = descriptorNode.getElement();
|
||||
selectedElements.add(element);
|
||||
CommonProblemDescriptor[] descriptors = actions.get(element);
|
||||
final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor();
|
||||
final CommonProblemDescriptor[] descriptorAsArray = descriptor == null ? CommonProblemDescriptor.EMPTY_ARRAY
|
||||
: new CommonProblemDescriptor[]{descriptor};
|
||||
actions.put(element, descriptors == null ?
|
||||
descriptorAsArray :
|
||||
DefaultInspectionToolPresentation.mergeDescriptors(descriptors, descriptorAsArray));
|
||||
}
|
||||
else if (node instanceof RefElementNode) {
|
||||
selectedElements.add(((RefElementNode)node).getElement());
|
||||
}
|
||||
return true;
|
||||
TreeUtil.traverseDepth((TreeNode)selectionPath.getLastPathComponent(), node -> {
|
||||
if (!((InspectionTreeNode)node).isValid()) return true;
|
||||
if (node instanceof OfflineProblemDescriptorNode) {
|
||||
if (!((OfflineProblemDescriptorNode)node).isQuickFixAppliedFromView()) return true;
|
||||
final OfflineProblemDescriptorNode descriptorNode = (OfflineProblemDescriptorNode)node;
|
||||
final RefEntity element = descriptorNode.getElement();
|
||||
selectedElements.add(element);
|
||||
CommonProblemDescriptor[] descriptors = actions.get(element);
|
||||
final CommonProblemDescriptor descriptor = descriptorNode.getDescriptor();
|
||||
final CommonProblemDescriptor[] descriptorAsArray = descriptor == null ? CommonProblemDescriptor.EMPTY_ARRAY
|
||||
: new CommonProblemDescriptor[]{descriptor};
|
||||
actions.put(element, descriptors == null ?
|
||||
descriptorAsArray :
|
||||
DefaultInspectionToolPresentation.mergeDescriptors(descriptors, descriptorAsArray));
|
||||
}
|
||||
else if (node instanceof RefElementNode) {
|
||||
selectedElements.add(((RefElementNode)node).getElement());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -241,8 +241,19 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
|
||||
}
|
||||
}
|
||||
else if (node instanceof ProblemDescriptionNode) {
|
||||
if (!((ProblemDescriptionNode)node).isValid()) return null;
|
||||
return navigate(((ProblemDescriptionNode)node).getDescriptor());
|
||||
boolean isValid;
|
||||
if (((ProblemDescriptionNode)node).isValid()) {
|
||||
if (((ProblemDescriptionNode)node).isQuickFixAppliedFromView()) {
|
||||
isValid = ((ProblemDescriptionNode)node).calculateIsValid();
|
||||
} else {
|
||||
isValid = true;
|
||||
}
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
return isValid
|
||||
? navigate(((ProblemDescriptionNode)node).getDescriptor())
|
||||
: InspectionResultsViewUtil.getNavigatableForInvalidNode((ProblemDescriptionNode)node);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ public class InspectionResultsViewUtil {
|
||||
@Nullable
|
||||
static Navigatable getNavigatableForInvalidNode(ProblemDescriptionNode node) {
|
||||
RefEntity element = node.getElement();
|
||||
while (element != null && !element.isValid()) {
|
||||
element = element.getOwner();
|
||||
}
|
||||
if (!(element instanceof RefElement)) return null;
|
||||
PsiElement containingElement = ((RefElement)element).getElement();
|
||||
if (!(containingElement instanceof NavigatablePsiElement) || !containingElement.isValid()) return null;
|
||||
|
||||
+1
-6
@@ -70,12 +70,7 @@ class InspectionViewPsiTreeChangeAdapter extends PsiTreeChangeAdapter {
|
||||
Set<VirtualFile> files = new HashSet<>();
|
||||
for (Update update : updates) {
|
||||
VirtualFile file = (VirtualFile)update.getEqualityObjects()[0];
|
||||
VfsUtilCore.iterateChildrenRecursively(file, VirtualFileFilter.ALL, new ContentIterator() {
|
||||
@Override
|
||||
public boolean processFile(VirtualFile fileOrDir) {
|
||||
return files.add(fileOrDir);
|
||||
}
|
||||
});
|
||||
VfsUtilCore.iterateChildrenRecursively(file, VirtualFileFilter.ALL, files::add);
|
||||
}
|
||||
final Project project = view.getProject();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean calculateIsValid() {
|
||||
protected boolean calculateIsValid() {
|
||||
if (myElement instanceof RefElement && !myElement.isValid()) return false;
|
||||
final CommonProblemDescriptor descriptor = getDescriptor();
|
||||
if (descriptor instanceof ProblemDescriptor) {
|
||||
@@ -138,7 +138,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calculatePresentableName() {
|
||||
protected String calculatePresentableName() {
|
||||
CommonProblemDescriptor descriptor = getDescriptor();
|
||||
if (descriptor == null) return "";
|
||||
PsiElement element = descriptor instanceof ProblemDescriptor ? ((ProblemDescriptor)descriptor).getPsiElement() : null;
|
||||
|
||||
Reference in New Issue
Block a user