Tomasz Krakowiak
09/06/2021, 6:09 AMfun styled(block : RuleSet, @CallerPackage packageName)
and introduce synthetic macro-like function:
fun styled(block : RuleSet) = styled(block, callerPackage())
and wherever styled(block)
is used, plugin would replace calls with styled(block, "actual.callers.package.name")
.
Are there any good examples I could use? Maybe somewhere in compose?shikasd
09/06/2021, 9:01 AMstyled
(you can check how Compose finds Composer
class, for example) and then run replace each IrCall
which calls that function (using IrElementTransformer
or similar). Package name can be retrieved from parent class or file (fqName property iirc)
Btw, I recommend using fun styled(block: RuleSet, packageName: String = throw IllegalArgumentException("Must be replaced at compile time"))
If it is called with default parameter, it will be easier to replace just one argument and not whole call (each function has different symbol and you'll have to replace it completely)
I don't have any examples atm (typing this from the mobile), but maybe someone will link similar transforms.raulraja
09/06/2021, 9:47 AM