jianbing
01/11/2022, 2:52 PM@MetaData
data class A (val x: String, val y: String)
after applying compiler plugin, the .class file will be altered to something like below (from source perspective), basically, I will add implicitly MetaData into the primary constructor for all source Kotlin so long as it is with annonation @MetaData in place, plus a new method fun getMetaData()
get generated.
data class A(val x: String, val y:String, val myMeta: MetaData) {
fun getMetaData() {
//some logic check
return myMeta
}
}
now when it comes to use the new synthetic ".class" file manipulated as below, IntelliJ complains it cannot find resolve A (it has only the constructor with 2 parameters not 3) and cannot resolve the the synthetic method getMetaData() either.
val x = A("ba", "fo", MetaData(..))
val y = x.getMetaData()
can somebody shed some light on it?
I know lombok seems no problem with it after adding its @Getter annotation for example into Java source code, IntelliJ can recognize its getXXX method (which is generated by lombok). I don't know how to implement the same for my case for kotlin language. please include the detailed steps if possible.raulraja
01/11/2022, 6:08 PMjianbing
01/12/2022, 9:25 AMraulraja
01/12/2022, 9:34 AMChachako
01/13/2022, 12:52 PMSyntheticResolveExtension
? I found that SyntheticResolveExtension
can achieve the similar behavior. Why are there two different extensions?raulraja
01/13/2022, 12:56 PMSyntheticResolveExtension
is for members and the other is needed for scope
resolution but I’m not positive. I could never get either to work without a custom IDEA plugin.jianbing
01/14/2022, 4:59 AMSyntheticResolveExtension
can achieve the similar behavior...."
basically my case is : I added new inner "data class XXX" and other new methods "fun getYYY()" into original ".class" file say A.kt, which is now very sythentic so that IntelliJ IDE cannot do code completion, nor resovle those synthetic symbols when I wrote code say A.XXX(...), a.getYYYY()....jianbing
01/14/2022, 5:02 AMChachako
01/14/2022, 5:19 AMcopy
, componentN
). This should be similar to your needs, so you just need to implement the SyntheticResolveExtension
in the compiler plugin (https://github.com/RinOrz/sweekt/blob/2b680e1042557b7d3dcea752db7db8d095f2c025/plugin/compiler-hosted/src/main/kotlin/com/meowool/sweekt/info/InfoClassSynthetic.kt#L56-L98), and then declare the Kotlin extension point in the IDEA plugin and this is done (https://github.com/RinOrz/sweekt/blob/2b680e1042557b7d3dcea752db7db8d095f2c025/plugin/ide/src/main/resources/META-INF/plugin.xml#L19-L20), but I have to tell you that IDEA does not currently allow us to create the Kotlin extension (https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1637391960430400), so it will not be able to upload to the plugin marketplace. Good luck 🙌jianbing
01/19/2022, 1:19 AM