Access class from project in plugin code

I need to access a project level Class from plugin code at runtime

I see that plugin classloader is different from project's classloader. I am getting ClassNotFoundException when I try to find class using both plugin's classloader & also classloader of PsiElement

Is there a way to get access project level Class from plugin code?

0
6 comments
Official comment

The IDE analyzes source code, not class files resulting from the compilation, and so doesn't normally use classloaders for project classes. Which problem are you trying to solve?

Avatar
Permanently deleted user

I'm trying to show suggestions if the class I encountered in the classpath via OrderEnumerator. If the class I enum, I want to show the suggestion as a list of choices in UI

0

Sorry, I don't understand you. If you need to enumerate all classes, you can use AllClassesSearch (but it can be very slow).

0
Avatar
Permanently deleted user

Sorry for the delay in responding.

I need to show values of an enum as suggestions within IDE editor. This enum comes from the classpath of the project, which can only be determined at runtime.

0

What if the enum is not compiled?

Have you considered finding corresponding PsiClass (JavaPsiFacade#findClass) and using its getFields for suggestions?

0
Avatar
Permanently deleted user

Hi,

I'll give it a try. Thanks

0

Please sign in to leave a comment.