Getting VirtualFile for an _inner_ class in a library dependency
|
Basically what the title says. I use an IntelliJ-plugin that currently has a bug when trying to get the contents of inner classes from libraries. I need that bug fixed, so I worked around it. The pull request where I 'kludged' around the problem and tried to detail the problem is here: https://github.com/ebean-orm- To summarize: |
Please sign in to leave a comment.
Please take a look at `CompilerPathsEx.findClassFileInOutput(PsiClass)` method - it solves a similar problem.
It is impossible to get a correct VirtualFile instance for an inner class starting from the `getContainingFile()`.
Thanks!
That did it! Basically just use projectIndex instead of module to get the 3rd party dependencies. I.e.
One question though:
Is there ever any chance that ProjectFileIndex and compileContext.getModuleByFile() will differ in what they return? E.g. if the same class name is present in multiple modules? Ebean uses JavaPsiFacade and GlobalSearchScope today, so I'm guessing no?
While the question above IS still interesting, I solved it in a imho better way by getting the module of the class being enhanced and looking through that's GlobalSearchScope, and then using the projectIndex. (compared to using the compilerContext)
Thanks again for the help and answer the question if you feel like it :)
Implementations of `CompileContext` class all delegate to `ProjectFileIndex` - so results should be the same.