Federico Tomassetti
05/26/2023, 12:49 PMdata class A(p1: Int) : Node()
into
class A(p1: Int) : ObservableNode() {
init {
println("initializing p1 at $p1") // instead of print we will notify observers
}
var p1 : Int = p1
get() {
print("reading p1") // instead of print we will notify observers
return field
}
set(value: Int) {
println("setting p1 to $value (currently at $field)") // instead of print we will notify observers
field = value
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is A) return false
return p1 == other.p1
}
override fun hashCode(): Int {
return p1
}
}
I can find the ClassDeclaration and check if it extends Node, but it is unclear to me how to modify it. I tried removing the irClass in the declarations of IrFile and replace it with a copy but that cause errorsJavier
05/26/2023, 2:00 PMFederico Tomassetti
05/26/2023, 2:02 PMJavier
05/26/2023, 2:04 PMval number: Int = a.p1
, that p1
wouldn't exist for the IDE as it will exist later.Federico Tomassetti
05/26/2023, 2:07 PMval
in the original data class which would be:
data class A(val p1: Int) : Node()
So I think the val p1
would be present also in the original code (even if with a different definition)Tóth István Zoltán
05/27/2023, 3:10 AMIrElementTransformerVoidWithContext
for that and the visitAnonymousInitializerNew
and visitPropertyNew
functions in particular.
I added an example below that is a transformer. It shows how a transformation is done and actually contains calls to printf in a form of trace functions. It is in-development and is a somewhat broken at the moment but you can see examples there.
https://github.com/spxbhuhb/rui/blob/7468ca0db6d345298247e80367883f53f0158e8a/rui-[…]/simplexion/rui/kotlin/plugin/ir/air2ir/StateAccessTransform.ktftomassetti
05/27/2023, 10:18 AMOliver.O
05/27/2023, 11:24 AMftomassetti
05/27/2023, 11:27 AMJavier
05/27/2023, 11:28 AMftomassetti
05/27/2023, 11:29 AMOliver.O
05/27/2023, 11:30 AMftomassetti
05/27/2023, 11:30 AM