I have a problem with processing Kotlin source code via kotlin-compiler-embeddable. I need to obtain PSI class representations for all classes in an external project, build them, and get BindingContext, but I can't find any examples.
I would like to use the kotlin-compiler-embeddable library to analyse dependencies in a Kotlin project outside the IntelliJ environment.
I manage to obtain PSI representations for individual classes. Unfortunately this is not enough. I would like to track dependencies between classes.
private val project by lazy {
KotlinCoreEnvironment.createForProduction(
Disposer.newDisposable(),
CompilerConfiguration(),
EnvironmentConfigFiles.JVM_CONFIG_FILES
).project
}
fun createKtFile(codeString: String, fileName: String) =
PsiManager.getInstance(project)
.findFile(
LightVirtualFile(fileName, KotlinFileType.INSTANCE, codeString)
) as KtFile
For example, I need to get a PSI Class representation or fully-qualified class name for the service
parameter type.
class ShapeEndpoint(service: ShapeService)
Is there somewhere a comprehensive example that would show how to compile a group of source files, build a BindingContext, access it and then use it effectively?