dephinera
04/12/2020, 10:29 AMclass A {
@Expose
private val mutableList = mutableListOf<String>()
}
class B(val a: A) {
init {
a.mutableList.add("hi") // ERROR!! the type here would be just List<String> instead of MutableList<String>
}
}
I'm doing it as a project at my university, but I'll release it as open source. I want to put an end to the private mutable-pulbic immutable boilerplate.raulraja
04/12/2020, 3:42 PMdephinera
04/13/2020, 6:51 AMfiles: Collection<KtFile>
argument, right? Does that mean that I'll be traversing the whole project? Is there a way I can optimize this by marking the properties I need during analysis and then when its completed to iterate and work only on them?raulraja
06/09/2020, 7:49 PMImran/Malic
06/09/2020, 8:40 PMidea-plugin/src/main/kotlin/arrow/meta/ide/plugins/<plugin name>
for the ide plugin. One can do the same for the Cli Plugin.
If that snapshot is available. I can check in with you and guide you through extracting your plugin to a standalone project with your compiler plugin. It will look like this. Only with the changes from master, which change a few types around, but the rough idea stays the same.dephinera
06/09/2020, 8:49 PMImran/Malic
06/09/2020, 9:00 PMTransform.newSources
to create new kotlin files, like kapt would do - only this is done at compile time with synthetic resolution for the generated descriptors in the Ide.bloder
06/09/2020, 9:09 PMTransform.newSources
is responsible for creating new kotlin files, but you also can combine different ast transformations using TransformMany
as @Imran/Malic suggested.Imran/Malic
06/09/2020, 9:23 PMdephinera
06/09/2020, 9:27 PMbloder
06/09/2020, 11:22 PMTransform.replace
to create AST transformations and arrow-meta quotes provides a support for properties, with this support you can take a look what information property quote provides you and you can build your logic from that, I recommend to take a look on: https://github.com/arrow-kt/arrow-meta/blob/master/compiler-plugin/src/main/kotlin/arrow/meta/quotes/nameddeclaration/stub/typeparameterlistowner/Property.kt#L32
https://github.com/arrow-kt/arrow-meta/blob/a8339723d916418a33c0a95a7599003910e64b74/compiler-plugin/src/test/kotlin/arrow/meta/quotes/scope/plugins/PropertyPlugin.kt
https://github.com/arrow-kt/arrow-meta/blob/a8339723d916418a33c0a95a7599003910e64b74/compiler-plugin/src/test/kotlin/arrow/meta/quotes/scope/templates/PropertyTest.ktdephinera
06/10/2020, 7:54 PMraulraja
06/10/2020, 8:55 PMdephinera
06/11/2020, 6:12 AMraulraja
06/11/2020, 8:08 AMdephinera
06/11/2020, 7:33 PMRetryWithAdditionalRoots
but I can see the compilers is passing through the phases only once. At least through the analysis and quotes phase. Could it be because I'm passing empty lists to RetryWithAdditionalRoots
and because there is nothing new to analyze? Also what is the addToEnvironment
Boolean parameter for?val slice = bindingTrace.bindingContext.getSliceContents(BindingContext.DECLARATION_TO_DESCRIPTOR)
slice.forEach { (psi, descriptor) ->
messageCollector?.report(
CompilerMessageSeverity.WARNING,
"${psi.text} -> Type: ${(descriptor as PropertyDescriptor).returnType}"
)
}
I was going through this thread but I couldn't follow everything...raulraja
06/11/2020, 9:49 PM