use of com.intellij.openapi.vfs.impl.ArchiveHandler in project intellij-community by JetBrains.
the class JrtFileSystemImpl method getHandler.
@NotNull
@Override
protected ArchiveHandler getHandler(@NotNull VirtualFile entryFile) {
checkSubscription();
String homePath = extractLocalPath(extractRootPath(entryFile.getPath()));
ArchiveHandler handler = myHandlers.get(homePath);
if (handler == null) {
handler = new JrtHandler(homePath);
myHandlers.put(homePath, handler);
ApplicationManager.getApplication().invokeLater(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(homePath + "/release"), ModalityState.defaultModalityState());
}
return handler;
}
use of com.intellij.openapi.vfs.impl.ArchiveHandler 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.impl.ArchiveHandler in project intellij-community by JetBrains.
the class VfsImplUtil method getHandler.
@NotNull
public static <T extends ArchiveHandler> T getHandler(@NotNull ArchiveFileSystem vfs, @NotNull String localPath, @NotNull Function<String, T> producer) {
checkSubscription();
ArchiveHandler handler;
synchronized (ourLock) {
Pair<ArchiveFileSystem, ArchiveHandler> record = ourHandlers.get(localPath);
if (record == null) {
handler = producer.fun(localPath);
record = Pair.create(vfs, handler);
ourHandlers.put(localPath, record);
final String finalRootPath = localPath;
forEachDirectoryComponent(localPath, containingDirectoryPath -> {
Set<String> handlers = ourDominatorsMap.get(containingDirectoryPath);
if (handlers == null) {
ourDominatorsMap.put(containingDirectoryPath, handlers = ContainerUtil.newTroveSet());
}
handlers.add(finalRootPath);
});
}
handler = record.second;
}
@SuppressWarnings("unchecked") T t = (T) handler;
return t;
}
Aggregations