Ahmed Mourad
05/09/2020, 7:42 PMnamedFunction
block, however, kotlinType
requires a BindingContext
, where can I get its instance from?
namedFunction({ ... }) { c ->
c!!containingClass().getProperties()[0].kotlinType()
}
bloder
05/09/2020, 8:11 PMclassDeclaration
quote, matching your function case or other approach to get its contexts, since we don't provide in our scopes outer contexts like in this case, but giving you a real answer to what u asked you can get this instance using analysis
extension phase instead of quotes: https://meta.arrow-kt.io/apidocs/compiler-plugin/arrow.meta.dsl.analysis/-analysis-syntax/analysis.htmlAhmed Mourad
05/09/2020, 8:18 PMwhen
block.Ahmed Mourad
05/09/2020, 8:18 PMclassDeclaration
?bloder
05/09/2020, 8:25 PMClassBody
scope provides a typed access to all its functions and propertiesbloder
05/09/2020, 8:27 PMbloder
05/09/2020, 8:30 PMAhmed Mourad
05/09/2020, 8:41 PMval Meta.demo: CliPlugin
get() = "demo" {
meta(classBody({...}) { c ->
val funToTransform = this.functions.value.first { it.name == "funName" }
val properties = c.containingClass()!!.getProperties()
Transform.replace(
replacing = funToTransform,
newDeclaration = """...""".function
})
}
I changed it to classBody
but still not sure where to get the type from.Ahmed Mourad
05/09/2020, 8:42 PMbut maybe it's good to start to study if we can get from the compiler its outer contexts and provide in scopes or if is irrelevant.I think that would be very helpful.
bloder
05/09/2020, 8:47 PMthis.body.properties.value
is the list of its propertiesraulraja
05/09/2020, 8:51 PM