Skip to content

feat(dap): let a descriptor start its process for an attach - #1798

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/dap-attach-through-descriptor-process
Oct 29, 2026
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
lagergren:feat/dap-attach-through-descriptor-process

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

DAPCommandLineState.startProcess() starts a NopProcessHandler for an attach, in place of the descriptor's startServer(), and the DAP client then reaches the Debug Adapter at the address and port of getServerReadyConfig(DebugMode.ATTACH). That is right for a Debug Adapter that already runs and listens, but a descriptor whose Debug Adapter is reached through the process that startServer() starts can only launch: in attach mode it has no process, and without a port the client reads the streams of the NopProcessHandler.

The Ecstasy plugin's Debug Adapter runs in its language server, and startServer() returns a process handler that carries the session over the language server's connection. Its new attach configuration, which attaches to a program started outside the IDE, keeps getDebugMode() at LAUNCH so that the handler is started, and overrides createClient() to make the client in ATTACH mode, so that it sends attach and, on stop, disconnect.

The change

  • New DebugAdapterDescriptor.startServer(DebugMode): the session's process. For a launch it is startServer(); for an attach it is a NopProcessHandler by default, as before. A descriptor that reaches its Debug Adapter through its process overrides it.
  • DAPCommandLineState.startProcess() calls it.
  • docs/dap/DeveloperGuide.md says when to override it.

Tests

New DAPCommandLineStateTest: a launch starts the descriptor's server; an attach starts a NopProcessHandler and never calls startServer(); and an attach of a descriptor that overrides startServer(DebugMode) starts its process.

With startProcess() as it was, the last case fails.

./gradlew test: 944 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: the Ecstasy plugin builds on 0.21.0, which has no startServer(DebugMode).

Design question

@angelozerr, the descriptor could instead say only whether its attach needs its process, with something like boolean isAttachThroughProcess(), and DAPCommandLineState would call startServer() itself. I chose the overload because it lets a descriptor start a different process for an attach, but I'm happy to switch.

An attach started a NopProcessHandler in place of the descriptor's server, and the DAP client then reached the Debug Adapter by the address and port of the attach configuration. A descriptor whose Debug Adapter is reached through its process, such as one that carries its sessions over another connection, could only launch. DebugAdapterDescriptor.startServer(DebugMode) starts the session's process: the server for a launch, and by default nothing for an attach, as before; such a descriptor overrides it.
@coderabbitai

coderabbitai Bot commented Oct 29, 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: ec2ab6c3-f6db-4b72-8070-49c09f5ef72d
Commits

Reviewing files that changed from the base of the PR and between 116a18d and 8b7b093.

Files selected for processing: 4
  • docs/dap/DeveloperGuide.md
  • src/main/java/com/redhat/devtools/lsp4ij/dap/configurations/DAPCommandLineState.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterDescriptor.java
  • src/test/java/com/redhat/devtools/lsp4ij/dap/configurations/DAPCommandLineStateTest.java

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

📝 Summary

Summary by CodeRabbit

  • New Features
    • Attach sessions now connect to an already-running debug adapter without starting a process by default. Adapters that require a process to be started can do so for attach sessions, while launch sessions continue to start the adapter process.
  • Documentation
    • Updated the developer guide to explain how launch and attach sessions handle adapter startup and how to configure attach sessions that require a process.

Debug adapter startup now passes the selected debug mode to the descriptor. The descriptor returns a no-op process handler for attach mode by default, while allowing subclasses to start a process for attach sessions. Tests cover launch and attach startup behavior.

Changes: Debug adapter startup

Layer / File(s) Summary
Mode-specific descriptor startup
src/main/java/com/redhat/devtools/lsp4ij/dap/descriptors/DebugAdapterDescriptor.java
DebugAdapterDescriptor adds startServer(DebugMode). Attach mode returns a no-op process handler by default; other modes delegate to the existing startServer().
Startup wiring and validation
src/main/java/com/redhat/devtools/lsp4ij/dap/configurations/DAPCommandLineState.java, src/test/java/com/redhat/devtools/lsp4ij/dap/configurations/DAPCommandLineStateTest.java, docs/dap/DeveloperGuide.md
DAPCommandLineState passes the debug mode to the descriptor. Tests cover launch, default attach, and attach through a descriptor process. The guide documents the default and override behavior.

Priority: Normal

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

Change: Feature

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 8b7b0

The change enables descriptors to start a process for attach sessions while preserving default startup behavior. No actionable merge-blocking issue is identified; merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% 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 the main change: allowing a descriptor to start its process for an attach session.
Description check Passed The description directly explains the attach-session behavior, the new API, implementation changes, tests, and validation results.
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 50.00% 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 2 functions across 3 files. (1 skipped: 1 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 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.69%. Comparing base (116a18d) to head (8b7b093).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1798      +/-   ##
==========================================
+ Coverage   36.66%   36.69%   +0.02%     
==========================================
  Files         781      781              
  Lines       29843    29842       -1     
  Branches     4533     4532       -1     
==========================================
+ Hits        10943    10951       +8     
+ Misses      16994    16988       -6     
+ Partials     1906     1903       -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

Copy link
Copy Markdown
Contributor

@lagergren your PR is good, but I notice (I remember that for now) that the DAP dev guide is very simple and not finished.

As you are working on DAP LSP4IJ extension, if you have time please improve this guide.

@angelozerr angelozerr added enhancement New feature or request dap Debugging Adapter Protocol labels Oct 29, 2026
@angelozerr angelozerr added this to the 0.30.0 milestone Oct 29, 2026
@angelozerr angelozerr moved this to In Progress in Java Tooling Oct 29, 2026
@angelozerr
angelozerr merged commit 8c4a5ba into redhat-developer:main Oct 29, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Java Tooling Oct 29, 2026
@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