mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Non-existing multi-catch-to-normal type migration conflicts eliminated; cleanup
This commit is contained in:
+22
-21
@@ -40,6 +40,7 @@ import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Query;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
@@ -765,28 +766,30 @@ public class TypeMigrationLabeler {
|
||||
return refs;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public String getMigrationReport() {
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append("Types:\n").append(getTypeEvaluator().getReport()).append("\n");
|
||||
|
||||
buffer.append("Types:\n" + getTypeEvaluator().getReport() + "\n");
|
||||
buffer.append("Conversions:\n");
|
||||
|
||||
final String[] conversions = new String[myConversions.size()];
|
||||
int k = 0;
|
||||
|
||||
for (final PsiElement expr : myConversions.keySet()) {
|
||||
final Object conv = myConversions.get(expr);
|
||||
final Object conversion = myConversions.get(expr);
|
||||
|
||||
if (conv instanceof Pair && ((Pair)conv).first == null) {
|
||||
conversions[k++] = (expr.getText() + " -> " + ((Pair)conv).second + "\n");
|
||||
if (conversion instanceof Pair && ((Pair)conversion).first == null) {
|
||||
conversions[k++] = (expr.getText() + " -> " + ((Pair)conversion).second + "\n");
|
||||
} else {
|
||||
conversions[k++] = (expr.getText() + " -> " + conv + "\n");
|
||||
conversions[k++] = (expr.getText() + " -> " + conversion + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
Arrays.sort(conversions, new Comparator() {
|
||||
public int compare(Object x, Object y) {
|
||||
return ((String)x).compareTo((String)y);
|
||||
Arrays.sort(conversions, new Comparator<String>() {
|
||||
public int compare(String x, String y) {
|
||||
return x.compareTo(y);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -796,23 +799,22 @@ public class TypeMigrationLabeler {
|
||||
|
||||
buffer.append("\nNew expression type changes:\n");
|
||||
|
||||
final String[] newchanges = new String[myNewExpressionTypeChange.size()];
|
||||
final String[] newChanges = new String[myNewExpressionTypeChange.size()];
|
||||
k = 0;
|
||||
|
||||
for (final Map.Entry<TypeMigrationUsageInfo, PsiType> entry : myNewExpressionTypeChange.entrySet()) {
|
||||
|
||||
|
||||
newchanges[k++] = entry.getKey().getElement().getText() + " -> " + entry.getValue().getCanonicalText() + "\n";
|
||||
final PsiElement element = entry.getKey().getElement();
|
||||
newChanges[k++] = (element != null ? element.getText() : entry.getKey()) + " -> " + entry.getValue().getCanonicalText() + "\n";
|
||||
}
|
||||
|
||||
Arrays.sort(newchanges, new Comparator() {
|
||||
public int compare(Object x, Object y) {
|
||||
return ((String)x).compareTo((String)y);
|
||||
Arrays.sort(newChanges, new Comparator<String>() {
|
||||
public int compare(String x, String y) {
|
||||
return x.compareTo(y);
|
||||
}
|
||||
});
|
||||
|
||||
for (String newchange : newchanges) {
|
||||
buffer.append(newchange);
|
||||
for (String change : newChanges) {
|
||||
buffer.append(change);
|
||||
}
|
||||
|
||||
buffer.append("Fails:\n");
|
||||
@@ -830,13 +832,12 @@ public class TypeMigrationLabeler {
|
||||
for (final Pair<PsiAnchor, PsiType> p : failsList) {
|
||||
final PsiElement element = p.getFirst().retrieve();
|
||||
if (element != null) {
|
||||
buffer.append(element.getText() + "->" + p.getSecond().getCanonicalText() + "\n");
|
||||
buffer.append(element.getText()).append("->").append(p.getSecond().getCanonicalText()).append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static class MigrateException extends RuntimeException {
|
||||
}
|
||||
public static class MigrateException extends RuntimeException { }
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class TypeMigrationRules {
|
||||
|
||||
@NonNls
|
||||
@Nullable
|
||||
public TypeConversionDescriptorBase findConversion(final PsiType from, final PsiType to, PsiMember member, final PsiExpression context, final boolean isCovariantPosition,
|
||||
final TypeMigrationLabeler labeler) {
|
||||
public TypeConversionDescriptorBase findConversion(final PsiType from, final PsiType to, final PsiMember member, final PsiExpression context,
|
||||
final boolean isCovariantPosition, final TypeMigrationLabeler labeler) {
|
||||
final TypeConversionDescriptorBase conversion = findConversion(from, to, member, context, labeler);
|
||||
if (conversion != null) return conversion;
|
||||
|
||||
@@ -74,12 +74,13 @@ public class TypeMigrationRules {
|
||||
}
|
||||
if (TypeConversionUtil.isAssignable(to, from)) return new TypeConversionDescriptorBase();
|
||||
}
|
||||
if (!isCovariantPosition && TypeConversionUtil.isAssignable(from, to)) return new TypeConversionDescriptorBase();
|
||||
return null;
|
||||
|
||||
return !isCovariantPosition && TypeConversionUtil.isAssignable(from, to) ? new TypeConversionDescriptorBase() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TypeConversionDescriptorBase findConversion(PsiType from, PsiType to, PsiMember member, PsiExpression context, TypeMigrationLabeler labeler) {
|
||||
public TypeConversionDescriptorBase findConversion(final PsiType from, final PsiType to, final PsiMember member,
|
||||
final PsiExpression context, final TypeMigrationLabeler labeler) {
|
||||
for (TypeConversionRule descriptor : myConversionRules) {
|
||||
final TypeConversionDescriptorBase conversion = descriptor.findConversion(from, to, member, context, labeler);
|
||||
if (conversion != null) return conversion;
|
||||
@@ -96,7 +97,8 @@ public class TypeMigrationRules {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Pair<PsiType, PsiType> bindTypeParameters(final PsiType from, final PsiType to, final PsiMethod method, final PsiExpression context, final TypeMigrationLabeler labeler) {
|
||||
public Pair<PsiType, PsiType> bindTypeParameters(final PsiType from, final PsiType to, final PsiMethod method,
|
||||
final PsiExpression context, final TypeMigrationLabeler labeler) {
|
||||
for (TypeConversionRule conversionRule : myConversionRules) {
|
||||
final Pair<PsiType, PsiType> typePair = conversionRule.bindTypeParameters(from, to, method, context, labeler);
|
||||
if (typePair != null) return typePair;
|
||||
|
||||
Reference in New Issue
Block a user