toString(JetType) extracted
This commit is contained in:
committed by
Alexander Udalov
parent
b9283f0afc
commit
6be5ecc666
@@ -24,7 +24,6 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
|||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class JetTypeImpl extends AnnotatedImpl implements JetType {
|
public final class JetTypeImpl extends AnnotatedImpl implements JetType {
|
||||||
@@ -84,19 +83,7 @@ public final class JetTypeImpl extends AnnotatedImpl implements JetType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return constructor + (arguments.isEmpty() ? "" : "<" + argumentsToString() + ">") + (isNullable() ? "?" : "");
|
return TypeUtils.toString(this);
|
||||||
}
|
|
||||||
|
|
||||||
private StringBuilder argumentsToString() {
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
for (Iterator<TypeProjection> iterator = arguments.iterator(); iterator.hasNext();) {
|
|
||||||
TypeProjection argument = iterator.next();
|
|
||||||
stringBuilder.append(argument);
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
stringBuilder.append(", ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stringBuilder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -180,6 +180,24 @@ public class TypeUtils {
|
|||||||
new ChainedScope(null, scopes)); // TODO : check intersectibility, don't use a chanied scope
|
new ChainedScope(null, scopes)); // TODO : check intersectibility, don't use a chanied scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String toString(@NotNull JetType type) {
|
||||||
|
List<TypeProjection> arguments = type.getArguments();
|
||||||
|
return type.getConstructor() + (arguments.isEmpty() ? "" : "<" + argumentsToString(arguments) + ">") + (type.isNullable() ? "?" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static StringBuilder argumentsToString(List<TypeProjection> arguments) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (Iterator<TypeProjection> iterator = arguments.iterator(); iterator.hasNext();) {
|
||||||
|
TypeProjection argument = iterator.next();
|
||||||
|
stringBuilder.append(argument);
|
||||||
|
if (iterator.hasNext()) {
|
||||||
|
stringBuilder.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
private static class TypeUnifier {
|
private static class TypeUnifier {
|
||||||
private static class TypeParameterUsage {
|
private static class TypeParameterUsage {
|
||||||
private final TypeParameterDescriptor typeParameterDescriptor;
|
private final TypeParameterDescriptor typeParameterDescriptor;
|
||||||
|
|||||||
Reference in New Issue
Block a user