Move ClassSerializationUtil to 'compiler-tests' module
It's not used in 'serialization'
This commit is contained in:
+9
-19
@@ -20,8 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -34,7 +32,11 @@ public class ClassSerializationUtil {
|
|||||||
void writeClass(@NotNull ClassDescriptor classDescriptor, @NotNull ProtoBuf.Class classProto);
|
void writeClass(@NotNull ClassDescriptor classDescriptor, @NotNull ProtoBuf.Class classProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serializeClass(@NotNull ClassDescriptor classDescriptor, @NotNull DescriptorSerializer serializer, @NotNull Sink sink) {
|
private static void serializeClass(
|
||||||
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
|
@NotNull DescriptorSerializer serializer,
|
||||||
|
@NotNull Sink sink
|
||||||
|
) {
|
||||||
ProtoBuf.Class classProto = serializer.classProto(classDescriptor).build();
|
ProtoBuf.Class classProto = serializer.classProto(classDescriptor).build();
|
||||||
sink.writeClass(classDescriptor, classProto);
|
sink.writeClass(classDescriptor, classProto);
|
||||||
|
|
||||||
@@ -62,22 +64,10 @@ public class ClassSerializationUtil {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ClassId getClassId(@NotNull ClassDescriptor classDescriptor) {
|
public static ClassId getClassId(@NotNull ClassDescriptor classDescriptor) {
|
||||||
DeclarationDescriptor containingDeclaration = classDescriptor.getContainingDeclaration();
|
DeclarationDescriptor owner = classDescriptor.getContainingDeclaration();
|
||||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
if (owner instanceof NamespaceDescriptor) {
|
||||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
|
return new ClassId(((NamespaceDescriptor) owner).getFqName(), FqNameUnsafe.topLevel(classDescriptor.getName()));
|
||||||
return new ClassId(getPackageFqName(namespaceDescriptor), FqNameUnsafe.topLevel(classDescriptor.getName()));
|
|
||||||
}
|
}
|
||||||
// it must be a nested class
|
return getClassId((ClassDescriptor) owner).createNestedClassId(classDescriptor.getName());
|
||||||
ClassDescriptor outer = (ClassDescriptor) containingDeclaration;
|
|
||||||
ClassId outerId = getClassId(outer);
|
|
||||||
return outerId.createNestedClassId(classDescriptor.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static FqName getPackageFqName(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
|
||||||
if (DescriptorUtils.isRootNamespace(namespaceDescriptor)) return FqName.ROOT;
|
|
||||||
|
|
||||||
NamespaceDescriptor parent = (NamespaceDescriptor) namespaceDescriptor.getContainingDeclaration();
|
|
||||||
return getPackageFqName(parent).child(namespaceDescriptor.getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user