use of com.intellij.openapi.vfs.newvfs.events.VFileEvent in project intellij-community by JetBrains.
the class GitRepositoryUpdater method after.
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
// which files in .git were changed
boolean configChanged = false;
boolean headChanged = false;
boolean branchFileChanged = false;
boolean packedRefsChanged = false;
boolean rebaseFileChanged = false;
boolean mergeFileChanged = false;
boolean tagChanged = false;
for (VFileEvent event : events) {
String filePath = GitFileUtils.stripFileProtocolPrefix(event.getPath());
if (myRepositoryFiles.isConfigFile(filePath)) {
configChanged = true;
} else if (myRepositoryFiles.isHeadFile(filePath)) {
headChanged = true;
} else if (myRepositoryFiles.isBranchFile(filePath)) {
// it is also possible, that a local branch with complex name ("folder/branch") was created => the folder also to be watched.
branchFileChanged = true;
DvcsUtil.ensureAllChildrenInVfs(myHeadsDir);
} else if (myRepositoryFiles.isRemoteBranchFile(filePath)) {
// it is possible, that a branch from a new remote was fetch => we need to add new remote folder to the VFS
branchFileChanged = true;
DvcsUtil.ensureAllChildrenInVfs(myRemotesDir);
} else if (myRepositoryFiles.isPackedRefs(filePath)) {
packedRefsChanged = true;
} else if (myRepositoryFiles.isRebaseFile(filePath)) {
rebaseFileChanged = true;
} else if (myRepositoryFiles.isMergeFile(filePath)) {
mergeFileChanged = true;
} else if (myRepositoryFiles.isTagFile(filePath)) {
DvcsUtil.ensureAllChildrenInVfs(myTagsDir);
tagChanged = true;
}
}
if (headChanged || configChanged || branchFileChanged || packedRefsChanged || rebaseFileChanged || mergeFileChanged) {
myUpdateQueue.add(DUMMY_UPDATE_OBJECT);
} else if (tagChanged) {
myRepository.getProject().getMessageBus().syncPublisher(GitRepository.GIT_REPO_CHANGE).repositoryChanged(myRepository);
}
}
use of com.intellij.openapi.vfs.newvfs.events.VFileEvent 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());
}
}
use of com.intellij.openapi.vfs.newvfs.events.VFileEvent in project intellij-community by JetBrains.
the class JrtFileSystemImpl method checkSubscription.
private void checkSubscription() {
if (mySubscribed.getAndSet(true))
return;
Application app = ApplicationManager.getApplication();
app.getMessageBus().connect(app).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
Set<VirtualFile> toRefresh = null;
for (VFileEvent event : events) {
if (event.getFileSystem() instanceof LocalFileSystem && event instanceof VFileContentChangeEvent) {
VirtualFile file = event.getFile();
if (file != null && "release".equals(file.getName())) {
String homePath = file.getParent().getPath();
ArchiveHandler handler = myHandlers.remove(homePath);
if (handler != null) {
handler.dispose();
VirtualFile root = findFileByPath(composeRootPath(homePath));
if (root != null) {
((NewVirtualFile) root).markDirtyRecursively();
if (toRefresh == null)
toRefresh = ContainerUtil.newHashSet();
toRefresh.add(root);
}
}
}
}
}
if (toRefresh != null) {
boolean async = !ApplicationManager.getApplication().isUnitTestMode();
RefreshQueue.getInstance().refresh(async, true, null, toRefresh);
}
}
});
}
use of com.intellij.openapi.vfs.newvfs.events.VFileEvent in project intellij-community by JetBrains.
the class RefResolveServiceImpl method initListeners.
private void initListeners(@NotNull MessageBus messageBus, @NotNull PsiManager psiManager) {
messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
fileCount.set(0);
List<VirtualFile> files = ContainerUtil.mapNotNull(events, new Function<VFileEvent, VirtualFile>() {
@Override
public VirtualFile fun(VFileEvent event) {
return event.getFile();
}
});
queue(files, "VFS events " + events.size());
}
});
psiManager.addPsiTreeChangeListener(new PsiTreeChangeAdapter() {
@Override
public void childrenChanged(@NotNull PsiTreeChangeEvent event) {
PsiFile file = event.getFile();
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file);
if (virtualFile != null) {
queue(Collections.singletonList(virtualFile), event);
}
}
@Override
public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
childrenChanged(event);
}
});
messageBus.connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
disable();
}
@Override
public void exitDumbMode() {
enable();
}
});
messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() {
@Override
public void powerSaveStateChanged() {
if (PowerSaveMode.isEnabled()) {
enable();
} else {
disable();
}
}
});
myApplication.addApplicationListener(new ApplicationAdapter() {
@Override
public void beforeWriteActionStart(@NotNull Object action) {
disable();
}
@Override
public void writeActionFinished(@NotNull Object action) {
enable();
}
@Override
public void applicationExiting() {
disable();
}
}, this);
VirtualFileManager.getInstance().addVirtualFileManagerListener(new VirtualFileManagerListener() {
@Override
public void beforeRefreshStart(boolean asynchronous) {
disable();
}
@Override
public void afterRefreshFinish(boolean asynchronous) {
enable();
}
}, this);
HeavyProcessLatch.INSTANCE.addListener(new HeavyProcessLatch.HeavyProcessListener() {
@Override
public void processStarted() {
}
@Override
public void processFinished() {
wakeUp();
}
}, this);
}
use of com.intellij.openapi.vfs.newvfs.events.VFileEvent in project android by JetBrains.
the class CapturesToolWindow method after.
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
CaptureService service = CaptureService.getInstance(myProject);
VirtualFile captures = service.getCapturesDirectory();
if (captures == null) {
if (!service.getCaptures().isEmpty()) {
queueUpdate();
}
return;
}
for (VFileEvent event : events) {
if (event.getFile() != null && VfsUtilCore.isAncestor(captures, event.getFile(), false)) {
queueUpdate();
return;
}
}
}
Aggregations