Minor: extract constant

This commit is contained in:
Alexey Tsvetkov
2016-04-15 14:41:15 +03:00
parent 3ef21a941c
commit 33dc792bf9
3 changed files with 5 additions and 2 deletions
@@ -12,6 +12,9 @@ sealed class AnnotatedElementDescriptor(val classFqName: String) {
} }
class Constructor(classFqName: String) : AnnotatedElementDescriptor(classFqName) { class Constructor(classFqName: String) : AnnotatedElementDescriptor(classFqName) {
companion object {
const val METHOD_NAME = "<init>"
}
// use referential equality // use referential equality
} }
@@ -102,7 +102,7 @@ class KotlinAnnotationProvider(annotationsReader: Reader) {
ANNOTATED_METHOD -> { ANNOTATED_METHOD -> {
val name = elementName ?: throw AssertionError("Name for method must be provided") val name = elementName ?: throw AssertionError("Name for method must be provided")
if ("<init>" == name) if (AnnotatedElementDescriptor.Constructor.METHOD_NAME == name)
AnnotatedElementDescriptor.Constructor(classFqName) AnnotatedElementDescriptor.Constructor(classFqName)
else else
AnnotatedElementDescriptor.Method(classFqName, name) AnnotatedElementDescriptor.Method(classFqName, name)
@@ -63,7 +63,7 @@ public class AnnotationListParseTest {
when (element) { when (element) {
is AnnotatedElementDescriptor.Method -> actualAnnotations.append(' ').append(element.methodName) is AnnotatedElementDescriptor.Method -> actualAnnotations.append(' ').append(element.methodName)
is AnnotatedElementDescriptor.Field -> actualAnnotations.append(' ').append(element.fieldName) is AnnotatedElementDescriptor.Field -> actualAnnotations.append(' ').append(element.fieldName)
is AnnotatedElementDescriptor.Constructor -> actualAnnotations.append(" <init>") is AnnotatedElementDescriptor.Constructor -> actualAnnotations.append(" ${AnnotatedElementDescriptor.Constructor.METHOD_NAME}")
is AnnotatedElementDescriptor.Class -> {} is AnnotatedElementDescriptor.Class -> {}
} }
actualAnnotations.append('\n') actualAnnotations.append('\n')