Annotations have now retention of "RUNTIME" by default. Java retention is generated as given by kotlin annotation. Annotation rendering changed.

Annotation arguments with default values are rendered as ... if renderDefaultAnnotationArguments is true.
Tests: java retention does not taken into account by Descriptor comparator.
Java retentinon changed to kotlin retention in some tests + one new test with java retention added.
More accurate tests for intentions in byte code (visibility controlled).
This commit is contained in:
Mikhail Glukhikh
2015-07-03 12:11:08 +03:00
parent 4a27b4d614
commit 609d696202
68 changed files with 214 additions and 242 deletions
@@ -176,6 +176,7 @@ public interface DescriptorRendererOptions {
public var flexibleTypesForCode: Boolean
public var secondaryConstructorsAsPrimary: Boolean
public var renderAccessors: Boolean
public var renderDefaultAnnotationArguments: Boolean
}
public enum class RenderingFormat {
@@ -366,13 +366,22 @@ internal class DescriptorRendererImpl(
}
private fun renderAndSortAnnotationArguments(descriptor: AnnotationDescriptor): List<String> {
return descriptor.getAllValueArguments().entrySet()
val allValueArguments = descriptor.getAllValueArguments()
val classDescriptor = if (renderDefaultAnnotationArguments) TypeUtils.getClassDescriptor(descriptor.getType()) else null
val parameterDescriptorsWithDefaultValue = classDescriptor?.getUnsubstitutedPrimaryConstructor()?.getValueParameters()?.filter {
it.declaresDefaultValue()
} ?: emptyList()
val defaultList = parameterDescriptorsWithDefaultValue.filter { !allValueArguments.containsKey(it) }.map {
"${it.getName().asString()} = ..."
}.sort()
val argumentList = allValueArguments.entrySet()
.map { entry ->
val name = entry.key.getName().asString()
val value = renderConstant(entry.value)
val value = if (!parameterDescriptorsWithDefaultValue.contains(entry.key)) renderConstant(entry.value) else "..."
"$name = $value"
}
.sort()
return (defaultList + argumentList).sort()
}
private fun renderConstant(value: CompileTimeConstant<*>): String {
@@ -85,6 +85,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions {
override var receiverAfterName by property(false)
override var renderCompanionObjectName by property(false)
override var renderAccessors by property(false)
override var renderDefaultAnnotationArguments by property(false)
override var excludedAnnotationClasses by property(emptySet<FqName>())