Make DeserializedType a static nested class
This commit is contained in:
@@ -155,7 +155,7 @@ class LazyOperationsLog(
|
|||||||
javaClass.getPsi().getName().appendQuoted()
|
javaClass.getPsi().getName().appendQuoted()
|
||||||
}
|
}
|
||||||
o.javaClass.getSimpleName() == "DeserializedType" -> {
|
o.javaClass.getSimpleName() == "DeserializedType" -> {
|
||||||
val typeDeserializer = o.field<TypeDeserializer>("this\$0")
|
val typeDeserializer = o.field<TypeDeserializer>("typeDeserializer")
|
||||||
val context = typeDeserializer.field<DeserializationContext>("context")
|
val context = typeDeserializer.field<DeserializationContext>("context")
|
||||||
val typeProto = o.field<ProtoBuf.Type>("typeProto")
|
val typeProto = o.field<ProtoBuf.Type>("typeProto")
|
||||||
val text = when (typeProto.getConstructor().getKind()) {
|
val text = when (typeProto.getConstructor().getKind()) {
|
||||||
|
|||||||
+35
-28
@@ -82,18 +82,22 @@ public class TypeDeserializer {
|
|||||||
String id = context.getNameResolver().getString(proto.getFlexibleTypeCapabilitiesId());
|
String id = context.getNameResolver().getString(proto.getFlexibleTypeCapabilitiesId());
|
||||||
FlexibleTypeCapabilities capabilities = getComponents().getFlexibleTypeCapabilitiesDeserializer().capabilitiesById(id);
|
FlexibleTypeCapabilities capabilities = getComponents().getFlexibleTypeCapabilitiesDeserializer().capabilitiesById(id);
|
||||||
|
|
||||||
if (capabilities == null) return ErrorUtils.createErrorType(new DeserializedType(proto) + ": Capabilities not found for id " + id);
|
if (capabilities == null) {
|
||||||
|
return ErrorUtils.createErrorType(new DeserializedType(context, proto) + ": Capabilities not found for id " + id);
|
||||||
|
}
|
||||||
|
|
||||||
return DelegatingFlexibleType.create(
|
return DelegatingFlexibleType.create(
|
||||||
new DeserializedType(proto),
|
new DeserializedType(context, proto),
|
||||||
new DeserializedType(proto.getFlexibleUpperBound()),
|
new DeserializedType(context, proto.getFlexibleUpperBound()),
|
||||||
capabilities
|
capabilities
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new DeserializedType(proto);
|
|
||||||
|
return new DeserializedType(context, proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeConstructor typeConstructor(ProtoBuf.Type proto) {
|
@NotNull
|
||||||
|
public TypeConstructor typeConstructor(@NotNull ProtoBuf.Type proto) {
|
||||||
ProtoBuf.Type.Constructor constructorProto = proto.getConstructor();
|
ProtoBuf.Type.Constructor constructorProto = proto.getConstructor();
|
||||||
int id = constructorProto.getId();
|
int id = constructorProto.getId();
|
||||||
TypeConstructor typeConstructor = typeConstructor(constructorProto);
|
TypeConstructor typeConstructor = typeConstructor(constructorProto);
|
||||||
@@ -101,7 +105,7 @@ public class TypeDeserializer {
|
|||||||
String message = constructorProto.getKind() == ProtoBuf.Type.Constructor.Kind.CLASS
|
String message = constructorProto.getKind() == ProtoBuf.Type.Constructor.Kind.CLASS
|
||||||
? context.getNameResolver().getClassId(id).asSingleFqName().asString()
|
? context.getNameResolver().getClassId(id).asSingleFqName().asString()
|
||||||
: "Unknown type parameter " + id;
|
: "Unknown type parameter " + id;
|
||||||
typeConstructor = ErrorUtils.createErrorType(message).getConstructor();
|
return ErrorUtils.createErrorType(message).getConstructor();
|
||||||
}
|
}
|
||||||
return typeConstructor;
|
return typeConstructor;
|
||||||
}
|
}
|
||||||
@@ -142,7 +146,8 @@ public class TypeDeserializer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TypeProjection> typeArguments(List<ProtoBuf.Type.Argument> protos) {
|
@NotNull
|
||||||
|
public List<TypeProjection> typeArguments(@NotNull List<ProtoBuf.Type.Argument> protos) {
|
||||||
List<TypeProjection> result = new ArrayList<TypeProjection>(protos.size());
|
List<TypeProjection> result = new ArrayList<TypeProjection>(protos.size());
|
||||||
for (ProtoBuf.Type.Argument proto : protos) {
|
for (ProtoBuf.Type.Argument proto : protos) {
|
||||||
result.add(typeProjection(proto));
|
result.add(typeProjection(proto));
|
||||||
@@ -154,43 +159,30 @@ public class TypeDeserializer {
|
|||||||
return new TypeProjectionImpl(variance(proto.getProjection()), type(proto.getType()));
|
return new TypeProjectionImpl(variance(proto.getProjection()), type(proto.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static JetScope getTypeMemberScope(@NotNull TypeConstructor constructor, @NotNull List<TypeProjection> typeArguments) {
|
|
||||||
ClassifierDescriptor descriptor = constructor.getDeclarationDescriptor();
|
|
||||||
if (descriptor instanceof TypeParameterDescriptor) {
|
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
|
||||||
return typeParameterDescriptor.getDefaultType().getMemberScope();
|
|
||||||
}
|
|
||||||
else if (descriptor instanceof ClassDescriptor) {
|
|
||||||
return ((ClassDescriptor) descriptor).getMemberScope(typeArguments);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalStateException("Unsupported classifier: " + descriptor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return debugName;
|
return debugName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DeserializedType extends AbstractJetType implements LazyType {
|
private static class DeserializedType extends AbstractJetType implements LazyType {
|
||||||
|
private final TypeDeserializer typeDeserializer;
|
||||||
private final ProtoBuf.Type typeProto;
|
private final ProtoBuf.Type typeProto;
|
||||||
private final NotNullLazyValue<TypeConstructor> constructor;
|
private final NotNullLazyValue<TypeConstructor> constructor;
|
||||||
private final List<TypeProjection> arguments;
|
private final List<TypeProjection> arguments;
|
||||||
private final NotNullLazyValue<JetScope> memberScope;
|
private final NotNullLazyValue<JetScope> memberScope;
|
||||||
|
|
||||||
public DeserializedType(@NotNull ProtoBuf.Type proto) {
|
public DeserializedType(@NotNull DeserializationContext context, @NotNull ProtoBuf.Type proto) {
|
||||||
|
this.typeDeserializer = context.getTypeDeserializer();
|
||||||
this.typeProto = proto;
|
this.typeProto = proto;
|
||||||
this.arguments = typeArguments(proto.getArgumentList());
|
this.arguments = typeDeserializer.typeArguments(proto.getArgumentList());
|
||||||
|
|
||||||
this.constructor = getComponents().getStorageManager().createLazyValue(new Function0<TypeConstructor>() {
|
this.constructor = context.getComponents().getStorageManager().createLazyValue(new Function0<TypeConstructor>() {
|
||||||
@Override
|
@Override
|
||||||
public TypeConstructor invoke() {
|
public TypeConstructor invoke() {
|
||||||
return typeConstructor(typeProto);
|
return typeDeserializer.typeConstructor(typeProto);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.memberScope = getComponents().getStorageManager().createLazyValue(new Function0<JetScope>() {
|
this.memberScope = context.getComponents().getStorageManager().createLazyValue(new Function0<JetScope>() {
|
||||||
@Override
|
@Override
|
||||||
public JetScope invoke() {
|
public JetScope invoke() {
|
||||||
return computeMemberScope();
|
return computeMemberScope();
|
||||||
@@ -225,6 +217,21 @@ public class TypeDeserializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static JetScope getTypeMemberScope(@NotNull TypeConstructor constructor, @NotNull List<TypeProjection> typeArguments) {
|
||||||
|
ClassifierDescriptor descriptor = constructor.getDeclarationDescriptor();
|
||||||
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
||||||
|
return typeParameterDescriptor.getDefaultType().getMemberScope();
|
||||||
|
}
|
||||||
|
else if (descriptor instanceof ClassDescriptor) {
|
||||||
|
return ((ClassDescriptor) descriptor).getMemberScope(typeArguments);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalStateException("Unsupported classifier: " + descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public JetScope getMemberScope() {
|
public JetScope getMemberScope() {
|
||||||
|
|||||||
Reference in New Issue
Block a user