This commit is contained in:
Natalia Ukhorskaya
2014-02-18 13:40:23 +04:00
parent df3ed5059c
commit 000dd4478a
9 changed files with 16 additions and 18 deletions
@@ -26,5 +26,5 @@ public interface ErrorReporter {
void reportCannotInferVisibility(@NotNull CallableMemberDescriptor descriptor);
void reportAnnotationLoadingError(@NotNull String message, @Nullable Exception exception);
void reportLoadingError(@NotNull String message, @Nullable Exception exception);
}
@@ -39,7 +39,6 @@ import org.jetbrains.jet.lang.resolve.java.resolver.ResolverPackage;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.DependencyClassByQualifiedNameResolver;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetType;
import javax.inject.Inject;
import java.io.IOException;
@@ -81,14 +80,14 @@ public class AnnotationDescriptorDeserializer extends BaseDescriptorDeserializer
if (kotlinClass == null) {
// This means that the resource we're constructing the descriptor from is no longer present: KotlinClassFinder had found the
// class earlier, but it can't now
errorReporter.reportAnnotationLoadingError("Kotlin class for loading class annotations is not found: " + descriptor, null);
errorReporter.reportLoadingError("Kotlin class for loading class annotations is not found: " + descriptor, null);
return Annotations.EMPTY;
}
try {
return loadClassAnnotationsFromClass(kotlinClass);
}
catch (IOException e) {
errorReporter.reportAnnotationLoadingError("Error loading member annotations from Kotlin class: " + kotlinClass, e);
errorReporter.reportLoadingError("Error loading member annotations from Kotlin class: " + kotlinClass, e);
return Annotations.EMPTY;
}
}
@@ -207,9 +206,9 @@ public class AnnotationDescriptorDeserializer extends BaseDescriptorDeserializer
@NotNull AnnotatedCallableKind kind,
@NotNull MemberSignature signature
) {
KotlinJvmBinaryClass kotlinClass = findClassWithMemberAnnotations(container, proto, nameResolver, kind);
KotlinJvmBinaryClass kotlinClass = findClassWithAnnotationsAndInitializers(container, proto, nameResolver, kind);
if (kotlinClass == null) {
errorReporter.reportAnnotationLoadingError("Kotlin class for loading member annotations is not found: " + container, null);
errorReporter.reportLoadingError("Kotlin class for loading member annotations is not found: " + container, null);
return Annotations.EMPTY;
}
@@ -97,7 +97,7 @@ public abstract class BaseDescriptorDeserializer {
}
@Nullable
protected KotlinJvmBinaryClass findClassWithMemberAnnotations(
protected KotlinJvmBinaryClass findClassWithAnnotationsAndInitializers(
@NotNull ClassOrPackageFragmentDescriptor container,
@NotNull ProtoBuf.Callable proto,
@NotNull NameResolver nameResolver,
@@ -67,9 +67,9 @@ public class ConstantDescriptorDeserializer extends BaseDescriptorDeserializer i
MemberSignature signature = getCallableSignature(proto, nameResolver, kind);
if (signature == null) return null;
KotlinJvmBinaryClass kotlinClass = findClassWithMemberAnnotations(container, proto, nameResolver, kind);
KotlinJvmBinaryClass kotlinClass = findClassWithAnnotationsAndInitializers(container, proto, nameResolver, kind);
if (kotlinClass == null) {
errorReporter.reportAnnotationLoadingError("Kotlin class for loading property constant is not found: " + container, null);
errorReporter.reportLoadingError("Kotlin class for loading property constant is not found: " + container, null);
return null;
}
@@ -46,11 +46,10 @@ public class DescriptorDeserializersStorage {
@Override
public Storage invoke(@NotNull KotlinJvmBinaryClass kotlinClass) {
try {
return loadMemberAnnotationsFromClass(kotlinClass);
return loadAnnotationsAndInitializers(kotlinClass);
}
catch (IOException e) {
errorReporter.reportAnnotationLoadingError(
"Error loading member annotations from Kotlin class: " + kotlinClass, e);
errorReporter.reportLoadingError("Error loading member information from Kotlin class: " + kotlinClass, e);
return Storage.EMPTY;
}
}
@@ -73,11 +72,11 @@ public class DescriptorDeserializersStorage {
}
@NotNull
private Storage loadMemberAnnotationsFromClass(@NotNull KotlinJvmBinaryClass kotlinClass) throws IOException {
private Storage loadAnnotationsAndInitializers(@NotNull KotlinJvmBinaryClass kotlinClass) throws IOException {
final Map<MemberSignature, List<AnnotationDescriptor>> memberAnnotations = new HashMap<MemberSignature, List<AnnotationDescriptor>>();
final Map<MemberSignature, CompileTimeConstant<?>> propertyConstants = new HashMap<MemberSignature, CompileTimeConstant<?>>();
kotlinClass.loadMemberAnnotations(new KotlinJvmBinaryClass.MemberVisitor() {
kotlinClass.visitMembers(new KotlinJvmBinaryClass.MemberVisitor() {
@Nullable
@Override
public KotlinJvmBinaryClass.MethodAnnotationVisitor visitMethod(@NotNull Name name, @NotNull String desc) {
@@ -28,7 +28,7 @@ public interface KotlinJvmBinaryClass {
void loadClassAnnotations(@NotNull AnnotationVisitor visitor);
void loadMemberAnnotations(@NotNull MemberVisitor visitor);
void visitMembers(@NotNull MemberVisitor visitor);
@Nullable
KotlinClassHeader getClassHeader();