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

6 comments
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0
Comment actions Permalink

Hello 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?


ModuleUtil.findModuleForFile(), ModuleUtil.findModuleForPsiElement()

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

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

0
Comment actions Permalink

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

0

Please sign in to leave a comment.