Getting a PsiClass/PsiReference from a fully qualified name

Hello,

Is there a way to get a PsiClass/PsiReference from a string which contains the fully qualified name of the class?

The class in question is in the module dependencies inside a jar.

thanks
Siddharth

4 comments
Comment actions Permalink

Finding a PsiClass: com.intellij.psi.JavaPsiFacade#findClass()

What exactly is your usecase?

0
Comment actions Permalink

I have a custom autocomplete provider which add to the autocomplete list, classes which are not part of the project

Once such a class has been selected

1. I add the required jar to the module library (dependencies)
2. I want to insert the class reference (with the appropriate import statements) at the current position (where autocomplete was called).


findClass() works for me. I use JavaCompleitionUtil#insertClassReference() and JavaCompletionUtil#shortenReference() for this.

Is there a better way?

0
Comment actions Permalink

If it works for you, it's fine ;-)

0
Comment actions Permalink

AFAIK this way is good enough.

0

Please sign in to leave a comment.