mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javafx: sort refs from bottom to top (IDEA-101687)
This commit is contained in:
+22
-3
@@ -1,6 +1,9 @@
|
||||
package com.intellij.refactoring.move.moveClassesOrPackages;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.ProperTextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.refactoring.util.MoveRenameUsageInfo;
|
||||
@@ -8,9 +11,7 @@ import com.intellij.refactoring.util.NonCodeUsageInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class CommonMoveUtil {
|
||||
|
||||
@@ -21,6 +22,24 @@ public class CommonMoveUtil {
|
||||
|
||||
public static NonCodeUsageInfo[] retargetUsages(final UsageInfo[] usages, final Map<PsiElement, PsiElement> oldToNewElementsMapping)
|
||||
throws IncorrectOperationException {
|
||||
Arrays.sort(usages, new Comparator<UsageInfo>() {
|
||||
@Override
|
||||
public int compare(UsageInfo o1, UsageInfo o2) {
|
||||
final VirtualFile file1 = o1.getVirtualFile();
|
||||
final VirtualFile file2 = o2.getVirtualFile();
|
||||
if (Comparing.equal(file1, file2)) {
|
||||
final ProperTextRange rangeInElement1 = o1.getRangeInElement();
|
||||
final ProperTextRange rangeInElement2 = o2.getRangeInElement();
|
||||
if (rangeInElement1 != null && rangeInElement2 != null) {
|
||||
return rangeInElement2.getStartOffset() - rangeInElement1.getStartOffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (file1 == null) return -1;
|
||||
if (file2 == null) return 1;
|
||||
return Comparing.compare(file1.getPath(), file2.getPath());
|
||||
}
|
||||
});
|
||||
List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<NonCodeUsageInfo>();
|
||||
for (UsageInfo usage : usages) {
|
||||
if (usage instanceof NonCodeUsageInfo) {
|
||||
|
||||
Reference in New Issue
Block a user