Get src relative file name
Hi.
How can i get the src relative file name from IStubFileElementType.parseContents(). I'm developing a language plugin and the ASTNode passed into this method is our psi file. Essentially, I need to derive a type name from the file. Thanks in advance for help.
Scott
请先登录再写评论。
To be more specific I'd like to the the module in the project associated with the psiFile obtained from the chameleon ASTNode passed into the IStubFileElementType.parseContents() method. So basically is there a way to get a module for a given psiFile or virtual file?
Thanks.
Scott
You are posting in the wrong forum btw.
I'll take a stab at answering your question:
You call the method getVirtualFile(), or even getParent()
You can then obtain whatever info you want about the file using the VirtualFile API;'s
Thanks (and excuse the wrong forum, sorry)...
But in the context of IFileElementType.parseContents( ASTNode ) the node passed in is often hollowed out and only provides minimal implemenation e.g., when IJ is reparsing a range etc. In this situation calling getVirtualFile() etc. returns null.
Hello Scott,
ModuleUtil.findModuleForFile(), ModuleUtil.findModuleForPsiElement()
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
I guess I can't be of much help. Are you actually implmenting parseContents, or are you using the implementation IDEA provides?
You might want to give a few more details about your language. Is it embedded in a file with another language?
there is also getPsi().getContainingFile()
edit... ah Dmitry already answered you
Thanks, Dmitry!
I also need the path of the file, but the VirtualFile associated with the chameleon ast node is null or a Light version that only has the name of the file with no path. Is there a way to get the path? I only need the path relative from the src directory. Thanks.
Scoltt