Only create lazy annotations for descriptors from code

This commit is contained in:
Andrey Breslav
2014-04-02 13:53:08 +04:00
parent c57243035e
commit bb87a6bb59
4 changed files with 45 additions and 77 deletions
@@ -42,7 +42,9 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.jetbrains.jet.descriptors.serialization.descriptors.Deserializers.AnnotatedCallableKind;
import static org.jetbrains.jet.lang.resolve.kotlin.DescriptorDeserializersStorage.MemberSignature;
@@ -119,10 +121,10 @@ public class AnnotationDescriptorDeserializer extends BaseDescriptorDeserializer
if (JvmAnnotationNames.isSpecialAnnotation(className)) return null;
final ClassDescriptor annotationClass = resolveClass(className, classResolver);
final AnnotationDescriptorImpl annotation = new AnnotationDescriptorImpl();
annotation.setAnnotationType(annotationClass.getDefaultType());
return new KotlinJvmBinaryClass.AnnotationArgumentVisitor() {
private final Map<ValueParameterDescriptor, CompileTimeConstant<?>> arguments = new HashMap<ValueParameterDescriptor, CompileTimeConstant<?>>();
@Override
public void visit(@Nullable Name name, @Nullable Object value) {
if (name != null) {
@@ -157,14 +159,16 @@ public class AnnotationDescriptorDeserializer extends BaseDescriptorDeserializer
@Override
public void visitEnd() {
annotation.markValueArgumentsResolved();
result.add(annotation);
result.add(new AnnotationDescriptorImpl(
annotationClass.getDefaultType(),
arguments
));
}
private void setArgumentValueByName(@NotNull Name name, @NotNull CompileTimeConstant<?> argumentValue) {
ValueParameterDescriptor parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass);
if (parameter != null) {
annotation.setValueArgument(parameter, argumentValue);
arguments.put(parameter, argumentValue);
}
}
};