Search code examples
scalasbtintellij-pluginintellij-scala

Call Scala Intellij Refresh Action From some other plugin


The requirement is to call Scala sbt plugin action (Refresh Action) and intelliJ synchronize all action from a custom plugin. As described here, we can use below syntax to call Actions of other plugins from our custom plugin :-

ActionManager.getInstance().getAction(IdeActions.ACTION_COPY_REFERENCE);

Is there any way to figure out Action name and ids for functionalities that are highlighted in red blocks in below screenshot :-

enter image description here


Solution

  • The action is com.intellij.openapi.externalSystem.action.RefreshAllExternalProjectsAction with id ExternalSystem.RefreshAllProjects (see ExternalSystemActions.xml)

    To trigger a project refresh programmatically, you don't need to call the action. You can use com.intellij.openapi.externalSystem.util.ExternalSystemUtil#refreshProjects

    In IntelliJ IDEA 2020.1 you may also use the experimental com.intellij.openapi.externalSystem.autoimport.ExternalSystemProjectTracker API via AutoImportProjectTracker.getInstance(???).scheduleProjectRefresh()