}
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
IFile virtualFile = new FileImpl(event.getFile());
if (Ignore.isIgnoreFile(virtualFile) && !context.isIgnored(virtualFile)) {
context.refreshIgnores();
break;
}
}
if (!isListening.get()) {
return;
}
for (VFileEvent event : events) {
Flog.debug(" after event type %s", event.getClass().getSimpleName());
if (event instanceof VFilePropertyChangeEvent) {
VFilePropertyChangeEvent propertyEvent = (VFilePropertyChangeEvent) event;
if (propertyEvent.getPropertyName() != "name") {
continue;
}
VirtualFile virtualFile = propertyEvent.getFile();
renameAllNestedFiles(virtualFile, oldRenamePath, virtualFile.getPath());
oldRenamePath = null;
continue;
}
if (event instanceof VFileMoveEvent) {
Flog.info("move event %s", event);
VirtualFile oldParent = ((VFileMoveEvent) event).getOldParent();
VirtualFile newParent = ((VFileMoveEvent) event).getNewParent();
renameAllNestedFiles(event.getFile(), oldParent.getPath(), newParent.getPath());
continue;
}
if (event instanceof VFileCopyEvent) {
// We get one copy event per file copied for copied directories, which makes this easy.
Flog.info("Copying a file %s", event);
VirtualFile newParent = ((VFileCopyEvent) event).getNewParent();
String newChildName = ((VFileCopyEvent) event).getNewChildName();
String path = event.getPath();
VirtualFile[] children = newParent.getChildren();
VirtualFile copiedFile = null;
for (VirtualFile child : children) {
if (child.getName().equals(newChildName)) {
copiedFile = child;
break;
}
}
if (copiedFile == null) {
Flog.warn("Couldn't find copied virtual file %s", path);
continue;
}
editorManager.createFile(new FileImpl(copiedFile));
continue;
}
if (event instanceof VFileCreateEvent) {
Flog.info("creating a file %s", event);
ArrayList<IFile> createdFiles = IntelliUtils.getAllValidNestedFiles(context, event.getFile());