How to access source code of classes attached as library using PSI

I have project with jar files attached as libraries. Source code of classes attached to libraries too.
I wrote visitor what parses source code of class. It works fine for classes from my project but ignores source code of classes from library files.
psiMethos.getText() for library classes returns something like
public void foo() { /* compiled code */ }
Idea itself can display source code of library classes.
Can I use PsiElement.acceptChildren() to parse source of library classes like source of project classes?

2 comments
Comment actions Permalink

Hello Andrew,

I have project with jar files attached as libraries. Source code of
classes attached to libraries too.

I wrote visitor what parses source code of class. It works fine for
classes from my project but ignores source code of classes from
library files.

psiMethos.getText() for library classes returns something like

public void foo() { /* compiled code */ }

Idea itself can display source code of library classes.


Call ((PsiCompiledElement) element).getMirror() on such a class or method
to get the corresponding element in library sources.

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


0
Comment actions Permalink

Hello Dmitry,

It looks like PsiElement.getNavigationElement() should be called instead of getMirror().
Thank you, anyway - your answer was helpfull.

0

Please sign in to leave a comment.