Repository navigation
Description
Summary
LSP4IJ already supports diagnostics, folding, code lenses, documentation, and document links on non-project files (files outside content roots) by marking their respective passes/providers as DumbAware (LSPDiagnosticsPassFactory, LSPFoldingRangeBuilder, LSPCodeLensProvider, LSPDocumentationTargetProvider, LSPDocumentLinkPass).
However, LSP quick fixes (LSPQuickFixIntentionAction) and intention actions (LSPIntentionAction0..19) do not work on non-project files because their base class LSPLazyCodeActionIntentionAction does not implement com.intellij.openapi.project.DumbAware.
Root Cause
In IntelliJ Platform, both the intention popup (Alt+Enter via ShowIntentionsPass#addAvailableFixesForGroups and ShowIntentionsPass#getRegisteredIntentionActions) and the hover tooltip quick-fix button (DaemonTooltipActionProviderKt#extractMostPriorityFixFromHighlightInfo / DaemonTooltipAction#execute -> findIntention) filter actions using DumbService#isUsableInCurrentContext(Object thing, VirtualFile file):
fun isUsableInCurrentContext(thing: Any, file: VirtualFile?) : Boolean {
if (file == null || !file.isInLocalFileSystem) return isUsableInCurrentContext(thing)
return (!isDumb && FileIndexFacade.getInstance(project).isIndexable(file)) || isDumbAware(thing, project is LightEditCompatible)
}For a non-project file (a file outside the project's content roots/libraries), FileIndexFacade.getInstance(project).isIndexable(file) returns false even when the IDE is in Smart Mode (!isDumb == true).
Because (!isDumb && isIndexable(file)) evaluates to false, IntelliJ requires isDumbAware(thing) to be true:
- Prior to IntelliJ 2026.2 (IJPL-254242),
extractMostPriorityFixFromHighlightInfomissed theisUsableInCurrentContextcheck, so LSP quick fixes were shown in hover tooltips on non-project files, but clicking them silently failed insideDaemonTooltipAction#execute->findIntention(which calledShowIntentionsPass#getAvailableFixes->isUsableInCurrentContext->false). - In newer IntelliJ builds where
extractMostPriorityFixFromHighlightInfoalso checksisUsableInCurrentContext, non-DumbAwarequick fixes and intentions are completely hidden on non-project files in both tooltips andAlt+Enter.
Proposed Solution
-
Implement
DumbAwareonLSPLazyCodeActionIntentionAction:
Since external language servers operate out-of-process and do not rely on IntelliJ's PSI indexes,LSPLazyCodeActionIntentionActionshould implementDumbAware.- Note: For
LSPIntentionAction0..19registered via<intentionAction>inplugin.xml, IntelliJ wraps them inIntentionActionWrapperwhich implementsIntentionActionDelegate(PossiblyDumbAware) and delegatesisDumbAware()toDumbService.isDumbAware(getDelegate()). Thus, markingLSPLazyCodeActionIntentionActionasDumbAwareautomatically makes bothLSPQuickFixIntentionActionandLSPIntentionAction0..19dumb-aware.
- Note: For
-
Guard against actual project indexing in
LSPLazyCodeActionIntentionAction#isAvailable:
LSPIntentionAction#isAvailablealready checksProjectIndexingManager.canExecuteLSPFeature(file) != ExecuteLSPFeatureStatus.NOWto avoid triggering LSP requests while the project is actually indexing (scanning || dumbIndexing || DumbService.isDumb(project)). Moving this check up toLSPLazyCodeActionIntentionAction#isAvailableensures thatLSPQuickFixIntentionActionis also guarded during actual indexing while still returningtrue(ExecuteLSPFeatureStatus.NOW) for non-project files in Smart Mode:
// In com.redhat.devtools.lsp4ij.features.codeAction.LSPLazyCodeActionIntentionAction
public class LSPLazyCodeActionIntentionAction implements IntentionAction, DumbAware {
...
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (ProjectIndexingManager.canExecuteLSPFeature(file) != ExecuteLSPFeatureStatus.NOW) {
return false;
}
loadCodeActionIfNeeded();
return isValidCodeAction(this.action);
}- (Optional) Ensure write access for multi-file
WorkspaceEdits on non-project files:
For the currently activePsiFile,ShowIntentionActionsHandler#invokeIntentionautomatically callsFileModificationService.getInstance().preparePsiElementsForWrite(...)(triggering IntelliJ's standard "Non-Project Files Protection" unlock dialog beforeinvoke()runs). However, if aWorkspaceEditmodifies secondary non-project files,LSPIJUtils#applyWorkspaceEditshould callFileModificationService.getInstance().prepareVirtualFilesForWrite(project, affectedFiles)(orReadonlyStatusHandler.ensureFilesWritable(...)) before modifying documents.
Activity
lagergren commentedon Nov 9, 2026
The cause, checked in the IntelliJ sources and with LSP4IJ's tests: since IntelliJ 2025.3,
ShowIntentionsPass.getRegisteredIntentionActionsoffers a registered intention only ifDumbService.isUsableInCurrentContext(action, file), which for a file on the local file system is(!isDumb && FileIndexFacade.isIndexable(file)) || isDumbAware(action). A file outside the project's content isn't indexable, so LSP4IJ's intentions (LSPIntentionAction0…, which aren'tDumbAware) aren't offered there, even when nothing is being indexed. 2025.2 and earlier have onlyisUsableInCurrentContext(thing), which looks at dumb mode alone.LSP4IJ's own
ResolvedCodeActionTestshows it: its fixture's file is outside the project's content, and on 2025.3 and 2026.3getAvailableIntentions()is empty, so both of its tests fail, while they pass on 2024.2, which CI builds against. So the intentions are missing in non-project files for everyone on IntelliJ 2025.3 and later. #1681 makes themDumbAware, which is what that check asks for. Found while looking into building against 2026.x (#1908).