Skip to content

Inlining values inside debugger #8019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Dec 5, 2024

This is a prototype of a feature to show variable values directly in the editor, as permitted by the LSP protocol.

It looks like this inside VS Code:
inline-values-vscode

and inside NetBeans:
inline-values-nb

@lahodaj lahodaj added LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests already fixed labels Dec 5, 2024
@lahodaj lahodaj added this to the NB25 milestone Dec 5, 2024
@apache apache locked and limited conversation to collaborators Dec 5, 2024
@apache apache unlocked this conversation Dec 5, 2024
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Dec 6, 2024
@apache apache locked and limited conversation to collaborators Dec 6, 2024
@apache apache unlocked this conversation Dec 6, 2024
@mbien
Copy link
Member

mbien commented Dec 20, 2024

really useful feature! We have to watch out for side effects of calling toString() though.

The debugger does have "Variable Formatters" which can be configured in the settings. Collections (which can be large) will only print their size by default for example. (but I imagine you are probably planning to do that anyway)

@mbien mbien modified the milestones: NB25, NB26 Jan 15, 2025
@lahodaj lahodaj marked this pull request as ready for review March 16, 2025 17:52
@lahodaj
Copy link
Contributor Author

lahodaj commented Mar 16, 2025

I did a lot of improvements lately. Lets see if this is heading in the right direction.

@lahodaj
Copy link
Contributor Author

lahodaj commented Mar 16, 2025

really useful feature! We have to watch out for side effects of calling toString() though.

The debugger does have "Variable Formatters" which can be configured in the settings. Collections (which can be large) will only print their size by default for example. (but I imagine you are probably planning to do that anyway)

Done.

@lahodaj
Copy link
Contributor Author

lahodaj commented Mar 16, 2025

FWIW, in VSCode, this needs to be enabled explicitly using the:

"debug.inlineValues": "on"

setting. I didn't find a way, yet, to make it work with auto.

@mbien
Copy link
Member

mbien commented Mar 20, 2025

gave it another try and it worked great. I got one exception once but wasn't able to reproduce it a second time:

java.lang.NullPointerException: Cannot invoke "com.sun.source.util.TreePath.getLeaf()" because "path" is null
	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
	at org.netbeans.modules.debugger.jpda.ui.values.ComputeInlineValues.computeVariables(ComputeInlineValues.java:115)
	at org.netbeans.modules.debugger.jpda.ui.models.InlineValueComputerImpl$ComputeInlineVariablesFactory$1.run(InlineValueComputerImpl.java:344)
	at org.netbeans.modules.debugger.jpda.ui.models.InlineValueComputerImpl$ComputeInlineVariablesFactory$1.run(InlineValueComputerImpl.java:321)
[catch] at org.netbeans.modules.java.source.JavaSourceAccessor$CancelableTaskWrapper.run(JavaSourceAccessor.java:273)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

the inline hint should also listen to the main on/off toggle and be potentially also configurable like its other friends (see options window):

image

(I think listening to the main toggle would be sufficient, finer grained options could be added when needed in followup PRs - we don't have to solve everything at once)

@lahodaj
Copy link
Contributor Author

lahodaj commented Mar 21, 2025

Thanks for testing. I'll look at the exception.

For the toggle - I think I would prefer to have a different toggle (people may want the debugger values, but not parameter hints, and maybe even vice versa). I'll look into that.

@neilcsmith-net
Copy link
Member

I like where this is going, and agree that this shouldn't be aligned with the inline hints toggle but something separately configured.

@mbien
Copy link
Member

mbien commented Mar 21, 2025

What I had in mind is that I think it would be nice to retain the master switch for all inline hints, but add more shortcuts for the sub-switches. It could be somewhere in the debugger toolbar too potentially. Completely decoupled from the editor setting could also work - not sure what is more intuitive. (I suppose i could double-bind my mouse button to achieve something like a master switch still no matter how its implemented)

@neilcsmith-net
Copy link
Member

Aside from commit cleanup (cause of failing test) is this close to ready for merging, or are we retargetting for NB27?

@lahodaj lahodaj modified the milestones: NB26, NB27 Apr 15, 2025
@lahodaj
Copy link
Contributor Author

lahodaj commented Apr 15, 2025

Moving to NB 27, although assuming I can stabilize tests, I would like to integrate as early as possible (so that there's time to fix any breakages).

@lahodaj lahodaj changed the title Prototype for inlining values inside debugger Inlining values inside debugger Apr 15, 2025
@lahodaj lahodaj force-pushed the inline-values branch 2 times, most recently from af6ff55 to 470ee74 Compare April 17, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants