通过插件以编程方式刷新/同步 IntelliJ IDEA 项目



有没有办法通过插件以编程方式刷新/同步IntelliJ IDEA项目?

我正在开发一个 IntelliJ IDEA 插件,该插件可在活动项目中创建一个文件。我想通过插件自动刷新/同步项目,以便用户可以立即看到更改。这在IntelliJ IDEA中可能吗?

在挖掘更多之后,我通过了以下解决方案,它奏效了。

public void actionPerformed(AnActionEvent e) {
    // Create/Modify files
    // Get the project from the ActionEvent
    Project project = e.getData(PlatformDataKeys.PROJECT);
    // Get the Base Dir and refresh with the following parameters
    // 'asynchronous' set to false and 'recursive' set to true
    project.getBaseDir().refresh(false,true);
}

您可以使用SyncAction。

SyncProjectAction().actionPerformed(actionEvent)

最新更新