boolean (@NotNull AnAction action, @NotNull AnActionEvent e, boolean beforeActionPerformed) { Presentation presentation = e.getPresentation(); if (LightEdit.owns(e.getProject()) && !isActionLightEditCompatible(action)) { presentation.setEnabledAndVisible(false); presentation.putClientProperty(WOULD_BE_ENABLED_IF_NOT_DUMB_MODE, false); presentation.putClientProperty(WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE, false); return false; } Boolean wasEnabledBefore = presentation.getClientProperty(WAS_ENABLED_BEFORE_DUMB); boolean dumbMode = isDumbMode(e.getProject()); if (wasEnabledBefore != null && !dumbMode) { presentation.putClientProperty(WAS_ENABLED_BEFORE_DUMB, null); presentation.setEnabled(wasEnabledBefore.booleanValue()); presentation.setVisible(true); } boolean enabledBeforeUpdate = presentation.isEnabled(); boolean allowed = !dumbMode || action.isDumbAware(); action.applyTextOverride(e); try { if (beforeActionPerformed && e.getUpdateSession() == UpdateSession.EMPTY) { IdeUiService.getInstance().initUpdateSession(e); } Runnable runnable = () -> { // init group flags from deprecated methods boolean isGroup = action instanceof ActionGroup; boolean wasPopup = isGroup && ((ActionGroup)action).isPopup(); boolean wasHideIfEmpty = isGroup && ((ActionGroup)action).hideIfNoVisibleChildren(); boolean wasDisableIfEmpty = isGroup && ((ActionGroup)action).disableIfNoVisibleChildren(); presentation.setPopupGroup(isGroup && (presentation.isPopupGroup() || wasPopup)); e.setInjectedContext(action.isInInjectedContext()); if (beforeActionPerformed) { action.beforeActionPerformedUpdate(e); } else { action.update(e); } if (!e.getPresentation().isEnabled() && e.isInInjectedContext()) { e.setInjectedContext(false); if (beforeActionPerformed) { action.beforeActionPerformedUpdate(e); } else { action.update(e); } } //to be removed when ActionGroup#canBePerformed is dropped e.getPresentation().setPerformGroup( isGroup && e.getPresentation().isPopupGroup() && (e.getPresentation().isPerformGroup() || ((ActionGroup)action).canBePerformed(e.getDataContext()))); if (isGroup) { assertDeprecatedActionGroupFlagsNotChanged((ActionGroup)action, e, wasPopup, wasHideIfEmpty, wasDisableIfEmpty); } }; boolean isLikeUpdate = !beforeActionPerformed; try (AccessToken ignore = SlowOperations.startSection(isLikeUpdate ? SlowOperations.ACTION_UPDATE : SlowOperations.ACTION_PERFORM)) { long startTime = System.nanoTime(); runnable.run(); long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); ActionsCollector.getInstance().recordUpdate(action, e, duration); } presentation.putClientProperty(WOULD_BE_ENABLED_IF_NOT_DUMB_MODE, !allowed && presentation.isEnabled()); presentation.putClientProperty(WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE, !allowed && presentation.isVisible()); } catch (IndexNotReadyException e1) { if (!allowed) { return true; } throw e1; } finally { if (!allowed) { if (wasEnabledBefore == null) { presentation.putClientProperty(WAS_ENABLED_BEFORE_DUMB, enabledBeforeUpdate); } presentation.setEnabled(false); } } return false; }