Repository navigation
feat: the debug console of a DAP session indents the output of a group, as console.group() gives - #2198
Merged
lagergren merged 2 commits intoNov 24, 2026
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2198 +/- ##
==========================================
+ Coverage 54.24% 54.29% +0.04%
==========================================
Files 832 833 +1
Lines 35337 35369 +32
Branches 7287 5541 -1746
==========================================
+ Hits 19170 19202 +32
- Misses 13338 13345 +7
+ Partials 2829 2822 -7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
lagergren
added a commit
that referenced
this pull request
Nov 24, 2026
…pter's telemetry output (#2199) Fixes #2197 ## What The debug console of a DAP session printed the output events of the category `telemetry`. DAP's `output` event says of it: "Send the output to telemetry instead of the client." VS Code doesn't show it either. Some debug adapters send usage data in JSON this way, which then showed up among the program's output. ## Change - `DAPClient.output` skips an output event of the category `telemetry` (new static `isTelemetry`). It logs the event at DEBUG under `DAPClient`'s logger, for whoever diagnoses a debug adapter. - The other categories are printed as before. `getContentType` loses its now unreachable `telemetry` case. - `docs/dap/DAPSupport.md`: the Output line says that telemetry isn't shown. #2198 (output groups) and the coming PR for #2169 (ANSI colours) also change `DAPClient.output`. Whichever merges later is rebased. ## Tests - New `DAPOutputCategorySessionTest`, a `HeavyPlatformTestCase` with an in-process debug adapter on a loopback socket, built like `DAPProcessEventSessionTest`. The adapter sends a `telemetry`, a `console` and a `stdout` output event. The console shows the last two, but not the telemetry. - Without the fix it fails, since the console shows `{"event":"usage"}`. With it, it passes, also headless. ## Behaviour change | Before | After | |---|---| | The debug console shows the debug adapter's `telemetry` output | It doesn't; the output is logged at DEBUG |
…p, as console.group() gives An 'output' event can start a group (group: start or startCollapsed) or end one (group: end), as a debug adapter does for console.group() and console.groupEnd(). The debug console ignored it, so grouped output printed flat, with the headers of the groups looking like any other line. The console now indents the lines of a group by its nesting level, two spaces per level, as Node.js does in a terminal: - the output of start and startCollapsed is the header of the group, on a line of its own at the level where the group starts; - the output of end, if any, is at the outer level, and the level never goes below 0; - each line is indented where it starts, so a line sent in chunks is indented once, and each line of a multi-line output is indented; - telemetry output belongs to no group and isn't indented. Each DAP client keeps its own groups, since each session of a tree started with startDebugging has its own output. The indentation is done by a small helper, DAPOutputGroups, called from DAPClient.output. A group can't be folded yet, so a startCollapsed group is shown expanded. Part of redhat-developer#2167
…l, and each session of a tree has its own groups DAPOutputGroupsTest covers the helper: nesting, startCollapsed, an end below level 0, the output of an end, lines in chunks, multi-line output, carriage returns, a group which starts or ends mid-line, and telemetry. DAPOutputGroupsSessionTest sends 'output' events from a DAP server in the test's process, on a loopback socket, and reads the console: the lines of nested groups are indented, and the groups of a child session started with startDebugging don't indent the lines of the root session, nor the other way round. Part of redhat-developer#2167
lagergren
force-pushed
the
feat/dap-console-output-groups
branch
from
November 24, 2026 15:23
f402118 to
8ccb841
Compare
This was referenced Nov 24, 2026
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
lagergren
added a commit
that referenced
this pull request
Nov 24, 2026
… added, removed, started or stopped, instead of keeping the hovers of the earlier language servers (#2208) Fixes #2207 ## What `LSPHoverSupport` keeps the future of a file's last hover, and gives it again for a hover at the same offset while the file and the project's PSI are unchanged. Whether a language server was added, started or stopped since didn't count. So a hover answered before a second language server of the file was ready kept being given without that server's hover, until the file changed or the caret hovered elsewhere. That applies to Ctrl+hover on a semantic token and to Quick Documentation. The caches are dropped when a language server stops or the file closes, but not when one is added or starts. It also made `LSPSemanticTokenDocumentationProviderTest.testPlainTextOfTwoLanguageServers` fail at times on CI. It failed on #2198's Linux 2025.3 job, right after `testTheHoverOfALanguageServerWhenTheOtherOneCannotStart`, with only the first server's hover. A probe that hovers, adds a second language server and hovers again at the same offset missed the second hover 9 times out of 10. With the hover cache cleared before the second hover, it missed 0 times. ## Change - `LSPHoverSupport` records the modification count of the project's language servers when it loads a hover. `LanguageServiceAccessor` advances that count when a definition is added or removed, and when a language server changes its status. A hover loaded at another count isn't given again. - The count is read before the requests are sent, as the modification stamps are. A language server that starts for this hover makes the next hover ask again, and then ask that server too. - `LanguageServiceAccessor.getModificationCount()` is new and `@ApiStatus.Internal`. Only hover changes. The other document features keep their caches as before, since they're refreshed when a language server starts. ## Tests New `LSPSemanticTokenDocumentationProviderTest.testTheHoverAtTheSameOffsetAfterALanguageServerIsAddedHasItsHoverToo`: it hovers, adds a second language server, and hovers at the same offset again. The second hover has both servers' hovers. - Red-green: without the fix, the test fails every time with only the first hover. With it, it passes. - The documentation, semantic tokens and hover tests pass headless on IC 2024.2, 2025.3 and IU 2026.3: 58 tests each. - All `features.*` tests pass headless on 2024.2: 734 tests, 0 failures, 3 skipped as before. ## Behaviour change | Before | After | |---|---| | A hover at the same place, in an unchanged file, gives the hovers of the language servers that answered the first time, even after another language server of the file was added or started | It asks the language servers again once one of the project was added, removed, started or stopped, so the new one's hover shows too |
lagergren
added a commit
that referenced
this pull request
Nov 24, 2026
…e debug adapter's output, which it now asks for with supportsANSIStyling (#2200) Fixes #2169 ## What The debug console of a DAP session printed `output` events as they came. ANSI escape sequences, which programs and debug adapters use for colours and bold, showed as raw codes such as `ESC[31mred ESC[0m`. LSP4IJ also didn't send the client capability `supportsANSIStyling` in `initialize`, so an adapter that honours it, such as vscode-js-debug, could leave styles out. ## Change - **New `DAPOutputDecoder`** (`dap/console`) decodes an `output` event's text with IntelliJ's `AnsiEscapeDecoder`, as a `ColoredProcessHandler` console does. It returns chunks of text without the escape codes, each with its console content type: - **Unstyled text** keeps its category's content type, the same mapping as before: stderr red, important verbose, everything else info. The mapping moved here from `DAPClient`. - **Styled text** gets the content type that `AnsiEscapeDecoder` and `ColoredOutputTypeRegistry` give it, as in a process console. - **One decoder per category:** a missing or unknown category counts as console, as DAP says. stderr is decoded as STDERR and the other categories as STDOUT, since the decoder only handles those two. So a style, or a sequence split across events, continues into the next event of the same category, and doesn't leak into another one. - **`DAPClient`:** each client has its own decoder, so each session of a `startDebugging` tree has its own. `output` prints the decoded chunks. - **`DAPDebugProcess.printOutput(List<Chunk>)`** prints an event's chunks together under `consoleLock`, so that no other session's text lands between them. The existing `printOutput(String, ConsoleViewContentType)` is unchanged. - **`DebugAdapterDescriptor.createInitializeRequestArguments`** sends `supportsANSIStyling: true`. - **Docs:** the Output line of `docs/dap/DAPSupport.md` names the capability and the behaviour. #2198 (output groups) and #2199 (telemetry) are merged, and this PR is rebased on them. `DAPOutputGroups`, its `outputGroups.indent(args)` and the telemetry check were already on main at the base. This PR passes the indented text through the decoder: `outputDecoder.decode(outputGroups.indent(args), args.getCategory())`. Not in this PR: - A bold-only span on stderr is bold in the default foreground, not bold red, as in a process console. - If a session ends inside an escape sequence, the leftover is dropped. ## Tests New `DAPOutputAnsiStylingSessionTest` (6 tests, a `HeavyPlatformTestCase` with an in-process debug adapter on a loopback socket). It reads the console text, and the content type of each character from the document's markup. - `initialize` carries `supportsANSIStyling: true`. - `\^[[31mred\^[[0m plain` shows `red plain`, with `red` in the scheme's red and ` plain` as info, and no escape character. - The colour of a group's output shows where the group indents it (after the rebase on #2198). - An escape sequence split over two events, whose colour runs into a third, shows `green done` in green. - On stderr, bold text is bold, and unstyled text stays `LOG_ERROR_OUTPUT`. - A stdout colour doesn't carry into console output. Red-green: - Without the change, the first 5 tests fail: `supportsANSIStyling` is null, and the console shows the raw codes. The group test was added later, with the rebase on #2198. With the change, all 6 pass, also headless. - With one decoder shared by all categories, only the last test fails, so it guards the one-decoder-per-category rule. The `dap.*` tests pass on IC 2024.2, 2025.3 and IU 2026.3: 462 each, with 0 failures or skipped. Rebased on main at d8c7551, they pass again, also headless: 518 tests, 0 failures. ## Behaviour change | Before | After | |---|---| | The debug console shows ANSI escape codes as raw text, and `initialize` doesn't send `supportsANSIStyling` | It shows the colours and bold without the codes, keeping the category's colour for unstyled text, and `initialize` sends `supportsANSIStyling: true` |
This was referenced Nov 24, 2026
lagergren
added a commit
that referenced
this pull request
Nov 25, 2026
…nly for the open files of each project, not once more in every other open project (#2225) Fixes #2224 ## What With several projects open, adding a language server definition started the server in every open project, for the open files of all open projects. When a definition is added, every project's `LanguageServiceAccessor` hears it. Its `checkCurrentlyOpenFiles` went through the open files of every open project (`ProjectManager.getOpenProjects()`), but connected them through its own project. So each file got one instance of the server per open project, and all but one of them had another project's root and workspace folders. It also made `LSPSemanticTokenDocumentationProviderTest.testPlainTextOfTwoLanguageServers` fail now and then on Linux CI: 3 of about 520 jobs since 2026-11-23, including #2198 (#2207) and #2222. - In the CI JVM, the light tests' shared project stays open, so `addSecondServer` started the second server twice. - Both starts connected to the definition's one `MockLanguageServer`, whose `addRemoteProxy` adds to plain `ArrayList`s. Two concurrent adds threw `ArrayIndexOutOfBoundsException`, and one start failed with `CannotStartServerException`. - When that was the test project's own start, the hover had only the first server's text. #2208 fixed a different cause of the same symptom: the hover cache across language-server changes. ## Change - **`checkCurrentlyOpenFiles`** starts the added definitions only for the open files of the accessor's own project. Each open project's accessor does the same for its own files, as `handleChanged` and `handleRemoved` already only touch their own project's servers. - **Disposed and default projects** are skipped. A project whose accessor doesn't exist yet doesn't connect its open files when a definition is added. Before, another project connected them, to a server of that other project. They connect as usual once a feature or an editor of the project uses LSP4IJ. ## Tests New `ServerAddedWithSeveralOpenProjectsTest` (2 tests). It opens a second project and adds a server while a file is open in one of the two projects. Then it checks two things: - The file gets its own project's server, with a bounded wait. - Once the async tasks are done, the other project started none. Red-green: without the fix, both tests fail every run, with the wrapper that the other project started (`expected:<[]> but was:<[LanguageServerWrapper@…]>`). With the fix, both pass. Reproduction of the CI failure, with the light project opened first: | Condition | Runs | Failures | A duplicate server started | |---|---|---|---| | Before the fix | 1,000 | 1, the exact CI message | every run | | After the fix | 1,000 | 0 | never | | A CI-like Linux suite (the 238 classes that precede it on CI), before the fix | 800 | 0 | 800 of 800 | | The same, after the fix | 800 | 0 | 0 | The new class, `features.documentation.*`, `features.semanticTokens.*` and `*Hover*` pass headless on IC 2024.2, 2025.3 and IU 2026.3: 60 tests each. The full suite passes on 2024.2: 2,416 tests, 0 failures, with the 7 skipped tests that were already disabled. Rebased on main at 57bae55, the new class and the hover class pass headless on all three platforms. Not in this PR: `MockLanguageServer` and `MockTextDocumentService.addRemoteProxy` still aren't thread-safe. A test that starts two connections to one mock at once could still hit the same exception. ## Behaviour change | Before | After | |---|---| | A language server added while several projects are open starts in each open project for the open files of all of them, so each file gets one instance per open project, most of them with another project's root | It starts in each project for that project's own open files only: one instance per file, of the file's own project |
lagergren
added a commit
that referenced
this pull request
Nov 25, 2026
… to the source location that the debug adapter gives it (#2220) Fixes #2166 ## What A DAP `output` event can carry the source location the output comes from: `source`, `line`, `column`, and since DAP 1.68 `locationReference`. VS Code shows it as a link next to the output line. LSP4IJ's `DAPClient.output` used only `category` and `output`, so the location was dropped. ## Change - **`DAPClient.output`** keeps its order: skip telemetry, indent groups (#2198), decode ANSI (#2200). If the event has a location, it prints the decoded chunks followed by a link. - **`DAPDebugProcess.printOutput(List<Chunk>, String, HyperlinkInfo)`**, a new overload, prints the output under `consoleLock` in this order: - the chunks, without the trailing line end; - a space; - the link, with `ConsoleView.printHyperlink`; - the line end. So the link stays on the output's line, right after it, with no other session's text in between. An output without a location, or without visible text, prints exactly as before. - **Link text:** `name:line`, e.g. `app.js:12`, for a `source` with a `line`, as VS Code shows it. "Jump to Value Source" for a `locationReference` alone, since its location is unknown until it's resolved. - **New `DAPOutputLocation`** (package-private `HyperlinkInfo`) resolves the location only when the link is clicked, off the EDT: - **`source` + `line`:** a `path` opens the local file at the line and column. A `sourceReference` loads its text, as stack frames do (`DAPFileRegistry`, `DAPSourceReferencePosition`), and opens it if the text loaded. - **`locationReference`:** resolved with the `locations` request (#2115), within the execution epoch of the output, because DAP gives it the lifetime of a `variablesReference`. Once the program has stopped or resumed since the output, the click reports that the reference is out of date and sends nothing. - **Both kinds present:** `source` + `line` wins, and one link is printed. - **Errors:** a failure is reported with a warning, as Jump to Value Source does. This covers the adapter's error, no location, an unopenable source, a stale reference, or an ended session. After the session ends, a `sourceReference` or `locationReference` link is reported, not sent. A `path` link still opens. - **`DAPLocations`** is now public, with public `getSource`, `getSourcePosition`, `hasSourceReference` and a new `canBeOpened(Source)`. This adds API and breaks none. - **Docs:** the Output line of `docs/dap/DAPSupport.md`. Not in this PR: - An output without a trailing line end gets the link at its end, so the next output continues after the link on the same line. - A `startDebugging` child session that has ended while its parent still runs isn't recognized as ended. The check uses the shared `XDebugSession`. ## Tests New `DAPOutputLocationSessionTest`, 7 tests with an in-process debug adapter. Every wait is bounded and has a message. - A `path` gives the line `set up handlers.js:3`. The link covers only its text and opens the file at (2,21). - A `sourceReference` makes the adapter receive `source` for reference 11, and `generated.js` opens with its text at (1,16). - A `locationReference` sends no `locations` request until the click. Then it opens the file at (2,21). - A `locationReference` clicked after a `continued` event is reported as out of date, and no request is sent. - After the session ends, the `sourceReference` link is reported, and the `path` link still opens. - An event without a location prints `plain` with no link. - A group with ANSI red gives ` red handlers.js:3`, still indented and red, with the link after it. Red-green: with `DAPClient.output` as on main, 5 tests fail (e.g. `expected:<set up[ handlers.js:3]> but was:<set up[]>`). The no-location test passes either way, as it guards against a regression. With the change, all 7 pass. The new class passes headless on IC 2024.2, 2025.3 and IU 2026.3. The `dap.*` tests pass on all three: 525 tests each, with 0 failures or skipped. ## Behaviour change | Before | After | |---|---| | The debug console dropped an `output` event's `source`, `line`, `column` and `locationReference`, and showed only the text | The console shows a link after the text, on its line. `app.js:12` opens the local file, or the text of the `sourceReference`, at that line and column. "Jump to Value Source" for a `locationReference` asks `locations` when clicked, while the program hasn't stopped or resumed since. An output without a location prints as before |
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2167: the indentation. Folding a group in the console is left for later.
What
The DAP
outputevent has an optionalgroup, whichconsole.group()andconsole.groupCollapsed()give, for instance:startbegins a group;startCollapsedbegins a collapsed one;endends the current group.LSP4IJ's debug console printed grouped output flat, with the group headers looking like any other line.
Change
New package-private
DAPOutputGroups, one perDAPClient, so each session of astartDebuggingtree has its own groups.DAPClient.outputprintsoutputGroups.indent(args)instead of the event's text, and nothing else in it changes.console.group()in a terminal. VS Code indents its tree in pixels, so it has no space count to copy.startandstartCollapsed: the event's text is the group's header, on its own line at the current level. Then the level goes up.end: the level goes down, never below 0, and the end's text, if any, is printed at the outer level, as DAP and VS Code do.\ralso counts as a line start, so a progress line that rewrites itself stays indented.DAPClient.outputdrops it first, as VS Code does.DAPOutputGroupsitself passes it through unchanged.docs/dap/DAPSupport.md(merged with fix: the debug console of a DAP session no longer shows the debug adapter's telemetry output #2199's line about telemetry) describes the indentation, that each session has its own groups, and that folding isn't supported yet, so astartCollapsedgroup shows expanded.Not in this PR:
DAPDebugProcess.printText.Tests
DAPOutputGroupsTest(JUnit 5, 14 tests):startCollapsed, anendbelow 0, and the text of anend;\r;DAPOutputGroupsSessionTest(2 tests, an in-process debug adapter on a loopback socket):startDebuggingdon't share their group levels.DAPClientchange, both session tests fail, since the block prints flat. With it, all 16 pass, also headless.dap.*tests pass on IC 2024.2, 2025.3 and IU 2026.3: 473 each, with 0 failures or skipped.Behaviour change
endat the outer level. Each session has its own groups