Search in sources :

Example 1 with VFileCopyEvent

use of com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent in project intellij-community by JetBrains.

the class PushedFilePropertiesUpdaterImpl method processAfterVfsChanges.

public void processAfterVfsChanges(@NotNull List<? extends VFileEvent> events) {
    boolean pushedSomething = false;
    List<Runnable> delayedTasks = ContainerUtil.newArrayList();
    for (VFileEvent event : events) {
        VirtualFile file = event.getFile();
        if (event instanceof VFileCopyEvent) {
            file = ((VFileCopyEvent) event).getNewParent().findChild(((VFileCopyEvent) event).getNewChildName());
        }
        if (file == null)
            continue;
        final FilePropertyPusher[] pushers = file.isDirectory() ? myPushers : myFilePushers;
        if (pushers.length == 0)
            continue;
        if (event instanceof VFileCreateEvent) {
            if (!event.isFromRefresh() || !file.isDirectory()) {
                // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
                // avoid dumb mode for just one file
                doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
                pushedSomething = true;
            } else if (!ProjectUtil.isProjectOrWorkspaceFile(file)) {
                ContainerUtil.addIfNotNull(delayedTasks, createRecursivePushTask(file, pushers));
            }
        } else if (event instanceof VFileMoveEvent || event instanceof VFileCopyEvent) {
            for (FilePropertyPusher<?> pusher : pushers) {
                file.putUserData(pusher.getFileDataKey(), null);
            }
            // push synchronously to avoid entering dumb mode in the middle of a meaningful write action
            doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
            pushedSomething = true;
        }
    }
    if (!delayedTasks.isEmpty()) {
        queueTasks(delayedTasks);
    }
    if (pushedSomething) {
        GuiUtils.invokeLaterIfNeeded(() -> scheduleDumbModeReindexingIfNeeded(), ModalityState.defaultModalityState());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VFileEvent(com.intellij.openapi.vfs.newvfs.events.VFileEvent) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) VFileCopyEvent(com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent) VFileCreateEvent(com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent) VFileMoveEvent(com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent)

Example 2 with VFileCopyEvent

use of com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent in project intellij by bazelbuild.

the class BulkSymbolTableBuildingChangeListener method after.

@Override
public void after(List<? extends VFileEvent> events) {
    if (!enabled) {
        return;
    }
    for (VFileEvent event : events) {
        VirtualFile modifiedFile = null;
        // Skip delete events.
        if (event instanceof VFileContentChangeEvent || event instanceof VFileCreateEvent) {
            modifiedFile = event.getFile();
        } else if (event instanceof VFileCopyEvent) {
            VFileCopyEvent copyEvent = (VFileCopyEvent) event;
            modifiedFile = copyEvent.getNewParent();
        } else if (event instanceof VFileMoveEvent) {
            VFileMoveEvent moveEvent = (VFileMoveEvent) event;
            modifiedFile = moveEvent.getNewParent();
        } else if (event instanceof VFilePropertyChangeEvent) {
            VFilePropertyChangeEvent propEvent = (VFilePropertyChangeEvent) event;
            // actually changing though)
            if (propEvent.getPropertyName().equals(VirtualFile.PROP_NAME) && !propEvent.getOldValue().equals(propEvent.getNewValue())) {
                modifiedFile = propEvent.getFile();
            }
        }
        if (SymbolTableProvider.isSourceFile(modifiedFile)) {
            queueChange(modifiedFile);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VFileEvent(com.intellij.openapi.vfs.newvfs.events.VFileEvent) VFileContentChangeEvent(com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent) VFilePropertyChangeEvent(com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent) VFileCreateEvent(com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent) VFileCopyEvent(com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent) VFileMoveEvent(com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VFileCopyEvent (com.intellij.openapi.vfs.newvfs.events.VFileCopyEvent)2 VFileCreateEvent (com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent)2 VFileEvent (com.intellij.openapi.vfs.newvfs.events.VFileEvent)2 VFileMoveEvent (com.intellij.openapi.vfs.newvfs.events.VFileMoveEvent)2 EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)1 VFileContentChangeEvent (com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent)1 VFilePropertyChangeEvent (com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent)1