From e7fc6bcc6ec4e90652d29380766b17ec28c7a4dc Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 11 Dec 2015 11:10:05 +0300 Subject: [PATCH] BuiltIns refactoring: getEnumEntry --- .../kotlin/builtins/KotlinBuiltIns.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 070ddfca26a..a17c446bfb6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -385,13 +385,18 @@ public abstract class KotlinBuiltIns { } @Nullable - public ClassDescriptor getDeprecationLevelEnumEntry(@NotNull DeprecationLevel level) { - ClassifierDescriptor result = getDeprecationLevelEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier( - Name.identifier(level.name()), NoLookupLocation.FROM_BUILTINS + private static ClassDescriptor getEnumEntry(@NotNull ClassDescriptor enumDescriptor, @NotNull String entryName) { + ClassifierDescriptor result = enumDescriptor.getUnsubstitutedInnerClassesScope().getContributedClassifier( + Name.identifier(entryName), NoLookupLocation.FROM_BUILTINS ); return result instanceof ClassDescriptor ? (ClassDescriptor) result : null; } + @Nullable + public ClassDescriptor getDeprecationLevelEnumEntry(@NotNull DeprecationLevel level) { + return getEnumEntry(getDeprecationLevelEnum(), level.name()); + } + @NotNull public ClassDescriptor getTargetAnnotation() { return getAnnotationClassByName(FQ_NAMES.target.shortName()); @@ -419,10 +424,7 @@ public abstract class KotlinBuiltIns { @Nullable public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull KotlinTarget target) { - ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier( - Name.identifier(target.name()), NoLookupLocation.FROM_BUILTINS - ); - return result instanceof ClassDescriptor ? (ClassDescriptor) result : null; + return getEnumEntry(getAnnotationTargetEnum(), target.name()); } @NotNull @@ -432,10 +434,7 @@ public abstract class KotlinBuiltIns { @Nullable public ClassDescriptor getAnnotationRetentionEnumEntry(@NotNull KotlinRetention retention) { - ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier( - Name.identifier(retention.name()), NoLookupLocation.FROM_BUILTINS - ); - return result instanceof ClassDescriptor ? (ClassDescriptor) result : null; + return getEnumEntry(getAnnotationRetentionEnum(), retention.name()); } @NotNull