private synchronized void assertAllPointersDisposed() { for (Map.Entry<VirtualFilePointerListener, FilePointerPartNode> entry : myPointers.entrySet()) { FilePointerPartNode root = entry.getValue(); ArrayList<FilePointerPartNode> left = new ArrayList<FilePointerPartNode>(); root.getPointersUnder(null, false, "", left); if (!left.isEmpty()) { VirtualFilePointerImpl p = left.get(0).leaf; try { p.throwDisposalError("Not disposed pointer: "+p); } finally { for (FilePointerPartNode pair : left) { VirtualFilePointerImpl pointer = pair.leaf; pointer.dispose(); } } } } synchronized (myContainers) { if (!myContainers.isEmpty()) { VirtualFilePointerContainerImpl container = myContainers.iterator().next(); container.throwDisposalError("Not disposed container"); } } }
private synchronized void assertAllPointersDisposed() { for (Map.Entry<VirtualFilePointerListener, FilePointerPartNode> entry : myPointers.entrySet()) { FilePointerPartNode root = entry.getValue(); ArrayList<FilePointerPartNode> left = new ArrayList<FilePointerPartNode>(); root.getPointersUnder("", 0, left); if (!left.isEmpty()) { VirtualFilePointerImpl p = left.get(0).leaf; try { p.throwDisposalError("Not disposed pointer: "+p); } finally { for (FilePointerPartNode pair : left) { VirtualFilePointerImpl pointer = pair.leaf; pointer.dispose(); } } } } synchronized (myContainers) { if (!myContainers.isEmpty()) { VirtualFilePointerContainerImpl container = myContainers.iterator().next(); container.throwDisposalError("Not disposed container"); } } }
@NotNull private VirtualFilePointerImpl getOrCreate(@NotNull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener, @NotNull String path, @NotNull Pair<VirtualFile, String> fileAndUrl) { FilePointerPartNode root = myPointers.get(listener); FilePointerPartNode node; if (root == null) { root = new FilePointerPartNode(path, null, fileAndUrl); myPointers.put(listener, root); node = root; } else { node = root.findPointerOrCreate(path, 0, fileAndUrl); } VirtualFilePointerImpl pointer; if (node.leaf == null) { pointer = new VirtualFilePointerImpl(listener, parentDisposable, fileAndUrl); node.associate(pointer, fileAndUrl); } else { pointer = node.leaf; } pointer.myNode.incrementUsageCount(1); root.checkConsistency(); return pointer; }
@Override @NotNull public synchronized VirtualFilePointer duplicate(@NotNull VirtualFilePointer pointer, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { VirtualFile file = pointer.getFile(); return file == null ? create(pointer.getUrl(), parent, listener) : create(file, parent, listener); }
void removeNode(@NotNull FilePointerPartNode node, VirtualFilePointerListener listener) { boolean rootNodeEmpty = node.remove(); if (rootNodeEmpty) { myPointers.remove(listener); } else { myPointers.get(listener).checkConsistency(); } }
private VirtualFilePointer createPointerByFile(final File file, final VirtualFilePointerListener fileListener) throws IOException { final String url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, file.getCanonicalPath().replace(File.separatorChar, '/')); final VirtualFile vFile = refreshAndFind(url); return vFile == null ? myVirtualFilePointerManager.create(url, disposable, fileListener) : myVirtualFilePointerManager.create(vFile, disposable, fileListener); }
@NotNull @Override public VirtualFilePointer duplicate(@NotNull VirtualFilePointer pointer, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return new IdentityVirtualFilePointer(pointer.getFile(), pointer.getUrl()); }
public VirtualFilePointerContainerImpl(@NotNull VirtualFilePointerManager manager, @NotNull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener) { //noinspection HardCodedStringLiteral super(TRACE_CREATION && !ApplicationInfoImpl.isInPerformanceTest() ? new Throwable("parent = '" + parentDisposable + "' (" + parentDisposable.getClass() + "); listener=" + listener) : null); myVirtualFilePointerManager = manager; myParent = parentDisposable; myListener = listener; }
@Override @NotNull public VirtualFilePointerContainer clone(@NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { assert !myDisposed; VirtualFilePointerContainer clone = myVirtualFilePointerManager.createContainer(parent, listener); for (VirtualFilePointer pointer : myList) { clone.add(pointer.getUrl()); } return clone; }
@NotNull private VirtualFilePointerImpl getOrCreate(@NotNull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener, @NotNull String path, @NotNull Pair<VirtualFile, String> fileAndUrl) { FilePointerPartNode root = myPointers.get(listener); FilePointerPartNode node; if (root == null) { root = new FilePointerPartNode(path, null, fileAndUrl); myPointers.put(listener, root); node = root; } else { node = root.findPointerOrCreate(path, 0, fileAndUrl); } VirtualFilePointerImpl pointer; if (node.leaf == null) { pointer = new VirtualFilePointerImpl(listener, parentDisposable, fileAndUrl); node.associate(pointer, fileAndUrl); } else { pointer = node.leaf; } pointer.myNode.incrementUsageCount(1); root.checkStructure(); return pointer; }
void removeNode(@NotNull FilePointerPartNode node, VirtualFilePointerListener listener) { boolean rootNodeEmpty = node.remove(); if (rootNodeEmpty) { myPointers.remove(listener); } else { myPointers.get(listener).checkStructure(); } }
public VirtualFilePointerContainerImpl(@NotNull VirtualFilePointerManager manager, @NotNull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener) { //noinspection HardCodedStringLiteral super(TRACE_CREATION ? new Throwable("parent = '" + parentDisposable + "' (" + parentDisposable.getClass() + "); listener=" + listener) : null); myVirtualFilePointerManager = manager; myParent = parentDisposable; myListener = listener; }
@Nonnull @Override public VirtualFilePointer duplicate(@Nonnull VirtualFilePointer pointer, @Nonnull Disposable parent, @Nullable VirtualFilePointerListener listener) { return new CompilerServerVirtualFilePointer(pointer.getUrl()); }
@Nonnull private VirtualFilePointerImpl getOrCreate(@Nonnull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener, @Nonnull String path, @Nonnull Pair<VirtualFile, String> fileAndUrl) { FilePointerPartNode root = myPointers.get(listener); FilePointerPartNode node; if (root == null) { root = new FilePointerPartNode(path, null, fileAndUrl); root.pointersUnder++; myPointers.put(listener, root); node = root; } else { node = root.findPointerOrCreate(path, 0, fileAndUrl, 1); } VirtualFilePointerImpl pointer = node.getAnyPointer(); if (pointer == null) { pointer = new VirtualFilePointerImpl(listener, parentDisposable, fileAndUrl); node.associate(pointer, fileAndUrl); } pointer.myNode.incrementUsageCount(1); root.checkConsistency(); return pointer; }
@Override @Nonnull public synchronized VirtualFilePointer duplicate(@Nonnull VirtualFilePointer pointer, @Nonnull Disposable parent, @Nullable VirtualFilePointerListener listener) { VirtualFile file = pointer.getFile(); return file == null ? create(pointer.getUrl(), parent, listener) : create(file, parent, listener); }
private synchronized void assertAllPointersDisposed() { for (Map.Entry<VirtualFilePointerListener, FilePointerPartNode> entry : myPointers.entrySet()) { FilePointerPartNode root = entry.getValue(); List<FilePointerPartNode> left = new ArrayList<FilePointerPartNode>(); List<VirtualFilePointerImpl> pointers = new ArrayList<VirtualFilePointerImpl>(); root.addPointersUnder(null, false, "", left); for (FilePointerPartNode node : left) { node.addAllPointersTo(pointers); } if (!pointers.isEmpty()) { VirtualFilePointerImpl p = pointers.get(0); try { p.throwDisposalError("Not disposed pointer: "+p); } finally { for (VirtualFilePointerImpl pointer : pointers) { pointer.dispose(); } } } } synchronized (myContainers) { if (!myContainers.isEmpty()) { VirtualFilePointerContainerImpl container = myContainers.iterator().next(); container.throwDisposalError("Not disposed container"); } } }
void removeNode(@Nonnull FilePointerPartNode node, VirtualFilePointerListener listener) { FilePointerPartNode root = node.remove(); boolean rootNodeEmpty = root.children.length == 0 ; if (rootNodeEmpty) { myPointers.remove(listener); } else { myPointers.get(listener).checkConsistency(); } }
@Nonnull @Override public VirtualFilePointer duplicate(@Nonnull VirtualFilePointer pointer, @Nonnull Disposable parent, @Nullable VirtualFilePointerListener listener) { return new IdentityVirtualFilePointer(pointer.getFile(), pointer.getUrl()); }
public VirtualFilePointerContainerImpl(@Nonnull VirtualFilePointerManager manager, @Nonnull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener) { //noinspection HardCodedStringLiteral super(TRACE_CREATION && !ApplicationInfoImpl.isInPerformanceTest()); myVirtualFilePointerManager = manager; myParent = parentDisposable; myListener = listener; }
@Override @Nonnull public VirtualFilePointerContainer clone(@Nonnull Disposable parent, @Nullable VirtualFilePointerListener listener) { assert !myDisposed; VirtualFilePointerContainer clone = myVirtualFilePointerManager.createContainer(parent, listener); for (VirtualFilePointer pointer : myList) { clone.add(pointer.getUrl()); } return clone; }
VirtualFilePointerImpl(VirtualFilePointerListener listener, @NotNull Disposable parentDisposable, Pair<VirtualFile, String> fileAndUrl) { super(TRACE_CREATION ? new Throwable("parent = '" + parentDisposable + "' (" + parentDisposable.getClass() + "); URL="+fileAndUrl) : null); myListener = listener; }
VirtualFilePointerListener getListener() { return myListener; }
private EventDescriptor(@NotNull VirtualFilePointerListener listener, @NotNull VirtualFilePointer[] pointers) { myListener = listener; myPointers = pointers; }
@Override @NotNull public synchronized VirtualFilePointer create(@NotNull String url, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return create(null, url, parent, listener); }
@Override @NotNull public synchronized VirtualFilePointer create(@NotNull VirtualFile file, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return create(file, null, parent, listener); }
@Override @NotNull public synchronized VirtualFilePointerContainer createContainer(@NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return registerContainer(parent, new VirtualFilePointerContainerImpl(this, parent, listener)); }
@NotNull @Override public VirtualFilePointer create(@NotNull String url, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url); return new IdentityVirtualFilePointer(vFile, url); }
@NotNull @Override public VirtualFilePointer create(@NotNull VirtualFile file, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return new IdentityVirtualFilePointer(file, file.getUrl()); }
@NotNull @Override public VirtualFilePointerContainer createContainer(@NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return new VirtualFilePointerContainerImpl(this, parent, listener); }
@Override @NotNull public synchronized VirtualFilePointer create(@NotNull VirtualFile file, @NotNull Disposable parent, @Nullable VirtualFilePointerListener listener) { return create(file, file.getUrl(), parent, listener); }