mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unused declaration: avoid NPE while tree sorting due to RefImplicitConstructor doesn't have underlying smart pointer (IDEA-CR-12558, EA-86330, IDEA-159043)
This commit is contained in:
+11
-6
@@ -38,6 +38,7 @@ import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigT
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.PsiQualifiedNamedElement;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -159,12 +160,16 @@ public class InspectionResultsViewComparator implements Comparator {
|
||||
|
||||
private static int compareEntities(final RefEntity entity1, final RefEntity entity2) {
|
||||
if (entity1 instanceof RefElement && entity2 instanceof RefElement) {
|
||||
final VirtualFile file1 = ((RefElement)entity1).getPointer().getVirtualFile();
|
||||
final VirtualFile file2 = ((RefElement)entity2).getPointer().getVirtualFile();
|
||||
if (file1 != null && Comparing.equal(file1, file2) && file1.isValid()) {
|
||||
final int positionComparing = PsiUtilCore.compareElementsByPosition(((RefElement)entity1).getElement(), ((RefElement)entity2).getElement());
|
||||
if (positionComparing != 0) {
|
||||
return positionComparing;
|
||||
final SmartPsiElementPointer p1 = ((RefElement)entity1).getPointer();
|
||||
final SmartPsiElementPointer p2 = ((RefElement)entity2).getPointer();
|
||||
if (p1 != null && p2 != null) {
|
||||
final VirtualFile file1 = p1.getVirtualFile();
|
||||
final VirtualFile file2 = p2.getVirtualFile();
|
||||
if (file1 != null && Comparing.equal(file1, file2) && file1.isValid()) {
|
||||
final int positionComparing = PsiUtilCore.compareElementsByPosition(((RefElement)entity1).getElement(), ((RefElement)entity2).getElement());
|
||||
if (positionComparing != 0) {
|
||||
return positionComparing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user