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

3

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

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

2个回答

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

}

0

你可以使用SyncAction来实现它

SyncProjectAction().actionPerformed(actionEvent)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接