How to resolve unqualified name to possible PsiClasses?

This is something that probably 100 people have done before, but I can't find it
on the forums or the wiki or anywhere else, and there's no documentation for
most of the API I think I need to use.

If I have a PsiElement (of my custom language, but this shouldn't matter), what
is a good way to resolve it to a PsiClass?

0
5 comments
Avatar
Permanently deleted user

I had to problem from getting fra a PsiField to a PsiClass.

One solution I did was to get the fully qualified classname of the field.

And then using project.findClass(classname, scope);

0
Avatar
Permanently deleted user

Unfortunately I don't have FQN. By the way from PsiField to PsiClass couldn't
you do ((PsiClassType) field.getType()).resolve() or so?

Claus Ibsen wrote:

I had to problem from getting fra a PsiField to a PsiClass.

One solution I did was to get the fully qualified classname of the field.

And then using project.findClass(classname, scope);

0
Avatar
Permanently deleted user

Hi Kieth

Yeah I guess I could do this. As my home computer is not hooked to the internet yet I'm not working so much on my plugin.

0
Avatar
Permanently deleted user

Hello Keith,

KL> This is something that probably 100 people have done before, but I
KL> can't find it on the forums or the wiki or anywhere else, and
KL> there's no documentation for most of the API I think I need to use.
KL>
KL> If I have a PsiElement (of my custom language, but this shouldn't
KL> matter), what is a good way to resolve it to a PsiClass?

PsiManager.getInstance(project).getShortNamesCache().getClassesByName(name,
searchScope)

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Avatar
Permanently deleted user
PsiShortNamesCache.getInstance(project).getClassesByName() should be used
0

Please sign in to leave a comment.