intellij-ideaintellij-pluginintellij-14virtual-file

IntelliJ Plugin, Sync Virtual files to real files


I'm running some script command which generates files under my project, how can I refresh/reload the file tree when my command is terminated?

I have seen this Synchronize virtual file to the physical file in the Intellij IDEA plugin

I have tried to use this but no luck:

FileDocumentManager.getInstance().saveAllDocuments();

or

VirtualFileManager.getInstance().syncRefresh();

or even

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

None of these methods refresh the project tree.


Solution

  • Just found the correct way to do it :

    VirtualFile apiDir = currentProject.getBaseDir();
    VfsUtil.markDirtyAndRefresh(true, true, true, apiDir);
    

    Methods under my question were not working because my new files were generated outside IntelliJ.