从用户工作区加载类 [英] Load a class from the users workspace
问题描述
我试图访问在编辑器中由eclipse AST打开的类。这样我就可以得到该文件的枚举常量名称,而不是运行时分配的值。
那么如何获取枚举值呢?可以从用户的工作区加载类,并使用反射来访问该类的值吗?
我已经解决了这个脏的方式:我正在从bin目录中查找 .class
文件,加载它并以这种方式获取值。
I´m writing an eclipse plugin which should show some information of an enum class. The new view should show all enum constants and the assigned values. The enum values are calculated in the constructor somehow and it is not obvious in the editor which value they will have at runtime. So that´s the motivation for the plugin. I have tried to access the class which is opened in the editor by the eclipse AST. That way I´m getting the enum constant names of that file but not the assigned values at runtime.
So how can I get the enum values? Is it possible to load a class from the user´s workspace and use reflection to access the values of that class?
I have solved this on the dirty way: I am looking up the .class
file from the bin directory, loading it and grabbing the values on this way.
这篇关于从用户工作区加载类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!