Standalone UAST parser 关注
I'm using the following code to create a standalone UAST parser: https://github.com/bfergerson/standalone-uast
I'm able to get UFile & UClass objects from Java files but only UFile objects from Kotlin files. After solving several NPEs looking for various services during the initialization of JavaCoreApplicationEnvironment & JavaCoreProjectEnvironment, I've gotten stuck on the following error:
Could not find installation home path. Please make sure bin/idea.properties is present in the installation directory.
I would appreciate help getting past this error but I would also appreciate it if someone can take a look through my code to tell me what I'm doing wrong in setting up the environment for Kotlin UAST support.
For example, to get past one of the NPEs I had to use the following reflection hack:
val instance = IdeaDefaultIdeTargetPlatformKindProvider::class.java.let {
it.getDeclaredConstructor().let {
it.isAccessible = true
it.newInstance()
}
}
registerApplicationService(DefaultIdeTargetPlatformKindProvider::class.java, instance)
I doubt this is how DefaultIdeTargetPlatformKindProvider is supposed to be setup so I would really appreciate some help on how I'm supposed to be setting up the environment.
请先登录再写评论。
This is a somewhat complicated task. Please see also my answer in https://intellij-support.jetbrains.com/hc/en-us/community/posts/8912899552658-Get-PSI-reference-in-standalone-parser.
See also org.jetbrains.uast.kotlin.internal.CliKotlinUastResolveProviderService
I was able to get further using CliKotlinUastResolveProviderService as a reference but ultimately got stuck somewhere around FileBasedIndexImpl.waitUntilIndicesAreInitialized().
If I can get the standalone PSI references working I think I'll just abandon this approach.