Skip to content

feat: Jump to Source on a lazy DAP variable opens its declaration after Show value, when only the lazy variable gives one - #2205

Merged
lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:feat/dap-lazy-variable-declaration
Nov 24, 2026
Merged

lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:feat/dap-lazy-variable-declaration

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2186

What

Since #2182, Jump to Source on a DAP variable opens its declaration when the variable has a declarationLocationReference. A lazy variable (presentationHint.lazy) shows its resolved child after "Show value", and Jump to Source then used only that child's reference. If only the lazy variable had one, Jump to Source fell back to searching the variable's name, although the debug adapter had given the declaration.

Change

DAPValue.getDeclarationSourcePosition uses the declarationLocationReference of the shown variable, or else the variable's own.

  • Before Show value, the shown variable is the variable itself, so nothing changes.
  • A value with its own reference still wins.
  • Both references come from the same stop, so the stop check of DAPLocations.locate covers both.

Not in this PR:

  • Jump to Value Source (valueLocationReference) still uses only the shown variable, since a lazy placeholder's own value location isn't the value's.
  • No current adapter sends both lazy and declarationLocationReference on one variable. lldb-dap gives declarations but doesn't mark variables lazy, and vscode-js-debug marks getters lazy but gives no declarations. So this follows the protocol ahead of the adapters.

Tests

DAPJumpToDeclarationSessionTest gets two lazy locals and two tests:

  • a lazy variable with a declaration whose value has none: Jump to Source opens the declaration, before and after Show value;
  • a lazy variable whose value has its own declaration: after Show value, Jump to Source opens the value's declaration.

Red-green: without the change, the first test fails, because the name search finds nothing. With it, all 14 tests of the class pass, also headless.

The dap.* tests pass on IC 2024.2, 2025.3 and IU 2026.3: 473 tests each, with 0 failures or skipped.

Behaviour change

Before After
After Show value on a lazy variable whose value has no declarationLocationReference, Jump to Source searches the variable's name, although the lazy variable has a declaration It opens the lazy variable's declaration. Before Show value, and when the value has its own reference, nothing changes

…er Show value, when only the lazy variable gives one

After "Show value", a lazy variable (presentationHint.lazy) shows the variable
with its value, and Jump to Source used only that variable's
declarationLocationReference. When the debug adapter gave the reference to the
lazy variable alone, Jump to Source searched the name instead. It now asks for
the declaration of the shown variable, or else of the lazy variable. Before
"Show value", and when the shown variable has its own reference, nothing changes.

Fixes redhat-developer#2186
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the enhancement New feature or request label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved “Go to Declaration” for variables whose values are loaded on demand. Navigation now uses the displayed value’s declaration when available, falls back to the original variable’s declaration when needed, and otherwise searches by variable name.
    • Corrected navigation for lazy variables both before and after their values are shown, including cases where the shown value has no declaration location of its own.

Declaration lookup now falls back to the original variable’s declaration reference when the displayed value has none. Tests cover navigation for lazy variables before and after showing their values, including a shown value with its own declaration reference.

Changes: Lazy Variable Navigation

Layer / File(s) Summary
Declaration lookup and lazy-variable tests
src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java, src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToDeclarationSessionTest.java
Declaration lookup checks the displayed variable’s reference first, then the original variable’s reference. Tests cover both cases and add mock lazy-variable responses and value evaluation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: muescha

Merge Risk: Minimal · up to d2b28

After "Show value" on a lazy variable, Jump to Source now falls back to the lazy variable's declaration when the shown value has none. Existing behavior is otherwise preserved, and tests cover both cases. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Jump to Source on a lazy DAP variable now opens the lazy variable's declaration after Show value when only the lazy variable has a declarationLocationReference. The ra…
Description check Passed The description links issue #2186 and explains the problem, the change in DAPValue.getDeclarationSourcePosition, the unchanged Jump to Value Source behavior, the new tests in DAPJumpToDeclarationSessi…
Linked Issues check Passed Issue #2186 has one direct coding requirement. When the shown variable of a lazy DAP variable has no declarationLocationReference, Jump to Source must use the lazy variable's own reference. At head, D…
Out of Scope Changes check Passed The PR changes DAPValue.getDeclarationSourcePosition, its Javadoc, and DAPJumpToDeclarationSessionTest (two new lazy-variable tests and a mock DAP server extension for lazy variables and declaration l…
Full details: Title check

Explanation

The title names the main change: Jump to Source on a lazy DAP variable now opens the lazy variable's declaration after Show value when only the lazy variable has a declarationLocationReference. The raw summary confirms DAPValue.getDeclarationSourcePosition now falls back to the original variable's reference, and tests cover this case. The title is long (121 characters), but it stays on topic.

Full details: Description check

Explanation

The description links issue #2186 and explains the problem, the change in DAPValue.getDeclarationSourcePosition, the unchanged Jump to Value Source behavior, the new tests in DAPJumpToDeclarationSessionTest, and the test results. It matches the changeset.

Full details: Linked Issues check

Explanation

Issue #2186 has one direct coding requirement. When the shown variable of a lazy DAP variable has no declarationLocationReference, Jump to Source must use the lazy variable's own reference. At head, DAPValue.getDeclarationSourcePosition() reads the reference of getShownVariable() first, then falls back to getDeclarationLocationReference(variable), and searches by name only when neither exists. This matches the issue's proposed implementation. The issue's requested test, in DAPJumpToDeclarationSessionTest, is reported in the PR as added: testJumpToSourceOnALazyVariableOpensItsDeclarationAfterShowValueWhenItsValueHasNone. The test file diff could not be read in this review, so the test's content rests on the PR summary and description, not on direct source inspection. The implementation was confirmed by reading the head file directly. The issue's note about checking adapter behaviour is addressed in the PR description, which states that no current adapter sends both lazy and declarationLocationReference on one variable.

Full details: Out of Scope Changes check

Explanation

The PR changes DAPValue.getDeclarationSourcePosition, its Javadoc, and DAPJumpToDeclarationSessionTest (two new lazy-variable tests and a mock DAP server extension for lazy variables and declaration locations). All changes serve the objective of #2186. The PR states that Jump to Value Source (valueLocationReference) is intentionally unchanged, and the DAPValue change does not alter that path. No unrelated change was identified. The whole-PR diff could not be read, so this verdict relies on the PR summary and the head file content of DAPValue.java.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bbea35d1-4c43-4ab9-8dce-2bd9ce81f105
Commits

Reviewing files that changed from the base of the PR and between 1b0b053 and d2b2851.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPValue.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToDeclarationSessionTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.60%. Comparing base (1b0b053) to head (d2b2851).

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #2205     +/-   ##
=========================================
  Coverage   54.59%   54.60%             
=========================================
  Files         834      834             
  Lines       35385    35386      +1     
  Branches     7300     5547   -1753     
=========================================
+ Hits        19320    19321      +1     
+ Misses      13223    13222      -1     
- Partials     2842     2843      +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit d8c7551 into redhat-developer:main Nov 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP: Jump to Source on a lazy variable uses its declaration location after Show value

1 participant