Find PsiClass knowing only the name and the context, but not the package

已回答

I'd like to find a PsiClass knowing only the name, but not the package.

For example, I could be inside a file that imports java.lang.String and declares another class.

Now I'd like to get the PsiClass of String, without knowing from which package it comes from.

I've tried using the command below, but with no luck.

ClassUtils.findClass("String", field.getContext())

 

Any suggestion?

1
正式评论

Please try PsiShortNamesCache#getClassesByName

请先登录再写评论。