bnorm/kotlin-power-assert

Support library for custom diagram layout

Closed this issue · 1 comments

bnorm commented

Currently the layout for the function call diagram is hardcoded in the plugin. This means that users of this compiler plugin have no way to customize the look of the diagram if they want. Could there be a support library that includes common types which are recognized by the compiler plugin and allow passing of the components of the diagram rather than the diagram itself?

For example, consider the following types:

class CallDiagram(
  val file: String,
  val line: Long,
  val text: String,
  val parameters: List<CallParameter?>
)

class CallParameter(
  val offset: Int,
  val value: Any?
)

If provided and recognized by the compiler plugin, this type could serve as a replacement for a String message parameter and allow the called function to print, log, or whatever it wants with the resulting diagram. This could aid in creating a more rich assertion diagram or narrowing the scope of the diagram to only the needed information.

fun <T> dbg(value: T): T

// A call to the above function would be replaced with a call to the function below

fun <T> dbg(value: T, diagram: CallDiagram): T

Ticket has been moved to Kotlin YouTrack: https://youtrack.jetbrains.com/issue/KT-66808