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
Please sign in to leave a comment.
Finding a PsiClass: com.intellij.psi.JavaPsiFacade#findClass()
What exactly is your usecase?
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?
If it works for you, it's fine ;-)
AFAIK this way is good enough.