How to get Module from PsiClass?
Does anybody know how to get the corresponding Module of a given PsiClass?
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
请先登录再写评论。
Does anybody know how to get the corresponding Module of a given PsiClass?
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
请先登录再写评论。
Martin Fuhrer wrote:
There's com.intellij.openapi.vfs.VfsUtil.getModuleForFile(Project, VirtualFile).
You should be able to get the VirtualFile instance of your class by calling
PsiClass.getContainingFile().getVirtualFile()
HTH,
Sascha
PS: I found this using a Structural Search for all methods returning a Module ;)
Thanks a lot, works like a charm!
Sascha Weinreuter wrote:
>>Does anybody know how to get the corresponding Module of a given PsiClass?
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
For those who hit this page,
com.intellij.openapi.vfs.VfsUtil.getModuleForFile()
was refactored to the following couple:
Check out https://confluence.jetbrains.com/display/IDEADEV/Diana+Plugin+Migration+Guide
this works too:
ModuleUtil.findModuleForFile(VirtualFile, Project);