Bug 221886 - [hover] Enhance hover to get field and array values
Summary: [hover] Enhance hover to get field and array values
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
Depends on:
Blocks:
 
Reported: 2008-03-07 12:34 EST by Peter Salzman CLA
Modified: 2021-06-21 10:27 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Salzman CLA 2008-03-07 12:34:50 EST
Debugging under Eclipse is extremely painful.

I work with numerical code.  Lots of calculations that pull coefficients from a database that need to be debugged.  Speed of debugging is essential since there's usually so many things that need to be checked.

I'm used to Visual Studio, where the value of a variable pops up when the mouse cursor hovers over a variable.  This way I don't need to formally place tons of variables in a "watch list".  Eclipse does this too, but with unreasonable restrictions.

For example, consider this code:

MyClass.FooFactors foo = MyClass.getFooFactors( CASE_DEGENERATE );
MyClass.BarFactors bar = MyClass.getBarFactors( CASE_DEGENERATE );
FooBarClass.FBF    fbf = FooBarClass.getFBF( PERTURBATIVE );

for ( ... )
x[i] = foo.intercept + ln(bar.intercept) + fbf.ycept + exp(foo.x1)/(exp(foo.x2) + 1) + bar.propother + probit_transformation(fbf.rating) - ...

Since foo is a class, I wouldn't expect to see anything if I let the mouse hover over it.  Eclipse will pop up the name of the class that foo is an instance of (or if I'm making a reference to the class itself, it'll give the package name).  That's good.

What is unforgivable, however, is what happens when I let the mouse hover over ".intercept" in "foo.intercept".  I would expect the value of foo.intercept to pop up when the mouse hovers over the ".intercept" part of "foo.intercept".  It's a double.  Eclipse knows its current value with 100% certainty.  The value is sitting right there on the stack frame (or however Java programs are organized in memory).  I can even get the value by highlighting "foo.intercept" and using ctl-shft-d (to display) or ctl-shft-i (to inspect).  Or I could add foo to the watch list and see the value that way.

But I have hundreds of these things, and sometimes, I need to check each one.  Highlighting is surgeon's task here: including the semi-colon is an error.  Not highlighting the fully qualified variable (ie highlighting "intercept" rather than "foo.intercept") is an error.   And then I must use either two mouse clicks or take my hand off the mouse and put it on the keyboard.


It doesn't even have to be something as "exotic" as a class.  Even a simple array has the same problem:

public class Foo
{
   public static void main( String[] args )
   {
      int i;
      int j[] = new int[5];

      for ( i = 0; i < 5; ++i ) {
         j[i] = i;
         System.out.println("hello world");
      }
   }
}


Set a breakpoint at the println statement and debug the program in Eclipse.  Let the mouse hover over the "i", and Eclipse will pop up "0".  Now let the mouse hover over j[i].  You'd think Eclipse would pop up "0" since i=0 and j[0]=0, but it doesn't.  It pops up "j=int[5]", which is not all that helpful.

If Eclipse *can* know the value of a variable, it really *ought* to report the value of that variable in a manner convenient for the programmer.  Inspecting is fine when you have a complicated class object you want to look at.  Watch lists are fine when you want to see how a variable changes in time.  However, if I have a double valued member of a class, Eclipse really should simply display the value.

Also, highlighting variables to display, watch, or inspect them is very painful as well.   If I have a variable that I'd like to watch, say:

     double someDoubleVariable = 0.0
     someDoubleVariable = someClassInstance.someArray[j];

and I'd like to inpsect someArray, what I need to do is highlight "someClassInstance.someArray[j]".  The semi-colon is not allowed.  Missing the "s" in "someClassInstance" is not allowed.

Really, Eclipse should be smart enough for me to rightclick **anyway** in the string "someArray" and put the array in a watchlist.  There's really no need to highlight the whole thing.  I'm sure Eclipse could do that.

Thanks.
Comment 1 Curtis Windatt CLA 2008-03-07 12:59:40 EST
In 3.4 semi-colons can be included when inspecting.  We already have a bug for making our inspect selection smarter, bug 148641. 

While we don't want to run an evaluation to create a hover over methods, accessing a field is reasonable enhancement.

Patches are always appreciated. Marking as bugday.
Comment 2 Dani Megert CLA 2015-11-25 09:30:45 EST
Simple test case:

public class DebugHoverBug {
	public static void main(String[] args) {
		Data d= new Data();
		System.out.println(d.i);
		System.out.println(d.s);
	}
}
class Data {
	int i= 1;
	String s= "bug";
}
Comment 3 Juergen Baier CLA 2018-02-26 08:44:21 EST
I just want to confirm that this issue still exists in Eclipse 4.7.2.
Comment 4 John Kozlov CLA 2021-06-20 04:48:10 EDT
Duplicate of Bug 572629?
Comment 5 Sarika Sinha CLA 2021-06-21 10:27:04 EDT
Intial request of hover and action anywhere in variable already exists.

And now hover works well with chaining as well.

Original is different so not marking as duplicate.