From 33dc792bf9c0d766622c5115a35c28a732eed8a7 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Fri, 15 Apr 2016 14:41:15 +0300 Subject: [PATCH] Minor: extract constant --- .../jetbrains/kotlin/annotation/AnnotatedElementDescriptor.kt | 3 +++ .../jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt | 2 +- .../org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotatedElementDescriptor.kt b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotatedElementDescriptor.kt index ad301bdf31b..c30b55ed6d4 100644 --- a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotatedElementDescriptor.kt +++ b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotatedElementDescriptor.kt @@ -12,6 +12,9 @@ sealed class AnnotatedElementDescriptor(val classFqName: String) { } class Constructor(classFqName: String) : AnnotatedElementDescriptor(classFqName) { + companion object { + const val METHOD_NAME = "" + } // use referential equality } diff --git a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt index ca5074c9733..1ee857e7850 100644 --- a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt +++ b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt @@ -102,7 +102,7 @@ class KotlinAnnotationProvider(annotationsReader: Reader) { ANNOTATED_METHOD -> { val name = elementName ?: throw AssertionError("Name for method must be provided") - if ("" == name) + if (AnnotatedElementDescriptor.Constructor.METHOD_NAME == name) AnnotatedElementDescriptor.Constructor(classFqName) else AnnotatedElementDescriptor.Method(classFqName, name) diff --git a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt index a3ffb6086e8..0d556423bf9 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt +++ b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt @@ -63,7 +63,7 @@ public class AnnotationListParseTest { when (element) { is AnnotatedElementDescriptor.Method -> actualAnnotations.append(' ').append(element.methodName) is AnnotatedElementDescriptor.Field -> actualAnnotations.append(' ').append(element.fieldName) - is AnnotatedElementDescriptor.Constructor -> actualAnnotations.append(" ") + is AnnotatedElementDescriptor.Constructor -> actualAnnotations.append(" ${AnnotatedElementDescriptor.Constructor.METHOD_NAME}") is AnnotatedElementDescriptor.Class -> {} } actualAnnotations.append('\n')