Repository navigation
Description
Summary
LSP4IJ asks the platform whether a project is indexing through two flags of its own (scanning, dumbIndexing in ProjectIndexingManager). A listener on the internal ProjectIndexingActivityHistoryListener sets them, and its events can come after the platform has finished indexing. In that window, LSP4IJ still counts the project as indexing, and each LSP feature behind this check returns nothing, without an error.
- In the IDE this is rarely felt: right after indexing, a hover or a completion may come back empty once.
- In the tests it can make a test fail that asks a feature right after it opened a file in a new project. That is most likely what happened in the failure below. It happened once; a rerun passed.
So this is not urgent. It is worth fixing because the same check is in front of 26 features, and the long-term fix (#683) would remove the window in the IDE too. The cause is inferred from the CI log, not proven: see Open points.
The failure
LSPSemanticTokenDocumentationProviderTest.testPlainTextOfTwoLanguageServers failed once in the Test (ubuntu-latest, 2026.3) job (run, commit ab2a8ea). All other jobs of the run passed:
junit.framework.AssertionFailedError
at ...LSPSemanticTokenDocumentationProviderTest.getHintText(LSPSemanticTokenDocumentationProviderTest.java:162)
Line 162 is assertNotNull(hintText): getQuickNavigateInfo() returned null, so there was no hint at all, not a wrong one.
A rerun of the job passed. The same commit passes locally on IntelliJ IDEA 2026.3 (IU) too: the whole class once, and the single test 10 times in a row. So it is a rare race, not a failure on every run.
What the CI log shows
The test report of the job (tests-result-Linux-2026.3) holds the IDE log of the failed test. On 2026.3 each test opens a project of its own:
| Time | Event |
|---|---|
| 27,548 | project testPlainTextOfTwoLanguageServers is opened |
| 27,571–27,576 | scanning on project open |
| 27,580 | exit dumb mode |
| 27,608–27,619 | dumb mode again ("Push on VFS changes") |
| 27,634 | fileOpened test.ts |
| 27,644–27,658 | myFixture.doHighlighting() of initialize(), the semantic tokens come in |
| 27,662 | test failed |
Only 3–4 ms pass between the end of the highlighting and the failure. That is too short to ask two language servers (one of them added just before) and wait for both replies. So the hover was given up early, without a timeout and without an error. The log has no output of LSP4IJ itself.
Where null comes back that fast
LSPSemanticTokenDocumentationProvider.getDocumentation() returns null if LSPDocumentationTargetProvider.getHoverTargets() returns no targets. requestHover() sends no request at all if:
DumbService.isDumb(project). The log shows the project was not in dumb mode at that time.ProjectIndexingManager.canExecuteLSPFeature(psiFile) != NOW. That is the case whileisIndexingAll()is true, i.e. whilescanningordumbIndexingis set for any open project.
These two flags are not read from the platform. They are set by ProjectIndexingDumbAndScanningStrategy, a reflection proxy on the internal ProjectIndexingActivityHistoryListener. Its onFinishedScanning / onFinishedDumbIndexing events come with the indexing history and may arrive after the platform has ended scanning and dumb mode. The project was about 110 ms old. If one of these events had not arrived yet, the file counted as AFTER_INDEXING. Then no hover was sent, there was no hint, and assertNotNull failed.
Ruled out:
- No semantic tokens yet.
assertInstanceOf(element, LSPSemanticTokenPsiElement.class)in line 160 passed, and the highlighting had finished. - Only the second server was not ready. Then the text of the first server would still be there, and the test would fail at
contains("Third line<br>Fourth line"), not atassertNotNull. - Timeout or
ProcessCanceledException. That would take much longer than 3 ms. - The asynchronous
LSPFileSupport.dispose()when a server stops (LanguageServerWrapper.disposeFileSupports), which would cancel the hover too. It affects the files of the previous test, which belong to a project that was already closed.
Does this happen elsewhere?
In the code: yes, the same gate is in front of 26 features, nearly every LSP feature: hover, completion, semantic tokens, folding, inlay hints, code lens, formatting, code actions, go-to, find usages, hierarchies, structure view and the DAP variable positions, among others. Each returns nothing, without an error, while the flags are set. grep -rn "canExecuteLSPFeature\|isIndexingAll" src/main finds them all.
All 26 checks
In the tests: possible in any of them. 127 test classes are based on a code insight fixture. Each test that asks one of these features right after it opened a file in a new project can lose the same race. So the fix below belongs in the shared base class, not only in this one test.
In CI: not seen so far. In the last 40 failed ci.yml runs of this repository, no other failure clearly has this cause. The other flaky tests fail on server restarts, DAP sessions, a PSI leak (testGoToDefinitionWorksInTheContentOfTheServer) or file moves. GoToActionReportTest failed on 2025.3 and 2026.3 in the same run of one branch, which points to that branch's change, not to a race. This is the first time this failure showed up.
In the IDE: small. Right after indexing, a hover or a completion may come back empty once. The next try works. The editor features that LSP4IJ refreshes once indexing ends (filesToRefresh) catch up by themselves; a hover or a completion that the user asked for does not.
Proposed fix
1. Tests: wait for LSP4IJ's own indexing state
The platform's test fixture already waits for indexing when it opens a file (IndexWaiter in the log at 27,636). It does not know LSP4IJ's flags. So the wait belongs next to it, in the fixture that LSP4IJ's tests share.
A helper that any test can call (new, e.g. src/test/java/com/redhat/devtools/lsp4ij/fixtures/LSPIndexingTestUtil.java):
public final class LSPIndexingTestUtil {
private LSPIndexingTestUtil() {
}
/**
* Waits until LSP4IJ no longer counts any project as indexing.
* <p>
* Its flags follow the indexing history events, which can come after the platform has left dumb mode. Until
* then {@link ProjectIndexingManager#canExecuteLSPFeature} is not {@code NOW}, and each LSP feature returns
* nothing. This dispatches events while it waits, so an event delivered on the EDT cannot deadlock.
*/
public static void waitUntilLSP4IJIsNotIndexing() {
PlatformTestUtil.waitWithEventsDispatching(
"LSP4IJ still counts a project as indexing: " + ProjectIndexingManager.isIndexingAll(),
() -> !ProjectIndexingManager.isIndexingAll(), 10);
}
}ProjectIndexingManager.waitForIndexingAll().get() is no option here: it blocks the EDT, and it polls only once a second.
Called once, where the tests open their file. The tests open their files through LSPCodeInsightTestFixtureImpl, which extends CodeInsightTestFixtureImpl, and nearly always with configureByText (156 calls). One override there is enough:
@Override
public PsiFile configureByText(@NotNull String fileName, @NotNull String text) {
PsiFile file = super.configureByText(fileName, text);
LSPIndexingTestUtil.waitUntilLSP4IJIsNotIndexing();
return file;
}One wait after the file is opened covers both windows in the log: the scanning of the new project, and the dumb mode that creating the file can start ("Push on VFS changes"). A wait in setUp() as well would add nothing. The few tests that open a file in another way (openFileInEditor, 12 calls) or that are not based on this fixture call the helper themselves.
For the failing test, the wait then happens in initialize(), right before the hover is asked.
2. Longer term: read the platform's state instead of mirroring it (#683)
The window exists because ProjectIndexingManager.isIndexing() reads two flags that a listener on the internal ProjectIndexingActivityHistoryListener sets later:
public boolean isIndexing() {
return scanning || dumbIndexing || DumbService.isDumb(project);
}#683 says that since 2024.3 DumbService.runWhenSmart waits for scanning too. Where the platform covers scanning that way, LSP4IJ can ask it directly and needs no flags. A sketch:
/** Since 2024.3, smart mode waits for scanning too, see #683. */
private static final boolean SMART_MODE_WAITS_FOR_SCANNING =
ApplicationInfo.getInstance().getBuild().getBaselineVersion() >= 243;
public boolean isIndexing() {
if (SMART_MODE_WAITS_FOR_SCANNING) {
// The platform's own state: no listener, no lag behind it
return DumbService.isDumb(project);
}
// 2024.2 (pluginSinceBuild=242): keep the flags of the history listener
return scanning || dumbIndexing || DumbService.isDumb(project);
}And the refresh of the files that waited for indexing (filesToRefresh, today in ProjectIndexingStrategyBase.refreshEditorsFeaturesIfNeeded) would be scheduled when a feature is deferred, not by the history events:
private static @NotNull ExecuteLSPFeatureStatus doCanExecuteLSPFeature(@Nullable VirtualFile file,
@NotNull Project project) {
ProjectIndexingManager manager = getInstance(project);
if (isIndexingAll()) {
if (manager.filesToRefresh.add(file) && SMART_MODE_WAITS_FOR_SCANNING) {
// Refresh the editors of the waiting files once the project is smart again; refreshEditorsFeatures()
// would be today's ProjectIndexingStrategyBase.refreshEditorsFeaturesIfNeeded(), moved here
DumbService.getInstance(project).runWhenSmart(manager::refreshEditorsFeatures);
}
return ExecuteLSPFeatureStatus.AFTER_INDEXING;
}
return ExecuteLSPFeatureStatus.NOW;
}isIndexingAll() and waitForIndexingAll() stay as they are; they read isIndexing(). On 2024.3+ ProjectIndexingDumbAndScanningStrategy (the reflection proxy) would no longer be needed.
To be checked before this is done: that DumbService.isDumb() on 2024.3+ is true during the whole scanning, not only runWhenSmart. The log of the failure suggests so (DumbModeWhileScanningSubscriber is one of the tasks required for smart mode, and "exit dumb mode" comes after "Scanning completed"), but it was not checked in the platform sources.
With part 2, part 1 would no longer be needed: the features would check DumbService.isDumb(), which the platform's test fixture already waits for (IndexWaiter). So part 1 is a small stopgap for the tests, worth it only if this or a similar test fails again before part 2 is done.
Open points
- That the history events really come late on 2026.3 is inferred from the timing, not checked in the platform sources. A
LOGGER.debuginrequestHover()that names the reason fornull(dumb,AFTER_INDEXING, no file, no document) would make the next failure clear. - Why only the 2026.3 job failed is open. It may be a different delivery of the history events, or just timing.
How this was checked
Found by reading the code and the CI log with Claude Code. The failure was not reproduced:
- The CI log and the test report of the failed job, with the IDE log of the test (timestamps above).
- The same commit locally with
./gradlew test -PplatformVersion=2026.3 -PplatformType=IU: the whole class once, and the single test 10 times with--rerun. All passed (10–17 s each). gh run view --log-failedof the last 40 failedci.ymlruns of redhat-developer/lsp4ij, for the names of the failed tests.
Pair-programmed with ❤️ by @muescha and ⚙️ by 🤖 Claude Code
Activity
muescha commentedon Nov 23, 2026
The CI run and its test report will expire, so here are the log lines behind the timeline in the issue, from the IDE log of the failed test (job
Test (ubuntu-latest, 2026.3), commit ab2a8ea):IDE log of
testPlainTextOfTwoLanguageServers, from project open to the failureFailure in the test report
The log has no output of LSP4IJ itself, so it shows when the platform was done, not when LSP4IJ's flags were cleared.
lagergren commentedon Nov 23, 2026
@muescha The failure in this issue very likely has another cause, which is now proven and fixed: #2157, with the fix in #2159.
The cause:
EditorBehaviorFeaturecaches, for each file, the flag that turns on the semantic tokens-based file view provider. The cache was aCachedValuethat reads the language servers' modification counts after computing the flag. When the file's language server starts during that computation, the flag staysfalse. Highlighting then keeps no semantic token in the view provider. Adding the second server turns the provider on again, but with an empty token map.Why it matches your failure:
LSPSemanticTokenPsiElement.isIdentifierisUNSURE, so the hint is null at once, with no timeout and no error. That fits your 3–4 ms after the highlighting.The evidence:
What this doesn't show is whether the window of the indexing flags that you describe also happens. The fix wasn't run under load on 2026.3, where each test opens a project of its own. Whether to keep this issue open for the indexing flags is your call.
fix: give a file opened while its language server starts the editor b…
lagergren commentedon Nov 25, 2026
Closing: the failure behind this issue is fixed by #2159 (
6e6d7cb9, for 0.30.2). As explained above,EditorBehaviorFeaturecould keep the semantic-tokens view provider off for a file opened while its language server starts.The indexing-flag window described here was never shown to cause a failure. Running features during indexing is tracked in #683.