void (@NotNull PluginInstallOperation operation, @NotNull InstallPluginInfo info, @NotNull ModalityState modalityState) { boolean cancel = false; boolean success = true; boolean showErrors = true; boolean restartRequired = true; List<PendingDynamicPluginInstall> pluginsToInstallSynchronously = new ArrayList<>(); try { operation.run(); for (PendingDynamicPluginInstall install : operation.getPendingDynamicPluginInstalls()) { if (DynamicPlugins.allowLoadUnloadSynchronously(install.getPluginDescriptor())) { pluginsToInstallSynchronously.add(install); myPluginsToRemoveOnCancel.add(install.getPluginDescriptor()); } else { myDynamicPluginsToInstall.put(install.getPluginDescriptor().getPluginId(), install); } } success = operation.isSuccess(); showErrors = !operation.isShownErrors(); restartRequired = operation.isRestartRequired(); } catch (ProcessCanceledException e) { cancel = true; } catch (Throwable e) { LOG.error(e); success = false; } boolean _success = success; boolean _cancel = cancel; boolean _showErrors = showErrors; boolean _restartRequired = restartRequired; ApplicationManager.getApplication().invokeLater(() -> { boolean[] dynamicRestartRequired = new boolean[]{false}; for (PendingDynamicPluginInstall install : pluginsToInstallSynchronously) { boolean installedWithoutRestart = PluginInstaller.installAndLoadDynamicPlugin(install.getFile(), myInstalledPanel, install.getPluginDescriptor()); if (installedWithoutRestart) { IdeaPluginDescriptor installedDescriptor = PluginManagerCore.getPlugin(info.getDescriptor().getPluginId()); if (installedDescriptor != null) { info.setInstalledDescriptor((IdeaPluginDescriptorImpl)installedDescriptor); } } else { dynamicRestartRequired[0] = true; } } if (FINISH_DYNAMIC_INSTALLATION_WITHOUT_UI && isUIDisposedWithApply) { if (myDynamicPluginsToInstall.size() == 1 && myDynamicPluginsToUninstall.isEmpty() && !needRestart) { // this piece is stolen from #apply() for (var pendingPluginInstall : myDynamicPluginsToInstall.values()) { InstalledPluginsState.getInstance().trackPluginInstallation(() -> { var requiresRestart = !PluginInstaller.installAndLoadDynamicPlugin( pendingPluginInstall.getFile(), null, pendingPluginInstall.getPluginDescriptor() ); needRestart = requiresRestart; dynamicRestartRequired[0] |= requiresRestart; }); } myDynamicPluginsToInstall.clear(); LOG.info("installed final dynamic plugin"); } if (!myDynamicPluginsToInstall.isEmpty() || !myDynamicPluginsToUninstall.isEmpty()) { LOG.warn("pending dynamic plugins probably won't finish their installation: " + myDynamicPluginsToInstall + " " + myDynamicPluginsToUninstall); } } info.finish(_success, _cancel, _showErrors, _restartRequired || dynamicRestartRequired[0]); }, modalityState); }