Find class in an excluded directory

Hi, I'm working on developing a plugin to support a custom langauge. The plugin refers to other classes in a different language. Currently I'm using the following code to find the classes given their fully qualified name:

JavaPsiFacade.getInstance(element.getProject()).findClass(fqn, element.getPsi().getResolveScope)

It works fine for most cases, but it seems to be unable to find classes in excluded directories. I tried making the scope GlobalScopeSearch.allScope(...) but still got nothing.

My end goal is to find a specific class located outside of the project and find what classes extend it. The directory is not in the project but it is added to the project's classpath, and the directory is also marked as excluded. How could I find a class in this situation?

4 comments
Comment actions Permalink

The very idea of excluded directories is that IntelliJ IDEA does not index their content, does not build the PSI and does not do anything else with them. If you need to find classes in a directory, please consider not marking it as excluded.

0
Comment actions Permalink

Unfortunately marking the directory as excluded is not up to me, but I still need to be able to find it. Intellij Ctrl + shift + f finds excluded files, and when I click on package names in excluded directories I still get redirected to the package successfully, so shouldn't there be a way to search them?

0
Comment actions Permalink

As I said, we do not build the PSI or indexes for files in excluded directories. Neither of the operations you mentioned requires building the PSI or indexes.

You can, of course, use the VirtualFileSystem API to load the contents of files in excluded directories and search them yourself. However, none of the PSI operations will work.

0
Comment actions Permalink

Alright, thanks.

0

Please sign in to leave a comment.