You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: the Call Hierarchy computes a method's callers and callees again when a write action cancels their request, instead of showing none - #2279
The Call Hierarchy could show a method with no callers or no callees when IntelliJ ran a write action while LSP4IJ waited for textDocument/prepareCallHierarchy, callHierarchy/incomingCalls or callHierarchy/outgoingCalls. Typing, a save, a VFS refresh or IntelliJ's registry update could do it. The node stayed empty until Refresh.
Cause
IntelliJ's hierarchy tree computes a node's children in a read action that a write action cancels. It computes them again only if the computation ends with the ProcessCanceledException: HierarchyTreeStructure.getChildElements keeps whatever buildChildren returns. The three call hierarchy tree structures caught the ProcessCanceledException from awaitWithCheckCanceled, cancelled the LSP request, and went on to fillChildren with no answer. So the node kept no children.
Fix
In LSPCallHierarchyIncomingCallsTreeStructure, LSPCallHierarchyOutgoingCallsTreeStructure and LSPCallHierarchyTreeStructureBase, the catch (ProcessCanceledException) still cancels the request ($/cancelRequest), and then rethrows the exception, as the type hierarchy already does. IntelliJ then computes the children again with a new request. The CancellationException handling, for a request that LSP4IJ itself cancelled, is unchanged.
Behaviour changes
Change
Commit
Who sees it
The Call Hierarchy computes a method's callers, callees and prepared item again when a write action cancels their request, instead of showing none until Refresh
fix: the Call Hierarchy computes a method's callers and callees again when a write action cancels their request, instead of showing none
Every user of the Call Hierarchy with a language server that takes long enough to answer for a write action to come in between
Tests
CallHierarchyWriteActionTest reproduces it deterministically. The mock language server holds its answer to prepareCallHierarchy, incomingCalls and outgoingCalls until the test completes it. The test computes a node's children as the hierarchy tree does: once, on a pooled thread, in runInReadActionWithWriteActionPriority. It runs a write action while the request is pending, then asserts that:
the computation ends with a ProcessCanceledException;
the node keeps no cached children;
the language server got $/cancelRequest (LSP4J cancelled its pending request);
once the language server answers, computing the children again gives the callers, the callees or the prepared item.
Without the fix, all three tests fail with "ended normally with 0 children".
All waits are bounded futures or events, with no fixed sleeps. Headless, com.redhat.devtools.lsp4ij.features.callHierarchy.* passes on 2024.2, 2025.3 and IU 2026.3 (5 tests, 0 failures, 0 errors, 0 skipped on each).
… when a write action cancels their request, instead of showing none
IntelliJ's hierarchy tree computes the children of a node in a read action
that a write action cancels, and computes them again only when the
computation ends with the ProcessCanceledException. The call hierarchy tree
structures caught it while they waited for textDocument/prepareCallHierarchy,
callHierarchy/incomingCalls or callHierarchy/outgoingCalls, cancelled the
request and returned no children, which HierarchyTreeStructure keeps: any
write action during the wait, such as typing, a save or a VFS refresh, left
the node empty until Refresh.
They now rethrow it after cancelling the request, as the type hierarchy does,
so IntelliJ computes the children again with a new request.
Fixesredhat-developer#2278
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Call hierarchy computations now stop promptly when canceled, instead of continuing with incomplete results. Pending requests are canceled, and caller, callee, and prepared-item results can be recomputed after an interruption.
Tests
Added coverage confirming that canceled computations do not retain incomplete results and that the affected call hierarchy items are correctly recomputed when a response becomes available.
Call hierarchy tree structures now rethrow ProcessCanceledException after cancelling pending requests. New tests check cancellation and recomputation for prepared items, callers, and callees.
Changes: Call hierarchy cancellation
Layer / File(s)
Summary
Propagate cancellation from tree computations src/main/java/com/redhat/devtools/lsp4ij/features/callHierarchy/LSPCallHierarchyTreeStructureBase.java, src/main/java/com/redhat/devtools/lsp4ij/features/callHierarchy/LSPCallHierarchyIncomingCallsTreeStructure.java, src/main/java/com/redhat/devtools/lsp4ij/features/callHierarchy/LSPCallHierarchyOutgoingCallsTreeStructure.java
The three tree structures rethrow ProcessCanceledException after cancelling pending requests.
Test cancellation and recomputation src/test/java/com/redhat/devtools/lsp4ij/features/callHierarchy/CallHierarchyWriteActionTest.java
Tests check that write-action cancellation leaves no cached children, cancels the pending request, and allows prepared items, callers, and callees to be computed after the server response arrives.
This change makes Call Hierarchy retry its computation after a write action interrupts a pending request, instead of leaving the node empty until Refresh. The change is narrow, and the added tests cover the retry scenario. No merge-blocking risk is identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: Call Hierarchy recomputes callers and callees after a write action cancels their request, instead of showing none. The raw summary covers only the three rethrow edits …
Description check
The description explains the cause (IntelliJ hierarchy tree computes children in a read action that a write action cancels), the fix (cancel the LSP request, then rethrow ProcessCanceledException in t…
Linked Issues check
Issue #2278 requires that each of the three call hierarchy tree structures keep the LSP cancel and rethrow ProcessCanceledException, so IntelliJ recomputes the node's children. The previous review con…
Out of Scope Changes check
The production changes are limited to the three call hierarchy tree structures named in #2278. Each change adds only a rethrow after the existing cancel. The new test class CallHierarchyWriteActionTes…
Full details: Title check
Explanation
The title names the main change: Call Hierarchy recomputes callers and callees after a write action cancels their request, instead of showing none. The raw summary covers only the three rethrow edits and the test, and the objectives match the title. The title is long (136 characters), but it stays accurate.
Full details: Description check
Explanation
The description explains the cause (IntelliJ hierarchy tree computes children in a read action that a write action cancels), the fix (cancel the LSP request, then rethrow ProcessCanceledException in the three tree structures), the tests, and the linked issue #2278. It matches the changeset.
Full details: Linked Issues check
Explanation
Issue #2278 requires that each of the three call hierarchy tree structures keep the LSP cancel and rethrow ProcessCanceledException, so IntelliJ recomputes the node's children. The previous review confirmed this for LSPCallHierarchyIncomingCallsTreeStructure.buildChildren: the catch block calls cancel() and then rethrows, and fillChildren is not reached. The PR summary and the AI-generated change summary report the same rethrow for LSPCallHierarchyOutgoingCallsTreeStructure.buildChildren and LSPCallHierarchyTreeStructureBase.buildRoot. The CancellationException branches are unchanged, as the issue allows. The changes since the previous review (commit 2fa2c40) add a watchdog to CallHierarchyWriteActionTest. That change is test-only and does not alter the production conformance. CallHierarchyWriteActionTest covers the held-response reproduction from the issue for prepared items, callers, and callees. Limitation: the diff tool could not read the changed blobs in this checkout, so the two non-incoming production files rest on the PR summary. Test results were not independently run.
Full details: Out of Scope Changes check
Explanation
The production changes are limited to the three call hierarchy tree structures named in #2278. Each change adds only a rethrow after the existing cancel. The new test class CallHierarchyWriteActionTest exercises those code paths. The incremental change since the previous review is a test watchdog that bounds the held-response wait, which supports the test and does not add unrelated behavior. Limitation: the diff tool could not read the changed blobs in this checkout, so this verdict rests on the file list and the PR summary.
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: 17d6ce4d-42d8-4cf5-9bd2-f8e5cd66f9b4
Commits
Reviewing files that changed from the base of the PR and between 150fe2d and 2fa2c40.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
158-159: Major · Stability & Availability · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Bound the write action in the cancellation test.
If the worker stops checking for cancellation while it waits for the held LSP response, WriteAction.run waits for the worker to release its read lock. The test cannot reach the timeout at Line 161 or release the response at Line 170. This can hang the test run instead of reporting the regression.
Start a watchdog on a separate thread before entering the write action. If the deadline expires, have it release the held response so the worker can exit, and fail the test explicitly. On the successful path, keep the response held until the cancellation assertions pass.
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: c1bf189c-abaf-4638-913e-82f4be648eef
Commits
Reviewing files that changed from the base of the PR and between 5e4c130 and 150fe2d.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.
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.
❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.40%. Comparing base (5e4c130) to head (2fa2c40). ⚠️ Report is 1 commits behind head on main.
… if the computation ignores the cancel
Should the computation wait for the language server's answer instead of ending when the write action cancels it, the write action would wait for its read lock forever. A watchdog answers the held request after the test's bound, so that both end and the test fails with a message.
@coderabbitai About the comment on CallHierarchyWriteActionTest.java lines 158-159 (bound the write action): fixed in 2fa2c40.
Before the write action, a watchdog is scheduled after the test's bound. If the computation hasn't ended by then because it waits for the held answer instead of ending when cancelled, the watchdog answers the held request, so the computation and the write action end. The test then fails with "the computation of the children must end when a write action cancels it, not wait for the answer of …". On success the watchdog is cancelled.
Checked by simulating that regression: the callers computation waited with a plain get() instead of awaitWithCheckCanceled. The test failed after 16 s with that message, instead of hanging.
For best results, initiate chat on the files or code changes.
Analysis chain
Script executed:
#!/bin/bashset -u
printf'%s\n''--- Current revision ---'
git rev-parse HEAD
printf'%s\n''--- Test file locations ---'
fd -t f '^CallHierarchyWriteActionTest\.java$'.printf'%s\n''--- Test file outline and numbered contents ---'while IFS= read -r file;do
ast-grep outline "$file" --items all --view expanded ||true
cat -n "$file"| sed -n '1,360p'done<<(fd -t f '^CallHierarchyWriteActionTest\.java$' .)printf'%s\n''--- Cited commit summary and test diff ---'
git show --format=fuller --stat 2fa2c404 -- 2>&1||true
git show --format= -- ':(glob)**/CallHierarchyWriteActionTest.java'2>&1| sed -n '1,220p'||true
Length of output: 27158
Script executed:
#!/bin/bashset -u
printf'%s\n''--- Current revision ---'
git rev-parse HEAD
printf'%s\n''--- Test file locations ---'
fd -t f '^CallHierarchyWriteActionTest\.java$'.printf'%s\n''--- Test file outline and numbered contents ---'while IFS= read -r file;do
ast-grep outline "$file" --items all --view expanded ||true
cat -n "$file"| sed -n '1,360p'done<<(fd -t f '^CallHierarchyWriteActionTest\.java$' .)printf'%s\n''--- Cited commit summary and test diff ---'
git show --format=fuller --stat 2fa2c404 -- 2>&1||true
git show 2fa2c404 --format= -- ':(glob)**/CallHierarchyWriteActionTest.java'2>&1| sed -n '1,220p'||true
Length of output: 27167
@lagergren Thanks for the fix and the regression check. I inspected commit 2fa2c404. The watchdog addresses the reported hang when the computation waits for the held response.
I did not run the test or change the review thread’s status.
If you found this review helpful, would you consider giving us a shout-out on X?
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.
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
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.
The Call Hierarchy could show a method with no callers or no callees when IntelliJ ran a write action while LSP4IJ waited for
textDocument/prepareCallHierarchy,callHierarchy/incomingCallsorcallHierarchy/outgoingCalls. Typing, a save, a VFS refresh or IntelliJ's registry update could do it. The node stayed empty until Refresh.Cause
IntelliJ's hierarchy tree computes a node's children in a read action that a write action cancels. It computes them again only if the computation ends with the
ProcessCanceledException:HierarchyTreeStructure.getChildElementskeeps whateverbuildChildrenreturns. The three call hierarchy tree structures caught theProcessCanceledExceptionfromawaitWithCheckCanceled, cancelled the LSP request, and went on tofillChildrenwith no answer. So the node kept no children.Fix
In
LSPCallHierarchyIncomingCallsTreeStructure,LSPCallHierarchyOutgoingCallsTreeStructureandLSPCallHierarchyTreeStructureBase, thecatch (ProcessCanceledException)still cancels the request ($/cancelRequest), and then rethrows the exception, as the type hierarchy already does. IntelliJ then computes the children again with a new request. TheCancellationExceptionhandling, for a request that LSP4IJ itself cancelled, is unchanged.Behaviour changes
Tests
CallHierarchyWriteActionTestreproduces it deterministically. The mock language server holds its answer toprepareCallHierarchy,incomingCallsandoutgoingCallsuntil the test completes it. The test computes a node's children as the hierarchy tree does: once, on a pooled thread, inrunInReadActionWithWriteActionPriority. It runs a write action while the request is pending, then asserts that:ProcessCanceledException;$/cancelRequest(LSP4J cancelled its pending request);Without the fix, all three tests fail with "ended normally with 0 children".
All waits are bounded futures or events, with no fixed sleeps. Headless,
com.redhat.devtools.lsp4ij.features.callHierarchy.*passes on 2024.2, 2025.3 and IU 2026.3 (5 tests, 0 failures, 0 errors, 0 skipped on each).Fixes #2278