开发者

Get the value of a selected java field in a eclipse view

I making a eclipse view that is working with selected elements from other views. Let say I have opened a java file in the editor that has the following fields in it开发者_Go百科: private String world = " world!" private String hello = "hello" + world;

When I select "hello" in the Outline view I'm able to get IFiled selection and I have access to it's properties, but what i need is the true value of the field ("hello world!"). Any idea how can I do that? Thanks.


There is no value information available for variables before runtime (maybe except constant values), so such expressions cannot be evaluated (except using some serious inference about the variables). And I don't think these expressions could be evaluated even in theory, because the referenced variables might gain their values even from external input (that cannot be available during compiletime).

On the other hand, it is possible to evaluate such conditions using the JDT Debugger, there is a Display view for such reasons, and or the Inspect options. This way it is possible to get the selected values, as they can be read from the JVM. On the other hand, this information is not available in the Java AST but you have to use the debugger model.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜