Locate the folder including a file


I am writing a plugin to support a new JavaScript framework. To do so I would like to figure out if the project is using the framekwork.


               mySubViewFolder // <= right-click here
          framework-project.json // <= check
      @framework-folder // <= check



Let's say someone right-clicks on the mySubViewFolder. I would have to check if there is a @framework-folder and a framework-project.json as well as if I am inside the view folder.


Currently I am iterrating up the path to see if inside any folder there are any of these files.
But I had hoped that by indexing there is a faster way.


If not, is there any way to keep the results of the paths?

Any ideas?


Hi Kurt,
Please check com.intellij.psi.search.FilenameIndex for the items that can be located in unknown places.
For determining if the clicked file is in the “view” directory, I suggest checking its parents.


Hi Karol,
I would very much enjoy an example, because I am a total newbie to Plugin Development and to Java.

It's getting better, but for now a part of a single line of code, is not really helpful right now.

Thanks a lot for taking the time.


Hi Kurt,

In this case, I suggest investing some time in learning Java (or Kotlin) as it is a requirement for developing plugins.

I think it should be easy to find the method you need in the FilenameIndex class (getVirtualFilesByName() seems like the one you need):

I also recommend getting familiar with the Explore the API topic, which teaches how to find example implementations.​