Anastasia Birillo [JB]
09/09/2020, 2:14 PMMessageCollector
writes the messages (the filed of CompilerContext
). Maybe I did not understand clearly, but the arrow meta
uses NONE
MessageCollector, which does nothing. Can I override it? I would like to receive my logs.
I tried to run the @raulraja example with bindingContext
:
val Meta.example: CliPlugin
get() =
"Hello World" {
meta(
analysis(
doAnalysis = { project, module, projectContext, files, bindingTrace, componentProvider ->
null
},
analysisCompleted = { project, module, bindingTrace, files ->
val slice: ImmutableMap<PsiElement, DeclarationDescriptor> =
bindingTrace.bindingContext.getSliceContents(BindingContext.DECLARATION_TO_DESCRIPTOR)
slice.forEach { (psi, descriptor) ->
if (psi is KtProperty && descriptor is PropertyDescriptor) {
messageCollector?.report(
CompilerMessageSeverity.WARNING,
"${psi.text} -> Type: ${descriptor.returnType}"
)
}
}
null
}
)
)
}
raulraja
09/09/2020, 5:01 PMraulraja
09/09/2020, 5:02 PMraulraja
09/09/2020, 5:06 PMAnastasia Birillo [JB]
09/09/2020, 5:09 PMraulraja
09/09/2020, 5:13 PMmessageCollector
mutable in the CompilerContext so you can replace it or change any internals that don’t make sense. Meta is not distributed as stable until IR is stable so these are things that are fine to break bincompat for now.raulraja
09/09/2020, 5:14 PMAnastasia Birillo [JB]
09/09/2020, 6:06 PMoverride fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
val file = File(filePath)
file.createNewFile()
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY,
PrintingMessageCollector(PrintStream(file.outputStream()), MessageRenderer.PLAIN_FULL_PATHS, true))
super.registerProjectComponents(project, configuration)
}
I use PrintingMessageCollector
, it is the public class and I can configure it easily. Maybe it would be helpful for someone. But I don't know if it is a good way or not. @raulraja What do you think?raulraja
09/09/2020, 6:16 PMraulraja
09/09/2020, 6:19 PMcli
block here https://github.com/arrow-kt/arrow-meta/blob/6a758274131075bd44f56cc131385d67fa279a10/compiler-plugin/src/main/kotlin/arrow/meta/internal/registry/InternalRegistry.kt#L149 for your code then you would not need to register it manually.raulraja
09/09/2020, 6:19 PMAnastasia Birillo [JB]
09/09/2020, 6:21 PMNONE
, but use NONE
by default 🙂Anastasia Birillo [JB]
09/09/2020, 6:24 PMraulraja
09/09/2020, 6:38 PM