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

Ros*_*Fsk 3 java intellij-idea intellij-plugin intellij-14

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

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

Ros*_*Fsk 7

经过多次挖掘后,我得到了以下解决方案,并且有效.

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);

}
Run Code Online (Sandbox Code Playgroud)