Is this the proper way to do something like this? ...
# k2-adopters
g
Is this the proper way to do something like this? I've sort of took a shot in the dark here. I notice there's no human-readable error:
Copy code
standaloneAnalysisAPISession.modulesWithFiles
    .forEach { (ktSourceModule: KtSourceModule, psiFiles: List<PsiFile>) ->
        psiFiles as List<KtFile>
        val firSession = ktSourceModule.getFirResolveSession(ktSourceModule.project)

        psiFiles.forEach {
            firSession
                .diagnosticProvider
                .collectDiagnostics(it, DiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS)
                .forEach { diagnostic -> println(diagnostic) }
        }
    }
Example output:
Copy code
KtPsiDiagnosticWithParameters3(element=org.jetbrains.kotlin.KtRealPsiSourceElement@cae2a97, a=kotlin/String, b=kotlin/Int, c=false, severity=ERROR, factory=INITIALIZER_TYPE_MISMATCH)
KtPsiDiagnosticWithParameters2(element=org.jetbrains.kotlin.KtRealPsiSourceElement@6c421123, a=println, b=null, severity=ERROR, factory=UNRESOLVED_REFERENCE)
KtPsiDiagnosticWithParameters2(element=org.jetbrains.kotlin.KtRealPsiSourceElement@425b5fe2, a=fooblah, b=null, severity=ERROR, factory=UNRESOLVED_REFERENCE)
KtPsiSimpleDiagnostic(element=org.jetbrains.kotlin.KtRealPsiSourceElement@cae2a97, severity=WARNING, factory=CAN_BE_VAL)
KtPsiSimpleDiagnostic(element=org.jetbrains.kotlin.KtRealPsiSourceElement@cae2a97, severity=WARNING, factory=UNUSED_VARIABLE)