Skip to content

feat(dap): a hit condition for line breakpoints - #1787

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/line-breakpoint-hit-count
Oct 28, 2026
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/line-breakpoint-hit-count

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

A DAP line breakpoint can't have a hit condition. DAPBreakpointHandlerBase.addSourceBreakpoint() sends a line breakpoint's condition and log message but never sets SourceBreakpoint.hitCondition, and IntelliJ's line breakpoints have no hit count of their own to send. So with a debug adapter that has supportsHitConditionalBreakpoints, a breakpoint can't stop only at, say, its third hit. Function breakpoints (#1780) and data breakpoints (#1782) already have a hit condition.

The fix

  • DAPBreakpointProperties, which had no state, keeps a hit condition that the DAP server reads, such as 3 or >= 3, and saves it with the breakpoint.
  • DAPBreakpointType has a properties panel with a Hit condition field in the Breakpoints dialog, as the function and data breakpoint types have. A change fires breakpointChanged, so the debug sessions send the breakpoints again.
  • addSourceBreakpoint() sends a non-blank hit condition as the source breakpoint's hitCondition. A breakpoint of another plugin's type, forwarded to the DAP server, has none. Neither does the "Run to Cursor" breakpoint.
  • The user guide describes the hit condition.

Tests

New DAPBreakpointHitConditionTest:

  • The setBreakpoints request carries each line breakpoint's hit condition, and no hit condition for a breakpoint without one or with a blank one.
  • The hit condition is saved and loaded.
  • The panel changes the hit condition, and tells IntelliJ only when it changed.

./gradlew test: 921 tests, 3 skipped. The 7 failures are "File accessed outside allowed roots" (LSPIJUtils_applyWorkspaceEdit_{Go,TypeScript,Scala,Zig}Test and CommandExecutorTest.testExecuteCommandWithValidTextEdit), which main also has on macOS.

Not checked natively yet.

LSP4IJ sent a line breakpoint's condition and log message, but no hit
condition: DAPBreakpointHandlerBase.addSourceBreakpoint() never set
SourceBreakpoint.hitCondition, and IntelliJ line breakpoints have no
hit count to send. Function and data breakpoints already have one.

A DAP line breakpoint now has a hit condition, which the DAP server
reads, such as 3 or >= 3, as function and data breakpoints do: it is
kept with the breakpoint's properties, changed in the Breakpoints
dialog, and sent as the source breakpoint's hitCondition. A DAP server
without supportsHitConditionalBreakpoints ignores it.

Tests: DAPBreakpointHitConditionTest. ./gradlew test: 921 tests, 3
skipped, and the 7 failures "File accessed outside allowed roots"
which main has on macOS too.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

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: 28850693-c95b-4988-b208-90443fb731f6
Commits

Reviewing files that changed from the base of the PR and between e301a97 and f273e8c.

Files selected for processing: 7
  • docs/dap/UserGuide.md
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHandlerBase.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointProperties.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointPropertiesPanel.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointType.java
  • src/main/resources/messages/DAPBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHitConditionTest.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.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Configure a hit condition for a line breakpoint, such as 3 or >= 3. The condition is sent to the debug adapter along with the breakpoint.
  • Documentation
    • The user guide explains how hit conditions work and notes that a debug adapter may ignore them if unsupported.

DAP line breakpoints now support hit conditions. The breakpoint properties panel edits and stores the condition, and the handler sends nonblank conditions to the DAP server for regular breakpoints.

Changes: DAP breakpoint hit conditions

Layer / File(s) Summary
Store and edit hit conditions
src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointProperties.java, src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointPropertiesPanel.java, src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointType.java, src/main/resources/messages/DAPBundle.properties, src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHitConditionTest.java
Breakpoint properties store the hit condition. The custom properties panel trims edits, saves changed values, and notifies IntelliJ. Tests cover state serialization and panel edits.
Send hit conditions to the DAP server
src/main/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHandlerBase.java, src/test/java/com/redhat/devtools/lsp4ij/dap/breakpoints/DAPBreakpointHitConditionTest.java, docs/dap/UserGuide.md
The handler sends nonblank conditions for regular breakpoints and passes null for registered and temporary breakpoints. Tests check transmission, and the guide describes hit-condition support.

Priority: Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DAPBreakpointProperties
  participant DAPBreakpointHandlerBase
  participant DAPServer
  DAPBreakpointHandlerBase->>DAPBreakpointProperties: Read hit condition
  DAPBreakpointHandlerBase->>DAPServer: Send source breakpoint with hit condition
Loading

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to f273e

No actionable merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes adding hit conditions for DAP line breakpoints.
Description check Passed The description directly explains the missing hit-condition support, the implementation, documentation, and tests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 5 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.36%. Comparing base (e301a97) to head (f273e8c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../dap/breakpoints/DAPBreakpointPropertiesPanel.java 76.47% 4 Missing ⚠️
...p4ij/dap/breakpoints/DAPBreakpointHandlerBase.java 88.88% 1 Missing ⚠️
...sp4ij/dap/breakpoints/DAPBreakpointProperties.java 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1787      +/-   ##
==========================================
- Coverage   36.38%   36.36%   -0.03%     
==========================================
  Files         779      780       +1     
  Lines       29678    29707      +29     
  Branches     4505     5950    +1445     
==========================================
+ Hits        10798    10802       +4     
- Misses      16992    17020      +28     
+ Partials     1888     1885       -3     

☔ 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.

@angelozerr angelozerr added enhancement New feature or request dap Debugging Adapter Protocol labels Oct 28, 2026
@angelozerr angelozerr added this to the 0.21.1 milestone Oct 28, 2026
@angelozerr angelozerr moved this to In Progress in Java Tooling Oct 28, 2026
@angelozerr
angelozerr merged commit 0ecbcde into redhat-developer:main Oct 28, 2026
9 checks passed
@angelozerr

Copy link
Copy Markdown
Contributor

Thanks @lagergren !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dap Debugging Adapter Protocol enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants