Bug 532106 - [template] add sysvar code template to print variable name and value to standard out
Summary: [template] add sysvar code template to print variable name and value to stand...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 10
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-07 05:44 EST by Niko Stotz CLA
Modified: 2018-03-08 04:23 EST (History)
3 users (show)

See Also:


Attachments
Adds the sysvar template + externalized description (1.87 KB, application/octet-stream)
2018-03-07 05:44 EST, Niko Stotz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niko Stotz CLA 2018-03-07 05:44:00 EST
Created attachment 273016 [details]
Adds the sysvar template + externalized description

As described at https://advancedweb.hu/2017/11/28/print-debugging/, we should have a template to support print debugging.

I changed the name of the template from "sysoutv" (as proposed by the link) to "sysvar", as it feels more in line with existing "sysout" and "systrace" templates.

The template's description reads
  print variable name and value to standard out

The template's contents are
  System.out.println("${var} = " + ${var});${cursor}
Comment 1 Eclipse Genie CLA 2018-03-07 07:38:05 EST
GitHub Pull Request 7 created by [enikao]
https://github.com/eclipse/eclipse.jdt.ui/pull/7
Comment 2 Stephan Herrmann CLA 2018-03-07 16:30:27 EST
IMHO, even cooler would be a way to teach users the use of print points[1] instead of cluttering your code with sysouts.

[1] http://blog.deepakazad.com/2010/06/print-points-debugging-by-writing-to.html
Comment 3 Niko Stotz CLA 2018-03-07 16:38:31 EST
Print points are mentioned in the next installment[1] of the same series of articles, including extensive lists of pros and cons. I think both of them have their merits.

[1] https://advancedweb.hu/2018/02/06/debug/
Comment 4 Stephan Herrmann CLA 2018-03-07 18:50:09 EST
(In reply to Niko Stotz from comment #3)
> Print points are mentioned in the next installment[1] of the same series of
> articles, including extensive lists of pros and cons. I think both of them
> have their merits.
> 
> [1] https://advancedweb.hu/2018/02/06/debug/

From a quick scan the Pros and Cons refer to debugging in general, not to print points in particular. Am I missing anything?
Comment 5 Noopur Gupta CLA 2018-03-08 03:57:00 EST
Print points are now available as tracepoints in Eclipse: https://www.eclipse.org/eclipse/news/4.7/M5/#JDT.

Adding Sarika in cc for her views on the proposed template.
Comment 6 Niko Stotz CLA 2018-03-08 04:06:48 EST
(In reply to Noopur Gupta from comment #5)
> Print points are now available as tracepoints in Eclipse:
> https://www.eclipse.org/eclipse/news/4.7/M5/#JDT.
> 
> Adding Sarika in cc for her views on the proposed template.

I think of print points slightly differently (at least in this context). They would also print the name and value of a variable.

In a sense:

systrace template <--> tracepoint breakpoint
sysvar template <--> printpoint breakpoint

I'll look into another patch adding printpoints.
Comment 7 Sarika Sinha CLA 2018-03-08 04:11:35 EST
Tracepoints overcomes the biggest con of print-points - that is cluttering of the code.

It will be better to enhance Tracepoints for variable printing - if a variable is selected in editor, it can add the variable print. Just thinking aloud.
Comment 8 Niko Stotz CLA 2018-03-08 04:23:40 EST
I agree printpoints, in general, are to be preferred over println statements.

However, there are quite common scenarios where printpoints don't help that much, e.g.

* Execution environment cannot be debugged (remote server etc.)
* Execution is very sensitive to performance overhead of debug mode