VirtualFilePointerContainer (@NotNull Disposable parent, @NotNull VirtualFilePointerContainerImpl container) { synchronized (myContainers) { myContainers.add(container); } Disposer.register(parent, new Disposable() { @Override public void dispose() { Disposer.dispose(container); boolean removed; synchronized (myContainers) { removed = myContainers.remove(container); } if (!IS_UNDER_UNIT_TEST) { assert removed; } } @Override public String toString() { return "Disposing container " + container; } }); return container; }