Skip to content
Snippets Groups Projects
Verified Commit fe83786a authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Ensure all generated code is properly marked as generated

parent a4a0a211
No related branches found
No related tags found
No related merge requests found
......@@ -13,5 +13,21 @@ package de.justjanne.libquassel.annotations
/**
* Used to mark inline functions as generated for jacoco
*/
@Retention(AnnotationRetention.SOURCE)
@Retention(AnnotationRetention.RUNTIME)
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.TYPE_PARAMETER,
AnnotationTarget.PROPERTY,
AnnotationTarget.FIELD,
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.TYPE,
AnnotationTarget.FILE,
AnnotationTarget.TYPEALIAS,
)
annotation class Generated
......@@ -42,19 +42,25 @@ class RpcModelProcessor : RpcModelVisitor<ProtocolSide, KotlinModel?> {
TYPENAME_QVARIANT_INTOORTHROW.packageName,
TYPENAME_QVARIANT_INTOORTHROW.simpleName
)
.addAnnotation(TYPENAME_GENERATED)
.addType(
TypeSpec.objectBuilder(name.simpleName)
.addSuperinterface(TYPENAME_INVOKER.parameterizedBy(model.name))
.addAnnotation(TYPENAME_GENERATED)
.addProperty(
PropertySpec.builder(
"className",
String::class.asTypeName(),
KModifier.OVERRIDE
).initializer("\"${model.rpcName}\"").build()
)
.initializer("\"${model.rpcName}\"")
.addAnnotation(TYPENAME_GENERATED)
.build()
)
.addFunction(
FunSpec.builder("invoke")
.addModifiers(KModifier.OVERRIDE, KModifier.OPERATOR)
.addAnnotation(TYPENAME_GENERATED)
.addParameter(
ParameterSpec.builder(
"on",
......@@ -144,6 +150,10 @@ class RpcModelProcessor : RpcModelVisitor<ProtocolSide, KotlinModel?> {
"de.justjanne.libquassel.protocol.variant",
"intoOrThrow"
)
private val TYPENAME_GENERATED = ClassName(
"de.justjanne.libquassel.annotations",
"Generated"
)
private val TYPENAME_ANY = ANY.copy(nullable = true)
init {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment