001    package org.jetbrains.jet.descriptors.serialization.descriptors;
002    
003    import org.jetbrains.annotations.NotNull;
004    import org.jetbrains.jet.descriptors.serialization.NameResolver;
005    import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
006    import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
007    import org.jetbrains.jet.lang.descriptors.ClassOrNamespaceDescriptor;
008    import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
009    
010    import java.util.List;
011    
012    public interface AnnotationDeserializer {
013        AnnotationDeserializer UNSUPPORTED = new AnnotationDeserializer() {
014            @NotNull
015            @Override
016            public List<AnnotationDescriptor> loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) {
017                return notSupported();
018            }
019    
020            @NotNull
021            @Override
022            public List<AnnotationDescriptor> loadCallableAnnotations(
023                    @NotNull ClassOrNamespaceDescriptor container,
024                    @NotNull ProtoBuf.Callable proto,
025                    @NotNull NameResolver nameResolver,
026                    @NotNull AnnotatedCallableKind kind
027            ) {
028                return notSupported();
029            }
030    
031            @NotNull
032            @Override
033            public List<AnnotationDescriptor> loadValueParameterAnnotations(@NotNull ProtoBuf.Callable.ValueParameter parameterProto) {
034                return notSupported();
035            }
036    
037            @NotNull
038            private List<AnnotationDescriptor> notSupported() {
039                throw new UnsupportedOperationException("Annotations are not supported");
040            }
041        };
042    
043        enum AnnotatedCallableKind {
044            FUNCTION,
045            PROPERTY,
046            PROPERTY_GETTER,
047            PROPERTY_SETTER
048        }
049    
050        @NotNull
051        List<AnnotationDescriptor> loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto);
052    
053        @NotNull
054        List<AnnotationDescriptor> loadCallableAnnotations(
055                @NotNull ClassOrNamespaceDescriptor container,
056                @NotNull ProtoBuf.Callable proto,
057                @NotNull NameResolver nameResolver,
058                @NotNull AnnotatedCallableKind kind
059        );
060    
061        @NotNull
062        List<AnnotationDescriptor> loadValueParameterAnnotations(@NotNull ProtoBuf.Callable.ValueParameter parameterProto);
063    }