You can get it via FileTypeIndex.getFiles method. But note that there may be hundreds of thousands files in a project, so this call may cause performance and memory issues. Why do you need this?
I'm working on a project (a simple editor based on Swing, here https://github.com/ice1000/dev-kt, since IDEA is too heavy for old bad machines and take long time to boot, my emacs/vim friends are not glad to use it. I create this lightweight editor for them, and by the way to get more familiar with Kotlin compiler's API) using Kotlin's compiler, and I want to implement more functionalities.
`FileTypeIndex` is not present in Kotlin compiler. Is there any other alternatives?
My final goal is to get all the declarations and references in a mixed Java-Kotlin project, but when I create a project according to the test case I saw in the kotlin repo, I can only get java's psi classes/files.
I tried resolving some Java code that calling Kotlin, I get `null` (but I can resolve Java codes calling Java).
Only limited part of IntelliJ API is available inside Kotlin compiler, and the indices are not available indeed. It's better to ask your question at the Kotlin forum then.
Seems that Kotlin forum isn't friendly with kotlin compiler-related questions. I've asked a question about kotlin compiler's script API but get no replies and low views.
You said indices are not available, but I can get Java's PsiClass using APIs like `org.jetbrains.kotlin.com.intellij.psi.JavaPsiFacade#findClass`. But I cannot get Kotlin's `org.jetbrains.kotlin.psi.KtClass` by the same API, this is why I'm asking question here...
There is no API in the Kotlin compiler to enumerate all Kotlin classes. To get all Kotlin classes in a specific file, you can use `PsiManager.findFile(VirtualFile)`, cast the result to `KtFile`, and call `KtFile.getClasses()`. Enumerating source files is something that you can implement by yourself; you don't need to use any platform APIs for that.
This looks like it could be related to how IntelliJ handles pull request review mode and comment mapping internally. From what I understand, comments are linked to specific diffs or code ranges, so if they appear on unrelated code, it might be due to incorrect diff alignment or caching issues.
You could try refreshing the pull request view or reloading the diff to see if the comments re-align correctly. Also, switching branches or re-checking the selected commit might help, since IntelliJ allows reviewing comments based on specific commits and file versions.
In one of my projects dealing with structured datasets (similar to something like a sonic frozen menu model with multiple mapped items), I noticed that when references weren’t properly scoped, data appeared in unintended places—so this might be a similar mapping issue.
It might help to check whether the comments are tied to the correct commit or diff context.
You can get it via FileTypeIndex.getFiles method. But note that there may be hundreds of thousands files in a project, so this call may cause performance and memory issues. Why do you need this?
Thanks first for telling me the API.
I'm working on a project (a simple editor based on Swing, here https://github.com/ice1000/dev-kt, since IDEA is too heavy for old bad machines and take long time to boot, my emacs/vim friends are not glad to use it. I create this lightweight editor for them, and by the way to get more familiar with Kotlin compiler's API) using Kotlin's compiler, and I want to implement more functionalities.
What kind of functionality you're going to implement by enumerating all Kotlin files in the project? Maybe there is a better way to do this.
`FileTypeIndex` is not present in Kotlin compiler. Is there any other alternatives?
My final goal is to get all the declarations and references in a mixed Java-Kotlin project, but when I create a project according to the test case I saw in the kotlin repo, I can only get java's psi classes/files.
I tried resolving some Java code that calling Kotlin, I get `null` (but I can resolve Java codes calling Java).
I know. Tens of minutes of time cost is acceptable, so no worry about time cost.
Only limited part of IntelliJ API is available inside Kotlin compiler, and the indices are not available indeed. It's better to ask your question at the Kotlin forum then.
Seems that Kotlin forum isn't friendly with kotlin compiler-related questions. I've asked a question about kotlin compiler's script API but get no replies and low views.
You said indices are not available, but I can get Java's PsiClass using APIs like `org.jetbrains.kotlin.com.intellij.psi.JavaPsiFacade#findClass`. But I cannot get Kotlin's `org.jetbrains.kotlin.psi.KtClass` by the same API, this is why I'm asking question here...
BTW, thanks for your help again.
There is no API in the Kotlin compiler to enumerate all Kotlin classes. To get all Kotlin classes in a specific file, you can use `PsiManager.findFile(VirtualFile)`, cast the result to `KtFile`, and call `KtFile.getClasses()`. Enumerating source files is something that you can implement by yourself; you don't need to use any platform APIs for that.
Thanks yole. I'll try later.
It works! @yole but I'm getting new problems now. I'll create a new post.
OK. I've found a post that says exactly the same I want to say:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000795610-What-s-the-methed-call-to-Resolve-a-Kotlin-reference?page=1
Could you please take a look at it? @yole
Hi all,
could someone sare more info about get/list files in Kotlin / Android Studio?
the function only returns directories..
Thanks
This looks like it could be related to how IntelliJ handles pull request review mode and comment mapping internally. From what I understand, comments are linked to specific diffs or code ranges, so if they appear on unrelated code, it might be due to incorrect diff alignment or caching issues.
You could try refreshing the pull request view or reloading the diff to see if the comments re-align correctly. Also, switching branches or re-checking the selected commit might help, since IntelliJ allows reviewing comments based on specific commits and file versions.
In one of my projects dealing with structured datasets (similar to something like a sonic frozen menu model with multiple mapped items), I noticed that when references weren’t properly scoped, data appeared in unintended places—so this might be a similar mapping issue.
It might help to check whether the comments are tied to the correct commit or diff context.