do not show some Go to actions in non-text editors

GitOrigin-RevId: 46e9f43810036c99d030cfa17ea5b8587fc3cfef
This commit is contained in:
Gregory.Shrago
2020-04-26 22:37:36 +00:00
committed by intellij-monorepo-bot
parent e5f742376b
commit a45d9516d6
3 changed files with 6 additions and 13 deletions
@@ -84,6 +84,7 @@ public abstract class CodeInsightAction extends AnAction implements UpdateInBack
final DataContext dataContext = e.getDataContext();
Editor editor = getEditor(dataContext, project, true);
if (editor == null) {
presentation.setVisible(!ActionPlaces.isPopupPlace(e.getPlace()));
presentation.setEnabled(false);
return;
}
@@ -30,7 +30,11 @@ public abstract class PresentableActionHandlerBasedAction extends BaseCodeInsigh
@Override
public void update(@NotNull AnActionEvent event) {
// since previous handled may have changed the presentation, we need to restore it; otherwise it will stick.
if (!getLanguageExtension().hasAnyExtensions()) {
event.getPresentation().setEnabledAndVisible(false);
return;
}
// since previous handled may have changed the presentation, we need to restore it; otherwise it will stick.
event.getPresentation().copyFrom(getTemplatePresentation());
applyTextOverride(event);
super.update(event);
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.generation.actions.PresentableActionHandlerBased
import com.intellij.lang.CodeInsightActions;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageExtension;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.DumbService;
@@ -57,17 +56,6 @@ public class GotoSuperAction extends PresentableActionHandlerBasedAction impleme
return false;
}
@Override
public void update(@NotNull final AnActionEvent event) {
if (CodeInsightActions.GOTO_SUPER.hasAnyExtensions()) {
event.getPresentation().setVisible(true);
super.update(event);
}
else {
event.getPresentation().setVisible(false);
}
}
@NotNull
@Override
protected LanguageExtension<CodeInsightActionHandler> getLanguageExtension() {