Get all PSI/Virtual Files within a project
已回答
I am writing a small Intellij plugin, and in that I need to get all source code files that are within a specific project as PSI/Virtual file (in my understanding both are interexchangeable so it won't matter which of the two I get).
Is there any way to do this?
请先登录再写评论。
FileTypeIndex should suit your needs https://plugins.jetbrains.com/docs/intellij/file-based-indexes.html#standard-indexes
Hi,
thanks for your answer and as it seems this should work. But I don't know how to get the LanguageFileType. Can you tell me how I can get instances of the LanguageFileType for at least java ?
For Java, it's com.intellij.ide.highlighter.JavaFileType#INSTANCE
You can lookup any others via "Goto Class" and typing "*FileType" to list all classes matching this pattern.
See also https://plugins.jetbrains.com/docs/intellij/explore-api.html
What should we import in order to access `JavaFileType` from a test? I have a test file like:
```
And IntelliJ auto import isn't finding `JavaFileType`, I guess it's not in the classpath. What should I add to my build.gradle?
My project is the template project here, just with this change to the test file https://github.com/JetBrains/intellij-platform-plugin-template
Logan May You'll need to add an dependency on Java plugin: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
Yann Cebron That worked! And, the same approach worked for Kotlin using `org.jetbrains.kotlin`. Thank you very much