Allow ShowIntentionActionsAction to be used in dumb mode, show a notification for a regular project

LightEdit mode is always dumb. As a result no intentions are shown even if they are dumb-aware themselves.

GitOrigin-RevId: f99cfc711a055faf85a8cc7ea4b81f37474dd1f8
This commit is contained in:
Rustam Vishnyakov
2020-02-18 19:08:09 +03:00
committed by intellij-monorepo-bot
parent 54034d0152
commit f780a266c7
2 changed files with 24 additions and 2 deletions

View File

@@ -19,10 +19,14 @@ package com.intellij.codeInsight.intention.actions;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
import com.intellij.ide.lightEdit.LightEditCompatible;
import com.intellij.ide.lightEdit.LightEdit;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
@@ -32,11 +36,28 @@ import org.jetbrains.annotations.NotNull;
* @author mike
*/
public class ShowIntentionActionsAction extends BaseCodeInsightAction implements HintManagerImpl.ActionToIgnore,
LightEditCompatible {
DumbAware {
public ShowIntentionActionsAction() {
setEnabledInModalContext(true);
}
@Override
public void update(@NotNull AnActionEvent event) {
Project project = event.getProject();
Presentation presentation = event.getPresentation();
if (LightEdit.owns(project)) {
presentation.setEnabledAndVisible(true);
return;
}
else if (project != null && DumbService.isDumb(project)) {
DumbService.getInstance(project).showDumbModeNotification(
ApplicationBundle.message("intentions.are.not.available.message"));
presentation.setEnabledAndVisible(false);
return;
}
super.update(event);
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getProject();

View File

@@ -863,3 +863,4 @@ editbox.blanklines.around.method.in.interface=Around method in interface:
settings.editor.font.default=default
custom.option.description=Set custom page size
intentions.are.not.available.message=Intentions are not available while indices are updating.