2015-04-06 34 views
1

我正在运行一些脚本命令,它在我的项目下生成文件,当我的命令终止时如何刷新/重新加载文件树?IntelliJ插件,将虚拟文件同步到真实文件

我已经看到了这Synchronize virtual file to the physical file in the Intellij IDEA plugin

我试图用这个,但没有运气:

FileDocumentManager.getInstance().saveAllDocuments(); 

VirtualFileManager.getInstance().syncRefresh(); 

或THES甚至

currentProject.getBaseDir().refresh(false, true); 

无e方法刷新项目树。

+1

最后两个API都是刷新IntelliJ IDEA VFS的正确方法。如果他们没有带来预期的结果,最可能的原因是你在错误的时刻给他们打电话(可能在你的脚本实际完成之前)。 – yole 2015-04-08 18:29:13

回答

1

刚刚找到正确的方法来做到这一点:

下我的问题
VirtualFile apiDir = currentProject.getBaseDir(); 
VfsUtil.markDirtyAndRefresh(true, true, true, apiDir); 

方法没有奏效,因为我的新文件在外面IntelliJ产生。