com.ybo.trackingplugin.tasks.utils.impl._CodeGeneratorKotlin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of traceplugin Show documentation
Show all versions of traceplugin Show documentation
gradle plugin allowing to add automatic logs (or other process) at the start of each traced method
package com.ybo.trackingplugin.tasks.utils.impl
import com.ybo.trackingplugin.tasks.data.TraceAnnotationMark
import com.ybo.trackingplugin.tasks.utils.CodeGenerator
import com.ybo.trackingplugin.toB64
class _CodeGeneratorKotlin : CodeGenerator() {
override fun generate(
params: String,
tracerFactoryString: String,
insideMethodIndentation: String,
methodName: String,
tag: String,
alterationOffset: Int,
mark: TraceAnnotationMark,
): String {
return "/*$tag*/ $tracePerformerPackage.trace(" +
tracerFactoryString + "(), " +
"\"" + methodName.toB64() + "\", " +
"false, " +
"\"" + mark.longVersion.toB64() + "\"," +
params.paramsOrNot() + "," +
alterationOffset + ")\n" +
insideMethodIndentation
}
private fun String.paramsOrNot(): String {
return if (isEmpty()) {
"emptyArray()"
} else {
"arrayOf($this) "
}
}
}