how to refresh jar file contents after contentsChanged event
hello,
I have encountered the following problem :
after an external library's contents have been changed, I detect a 'contentsChanged' event triggered for the library's jar archive.
But when I iterate over its children using the following code snippets :
...
VirtualFile jarClassRoot = StandardFileSystems.getJarRootForLocalFile(changedFile);
VfsUtilCore.visitChildrenRecursively(jarClassRoot, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { if (!file.isDirectory()) { if (isAcceptedInputFile(file)) { // child file recognized as potentialy interesting structureDefFiles.add(fil); // add it to the interesting file collection.. } return false; // move to the next sibling } return true; // iterate over directory's contents } });
...
I get the same file list as before 'contentsChanged' event (meaning a refresh is needed..)
How to force IDEA to refresh the changed jar's contents ?
Do I need to explicitly call
jarClassRoot.refresh(false, true)
from within a writeAction (synchronous call) to make it happen ?
Or should I wait for 'start' mode (if it has something to do with file-based indices..)
I would be very grateful for a more elaborate description of how jar archives are handled by IDEA (I couldn't figure it out on my own) and how to properly recognize a file as a jar archive (i use file extension for this purpose as I haven't found any dedicated file type - there's only some generic 'ARCHIVE' type)
Thank you in advance for any feedback,
regards
Simon
Please sign in to leave a comment.