001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.descriptors.serialization.descriptors;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.jet.descriptors.serialization.NameResolver;
021 import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
022 import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
023 import org.jetbrains.jet.lang.descriptors.ClassOrPackageFragmentDescriptor;
024 import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
025
026 public interface AnnotationLoader {
027 AnnotationLoader UNSUPPORTED = new AnnotationLoader() {
028 @NotNull
029 @Override
030 public Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) {
031 return notSupported();
032 }
033
034 @NotNull
035 @Override
036 public Annotations loadCallableAnnotations(
037 @NotNull ClassOrPackageFragmentDescriptor container,
038 @NotNull ProtoBuf.Callable proto,
039 @NotNull NameResolver nameResolver,
040 @NotNull AnnotatedCallableKind kind
041 ) {
042 return notSupported();
043 }
044
045 @NotNull
046 @Override
047 public Annotations loadValueParameterAnnotations(
048 @NotNull ClassOrPackageFragmentDescriptor container,
049 @NotNull ProtoBuf.Callable callable,
050 @NotNull NameResolver nameResolver,
051 @NotNull AnnotatedCallableKind kind,
052 @NotNull ProtoBuf.Callable.ValueParameter proto
053 ) {
054 return notSupported();
055 }
056
057 @NotNull
058 private Annotations notSupported() {
059 throw new UnsupportedOperationException("Annotations are not supported");
060 }
061 };
062
063 @NotNull
064 Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto);
065
066 @NotNull
067 Annotations loadCallableAnnotations(
068 @NotNull ClassOrPackageFragmentDescriptor container,
069 @NotNull ProtoBuf.Callable proto,
070 @NotNull NameResolver nameResolver,
071 @NotNull AnnotatedCallableKind kind
072 );
073
074 @NotNull
075 Annotations loadValueParameterAnnotations(
076 @NotNull ClassOrPackageFragmentDescriptor container,
077 @NotNull ProtoBuf.Callable callable,
078 @NotNull NameResolver nameResolver,
079 @NotNull AnnotatedCallableKind kind,
080 @NotNull ProtoBuf.Callable.ValueParameter proto
081 );
082 }