Save class file to deserialized descriptor

This commit is contained in:
Alexey Tsvetkov
2015-07-30 15:38:08 +03:00
parent 0688afbb0c
commit 53eccb98e3
5 changed files with 41 additions and 17 deletions
@@ -24,7 +24,9 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.serialization.ClassData;
import org.jetbrains.kotlin.serialization.PackageData;
import org.jetbrains.kotlin.serialization.deserialization.ClassDataProvider;
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents;
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope;
@@ -55,9 +57,10 @@ public final class DeserializedDescriptorResolver {
public ClassDescriptor resolveClass(@NotNull KotlinJvmBinaryClass kotlinClass) {
String[] data = readData(kotlinClass, CLASS);
if (data != null) {
return components.getClassDeserializer().deserializeClass(
kotlinClass.getClassId(), JvmProtoBufUtil.readClassDataFrom(data)
);
ClassData classData = JvmProtoBufUtil.readClassDataFrom(data);
KotlinJvmBinarySourceElement sourceElement = new KotlinJvmBinarySourceElement(kotlinClass);
ClassDataProvider classDataProvider = new ClassDataProvider(classData, sourceElement);
return components.getClassDeserializer().deserializeClass(kotlinClass.getClassId(), classDataProvider);
}
return null;
}
@@ -33,6 +33,6 @@ public class JavaClassDataFinder(
}
val data = deserializedDescriptorResolver.readData(kotlinJvmBinaryClass, KotlinClassHeader.Kind.CLASS) ?: return null
val classData = JvmProtoBufUtil.readClassDataFrom(data)
return ClassDataProvider(classData)
return ClassDataProvider(classData, KotlinJvmBinarySourceElement(kotlinJvmBinaryClass))
}
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.descriptors.SourceElement
public class KotlinJvmBinarySourceElement(public val binaryClass: KotlinJvmBinaryClass) : SourceElement