Auto replace default arguments
Closed this issue · 3 comments
caffeine-mgn commented
Can you replace default argument on call some function? Like this:
build.gradle.kts
plugins {
// other plugins
id("com.jakewharton.cite")
}
// configuring auto replacer of default argument
autoApply {
// select class and method
to("com.foo.bar.Logger.info") {
// mapping what pass to arguments
mapLineToArgument(argumentName = "line")
mapFileToArgument(argumentName = "file")
}
}
// other code
com/foo/bar/Logger.kt
package com.foo.bar
object Logger {
fun info(msg:String, file:String = "", line:Int = 0) {
println("$file:$line: $msg")
}
}
and then try to use logger:
fun main(){
Logger.info("Hello world") // default values of "file" and "line" will be replaced by your plugin according ruls in build.gradle.kts file
}
JakeWharton commented
This is #20 and almost certainly will never be supported by this plugin because of the problems described in that issue.
caffeine-mgn commented
@JakeWharton you are not right. My version is easier to implement. And it work even you not apply plugin
JakeWharton commented
Well you are free to implement it in a fork or separate plugin then. I will not be pursuing it.