Bagadeshkumar R
09/30/2024, 4:10 AMstd-lib
in the new analysis API?
Currently, I'm using analyze(psiFile)
to analyze the file but println
is unresolved pointing that dependencies are not properly added.
I'm building the StandaloneAnalysisAPISession like following
val session = buildStandaloneAnalysisAPISession {
buildKtModuleProvider {
this.platform = JvmPlatforms.defaultJvmPlatform
val stdLib = addModule(
buildKtLibraryModule {
addBinaryRoot(kotlinStdFile.toPath())
libraryName = "stdLib-kotlin"
this.platform = JvmPlatforms.defaultJvmPlatform
}
)
val sdkModule = buildKtSdkModule {
this.platform = JvmPlatforms.defaultJvmPlatform
addBinaryRootsFromJdkHome(jdkPath.toPath(), false)
libraryName = "JDK moduleName"
}
// Adding the modules in multiple dependencies for testing
val module = buildKtSourceModule {
this.moduleName = "example"
this.platform = JvmPlatforms.defaultJvmPlatform
addSourceRoot(ktDirFile.toPath())
addDependsOnDependency(stdLib)
addDependsOnDependency(sdkModule)
addRegularDependency(stdLib)
addRegularDependency(sdkModule)
}
addModule(module)
addModule(sdkModule)
addModule(stdLib)
}
}