Bug 578756 - Add an ITextSelection->IVariable adapter
Summary: Add an ITextSelection->IVariable adapter
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.22   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 579511 (view as bug list)
Depends on: 507546
Blocks: 579511
  Show dependency tree
 
Reported: 2022-02-15 04:49 EST by Mickael Istria CLA
Modified: 2022-03-31 03:42 EDT (History)
5 users (show)

See Also:


Attachments
broken debugger? (96.89 KB, image/png)
2022-02-15 08:41 EST, Andrey Loskutov CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2022-02-15 04:49:57 EST
With bug 507546, it's now possible to have some debug values printed inline on editor. This requires an ITextSelection->IVariable adapter. JDT could add one to enable this feature.
Comment 1 Andrey Loskutov CLA 2022-02-15 08:41:51 EST
Created attachment 288052 [details]
broken debugger?

(In reply to Mickael Istria from comment #0)
> With bug 507546, it's now possible to have some debug values printed inline
> on editor. This requires an ITextSelection->IVariable adapter. JDT could add
> one to enable this feature.

Currently it simply fails to properly display content in a simple class, even on Linux.

The problems I saw so far:

1) annotations sometimes (in most cases?) during step debugging are shown on explicit click in editor only (on focus event?)

2) annotations are shown for all the source file, irrelevant if the code is on stack or not or if the variable local or not. So String "x" in one method is shown as completely unrelated integer "x" in another and wise versa.

This is a nice POC but for sure not ready for integration.
Please try this extremely simple example below.

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class App {
	String x = "String!";
	List<?> y = new ArrayList<>();
	Map<?,?> i = new HashMap<>();

	public static void main(String[] args) {
		for (int i = 0; i < 42; i++) {
			extracted(i);
		}
	}

	private static void extracted(int y) {
		Date i = new Date();
		Integer integer = Integer.valueOf(y);
		extracted(i, integer);
	}

	private static void extracted(Date i, Integer y) {
		String x = i.toString();
		extracted(y, x);
	}

	private static void extracted(Integer x, String y) {
		String string = x + y;
		System.out.println(string);
	}
}
Comment 2 Mickael Istria CLA 2022-02-15 09:58:46 EST
(In reply to Andrey Loskutov from comment #1)
> 1) annotations sometimes (in most cases?) during step debugging are shown on
> explicit click in editor only (on focus event?)

I also saw it a few times. I think it's more a generic issue in debug codemining handling.

> 2) annotations are shown for all the source file, irrelevant if the code is
> on stack or not or if the variable local or not. So String "x" in one method
> is shown as completely unrelated integer "x" in another and wise versa.

Yes, the adapter needs to be refined to not participate on lines that are not applicable to the current IJavaStackFrame. Filtering with getMethodName() would work well I believe.
Comment 3 Dr lux CLA 2022-03-31 03:42:31 EDT
*** Bug 579511 has been marked as a duplicate of this bug. ***