Finding the file corresponding to a Java class name

I have a class name such as "com.example.Foo" and want to find the file that defines it within an IDEA project. Basically I want to find the file that you would go to by control-clicking on an import statement, wherever that is. (It might be Java source, or it might come from a library, and if it's in a library, it may or may not have source code attached. If there is source code attached, I want the source.) How do I do that?

- Brian

1 comment
Comment actions Permalink

Hello Brian,

I have a class name such as "com.example.Foo" and want to find the
file that defines it within an IDEA project. Basically I want to find
the file that you would go to by control-clicking on an import
statement, wherever that is. (It might be Java source, or it might
come from a library, and if it's in a library, it may or may not have
source code attached. If there is source code attached, I want the
source.) How do I do that?


PsiManager.getInstance(project).getClass().getContainingFile()

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


0

Please sign in to leave a comment.