Refactoring: AnnotationTarget / AnnotationRetention renamed to KotlinTarget / KotlinRetention
(for not clashing with the same built-in classes)
This commit is contained in:
@@ -168,26 +168,26 @@ public abstract class AnnotationCodegen {
|
||||
generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass);
|
||||
}
|
||||
|
||||
private static final Map<AnnotationTarget, ElementType> annotationTargetMap =
|
||||
new EnumMap<AnnotationTarget, ElementType>(AnnotationTarget.class);
|
||||
private static final Map<KotlinTarget, ElementType> annotationTargetMap =
|
||||
new EnumMap<KotlinTarget, ElementType>(KotlinTarget.class);
|
||||
|
||||
static {
|
||||
annotationTargetMap.put(AnnotationTarget.PACKAGE, ElementType.PACKAGE);
|
||||
annotationTargetMap.put(AnnotationTarget.CLASSIFIER, ElementType.TYPE);
|
||||
annotationTargetMap.put(AnnotationTarget.ANNOTATION_CLASS, ElementType.ANNOTATION_TYPE);
|
||||
annotationTargetMap.put(AnnotationTarget.CONSTRUCTOR, ElementType.CONSTRUCTOR);
|
||||
annotationTargetMap.put(AnnotationTarget.LOCAL_VARIABLE, ElementType.LOCAL_VARIABLE);
|
||||
annotationTargetMap.put(AnnotationTarget.FUNCTION, ElementType.METHOD);
|
||||
annotationTargetMap.put(AnnotationTarget.PROPERTY_GETTER, ElementType.METHOD);
|
||||
annotationTargetMap.put(AnnotationTarget.PROPERTY_SETTER, ElementType.METHOD);
|
||||
annotationTargetMap.put(AnnotationTarget.FIELD, ElementType.FIELD);
|
||||
annotationTargetMap.put(AnnotationTarget.VALUE_PARAMETER, ElementType.PARAMETER);
|
||||
annotationTargetMap.put(KotlinTarget.PACKAGE, ElementType.PACKAGE);
|
||||
annotationTargetMap.put(KotlinTarget.CLASSIFIER, ElementType.TYPE);
|
||||
annotationTargetMap.put(KotlinTarget.ANNOTATION_CLASS, ElementType.ANNOTATION_TYPE);
|
||||
annotationTargetMap.put(KotlinTarget.CONSTRUCTOR, ElementType.CONSTRUCTOR);
|
||||
annotationTargetMap.put(KotlinTarget.LOCAL_VARIABLE, ElementType.LOCAL_VARIABLE);
|
||||
annotationTargetMap.put(KotlinTarget.FUNCTION, ElementType.METHOD);
|
||||
annotationTargetMap.put(KotlinTarget.PROPERTY_GETTER, ElementType.METHOD);
|
||||
annotationTargetMap.put(KotlinTarget.PROPERTY_SETTER, ElementType.METHOD);
|
||||
annotationTargetMap.put(KotlinTarget.FIELD, ElementType.FIELD);
|
||||
annotationTargetMap.put(KotlinTarget.VALUE_PARAMETER, ElementType.PARAMETER);
|
||||
}
|
||||
|
||||
private void generateTargetAnnotation(@NotNull ClassDescriptor classDescriptor, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
|
||||
String descriptor = Type.getType(Target.class).getDescriptor();
|
||||
if (!annotationDescriptorsAlreadyPresent.add(descriptor)) return;
|
||||
Set<AnnotationTarget> targets = AnnotationTargetChecker.INSTANCE$.possibleTargetSet(classDescriptor);
|
||||
Set<KotlinTarget> targets = AnnotationTargetChecker.INSTANCE$.possibleTargetSet(classDescriptor);
|
||||
Set<ElementType> javaTargets;
|
||||
if (targets == null) {
|
||||
javaTargets = getJavaTargetList(classDescriptor);
|
||||
@@ -195,7 +195,7 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
else {
|
||||
javaTargets = EnumSet.noneOf(ElementType.class);
|
||||
for (AnnotationTarget target : targets) {
|
||||
for (KotlinTarget target : targets) {
|
||||
if (annotationTargetMap.get(target) == null) continue;
|
||||
javaTargets.add(annotationTargetMap.get(target));
|
||||
}
|
||||
@@ -368,13 +368,13 @@ public abstract class AnnotationCodegen {
|
||||
value.accept(argumentVisitor, null);
|
||||
}
|
||||
|
||||
private static final Map<AnnotationRetention, RetentionPolicy> annotationRetentionMap =
|
||||
new EnumMap<AnnotationRetention, RetentionPolicy>(AnnotationRetention.class);
|
||||
private static final Map<KotlinRetention, RetentionPolicy> annotationRetentionMap =
|
||||
new EnumMap<KotlinRetention, RetentionPolicy>(KotlinRetention.class);
|
||||
|
||||
static {
|
||||
annotationRetentionMap.put(AnnotationRetention.SOURCE, RetentionPolicy.SOURCE);
|
||||
annotationRetentionMap.put(AnnotationRetention.BINARY, RetentionPolicy.CLASS);
|
||||
annotationRetentionMap.put(AnnotationRetention.RUNTIME, RetentionPolicy.RUNTIME);
|
||||
annotationRetentionMap.put(KotlinRetention.SOURCE, RetentionPolicy.SOURCE);
|
||||
annotationRetentionMap.put(KotlinRetention.BINARY, RetentionPolicy.CLASS);
|
||||
annotationRetentionMap.put(KotlinRetention.RUNTIME, RetentionPolicy.RUNTIME);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -415,7 +415,7 @@ public abstract class AnnotationCodegen {
|
||||
JetType classObjectType = getClassObjectType(enumEntry);
|
||||
if (classObjectType != null) {
|
||||
if ("kotlin/annotation/AnnotationRetention".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
||||
AnnotationRetention retention = AnnotationRetention.valueOf(enumEntry.getName().asString());
|
||||
KotlinRetention retention = KotlinRetention.valueOf(enumEntry.getName().asString());
|
||||
return annotationRetentionMap.get(retention);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user