mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migration: support multiple entries in migration set (IDEA-90186)
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.refactoring.migration;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
@@ -98,14 +99,20 @@ public class MigrationUtil {
|
||||
|
||||
// rename all references
|
||||
for (UsageInfo usage : usages) {
|
||||
PsiElement element = usage.getElement();
|
||||
if (element == null || !element.isValid()) continue;
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)element;
|
||||
referenceElement.bindToElement(aClass);
|
||||
}
|
||||
else {
|
||||
bindNonJavaReference(aClass, element, usage);
|
||||
if (usage instanceof MigrationProcessor.MigrationUsageInfo) {
|
||||
final MigrationProcessor.MigrationUsageInfo usageInfo = (MigrationProcessor.MigrationUsageInfo)usage;
|
||||
if (Comparing.equal(newQName, usageInfo.mapEntry.getNewName())) {
|
||||
PsiElement element = usage.getElement();
|
||||
if (element == null || !element.isValid()) continue;
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)element;
|
||||
referenceElement.bindToElement(aClass);
|
||||
}
|
||||
else {
|
||||
bindNonJavaReference(aClass, element, usage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class A {}
|
||||
class A1 {}
|
||||
|
||||
class B {}
|
||||
class B1 {}
|
||||
|
||||
public class Test {
|
||||
A1 a;
|
||||
B1 b;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A {}
|
||||
class A1 {}
|
||||
|
||||
class B {}
|
||||
class B1 {}
|
||||
|
||||
public class Test {
|
||||
A a;
|
||||
B b;
|
||||
}
|
||||
@@ -33,9 +33,12 @@ public class MigrationTest extends MultiFileTestCase {
|
||||
})));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void testTwoClasses() throws Exception {
|
||||
doTest(createAction(new MigrationMap(new MigrationMapEntry[]{
|
||||
new MigrationMapEntry("A", "A1", MigrationMapEntry.CLASS, true),
|
||||
new MigrationMapEntry("B", "B1", MigrationMapEntry.CLASS, true)
|
||||
})));
|
||||
}
|
||||
|
||||
private MultiFileTestCase.PerformAction createAction(final MigrationMap migrationMap) {
|
||||
return new MultiFileTestCase.PerformAction() {
|
||||
|
||||
Reference in New Issue
Block a user