Delete deprecated Type.Constructor message, advance ABI version

This commit is contained in:
Alexander Udalov
2015-09-16 16:21:43 +03:00
parent 42eb413066
commit e749bc262d
11 changed files with 483 additions and 2055 deletions
@@ -349,12 +349,23 @@ public class DescriptorSerializer {
public ProtoBuf.Type.Builder type(@NotNull JetType type) {
assert !type.isError() : "Can't serialize error types: " + type; // TODO
if (TypesPackage.isFlexible(type)) return flexibleType(type);
if (TypesPackage.isFlexible(type)) {
Flexibility flexibility = TypesPackage.flexibility(type);
return type(flexibility.getLowerBound())
.setFlexibleTypeCapabilitiesId(stringTable.getStringIndex(flexibility.getExtraCapabilities().getId()))
.setFlexibleUpperBound(type(flexibility.getUpperBound()));
}
ProtoBuf.Type.Builder builder = ProtoBuf.Type.newBuilder();
builder.setConstructor(typeConstructor(type.getConstructor()));
setTypeConstructorFields(builder, type.getConstructor());
ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor) {
builder.setClassName(getClassId((ClassDescriptor) descriptor));
}
if (descriptor instanceof TypeParameterDescriptor) {
builder.setTypeParameter(getTypeParameterId((TypeParameterDescriptor) descriptor));
}
for (TypeProjection projection : type.getArguments()) {
builder.addArgument(typeArgument(projection));
@@ -370,33 +381,6 @@ public class DescriptorSerializer {
return builder;
}
private void setTypeConstructorFields(@NotNull ProtoBuf.Type.Builder builder, @NotNull TypeConstructor typeConstructor) {
ClassifierDescriptor declarationDescriptor = typeConstructor.getDeclarationDescriptor();
assert declarationDescriptor instanceof TypeParameterDescriptor || declarationDescriptor instanceof ClassDescriptor
: "Unknown declaration descriptor: " + typeConstructor;
if (declarationDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
builder.setConstructorTypeParameter(getTypeParameterId(typeParameterDescriptor));
}
else {
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
builder.setConstructorClassName(getClassId(classDescriptor));
}
}
private ProtoBuf.Type.Builder flexibleType(@NotNull JetType type) {
Flexibility flexibility = TypesPackage.flexibility(type);
ProtoBuf.Type.Builder builder = type(flexibility.getLowerBound());
builder.setFlexibleTypeCapabilitiesId(stringTable.getStringIndex(flexibility.getExtraCapabilities().getId()));
builder.setFlexibleUpperBound(type(flexibility.getUpperBound()));
return builder;
}
@NotNull
private ProtoBuf.Type.Argument.Builder typeArgument(@NotNull TypeProjection typeProjection) {
ProtoBuf.Type.Argument.Builder builder = ProtoBuf.Type.Argument.newBuilder();
@@ -417,27 +401,6 @@ public class DescriptorSerializer {
return builder;
}
@NotNull
private ProtoBuf.Type.Constructor.Builder typeConstructor(@NotNull TypeConstructor typeConstructor) {
ProtoBuf.Type.Constructor.Builder builder = ProtoBuf.Type.Constructor.newBuilder();
ClassifierDescriptor declarationDescriptor = typeConstructor.getDeclarationDescriptor();
assert declarationDescriptor instanceof TypeParameterDescriptor || declarationDescriptor instanceof ClassDescriptor
: "Unknown declaration descriptor: " + typeConstructor;
if (declarationDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) declarationDescriptor;
builder.setKind(ProtoBuf.Type.Constructor.Kind.TYPE_PARAMETER);
builder.setId(getTypeParameterId(typeParameterDescriptor));
}
else {
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
//default: builder.setKind(Type.Constructor.Kind.CLASS);
builder.setId(getClassId(classDescriptor));
}
return builder;
}
@NotNull
public ProtoBuf.Package.Builder packageProto(@NotNull Collection<PackageFragmentDescriptor> fragments) {
return packageProto(fragments, null);
@@ -16,34 +16,30 @@
package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.descriptors.Named
import org.jetbrains.kotlin.load.java.structure.JavaNamedElement
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
import org.jetbrains.kotlin.load.java.structure.impl.JavaTypeImpl
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.descriptors.Named
import java.util.IdentityHashMap
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.load.java.structure.impl.JavaTypeImpl
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
import java.util.ArrayList
import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.load.java.structure.JavaNamedElement
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.resolve.DescriptorUtils
import java.util.HashMap
import org.jetbrains.kotlin.types.JetTypeImpl
import java.util.regex.Pattern
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTaskHolder
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.psi.debugText.getDebugText
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
import org.jetbrains.kotlin.serialization.deserialization.TypeConstructorKind
import org.jetbrains.kotlin.serialization.deserialization.getTypeConstructorData
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTaskHolder
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
import org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.JetTypeImpl
import org.jetbrains.kotlin.utils.Printer
import java.lang.reflect.Constructor
import java.lang.reflect.GenericDeclaration
import java.lang.reflect.Method
import java.lang.reflect.Constructor
import java.util.*
import java.util.regex.Pattern
class LazyOperationsLog(
val stringSanitizer: (String) -> String
@@ -160,12 +156,11 @@ class LazyOperationsLog(
val typeDeserializer = o.field<TypeDeserializer>("typeDeserializer")
val context = typeDeserializer.field<DeserializationContext>("c")
val typeProto = o.field<ProtoBuf.Type>("typeProto")
val typeConstructorData = typeProto.getTypeConstructorData()
val text = when (typeConstructorData.kind) {
TypeConstructorKind.CLASS -> context.nameResolver.getFqName(typeConstructorData.id).asString()
TypeConstructorKind.TYPE_PARAMETER -> {
val classifier = (o as JetType).getConstructor().getDeclarationDescriptor()!!
"" + classifier.getName() + " in " + DescriptorUtils.getFqName(classifier.getContainingDeclaration())
val text = when {
typeProto.hasClassName() -> context.nameResolver.getFqName(typeProto.className).asString()
typeProto.hasTypeParameter() -> {
val classifier = (o as JetType).constructor.declarationDescriptor!!
"" + classifier.name + " in " + DescriptorUtils.getFqName(classifier.containingDeclaration)
}
else -> "???"
}
File diff suppressed because it is too large Load Diff