2

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.

Community
  • 1
  • 1
jaumard
  • 8,202
  • 3
  • 40
  • 63
  • 1
    The last two APIs are both correct ways to refresh the IntelliJ IDEA VFS. If they don't bring the expected result, the most likely reason is that you're calling them at a wrong moment (possibly before your script has actually completed). – yole Apr 08 '15 at 18:29

1 Answers1

1

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.

Asken
  • 7,679
  • 10
  • 45
  • 77
jaumard
  • 8,202
  • 3
  • 40
  • 63