@Override public void disposeComponent() { ApplicationManager.getApplication().assertWriteAccessAllowed(); Disposer.dispose(myChangedFilesAlarm); if (myDefaultProject != null) { Disposer.dispose(myDefaultProject); myDefaultProject = null; myDefaultProjectWasDisposed = true; } }
@NotNull private VirtualFilePointerContainer registerContainer( @NotNull Disposable parent, @NotNull final VirtualFilePointerContainerImpl virtualFilePointerContainer) { synchronized (myContainers) { myContainers.add(virtualFilePointerContainer); } Disposer.register( parent, new Disposable() { @Override public void dispose() { Disposer.dispose(virtualFilePointerContainer); boolean removed; synchronized (myContainers) { removed = myContainers.remove(virtualFilePointerContainer); } if (!ApplicationManager.getApplication().isUnitTestMode()) { assert removed; } } @Override @NonNls @NotNull public String toString() { return "Disposing container " + virtualFilePointerContainer; } }); return virtualFilePointerContainer; }
static void registerDisposable(Disposable parentDisposable, VirtualFilePointerImpl pointer) { synchronized (ourInstances) { DelegatingDisposable result = ourInstances.get(parentDisposable); if (result == null) { ourInstances.put(parentDisposable, result = new DelegatingDisposable(parentDisposable)); Disposer.register(parentDisposable, result); } result.myCounts.put(pointer, result.myCounts.get(pointer) + 1); } }
@Override public void addProjectManagerListener( @NotNull final ProjectManagerListener listener, @NotNull Disposable parentDisposable) { addProjectManagerListener(listener); Disposer.register( parentDisposable, new Disposable() { @Override public void dispose() { removeProjectManagerListener(listener); } }); }
static void registerDisposable( @NotNull Disposable parentDisposable, @NotNull VirtualFilePointerImpl pointer) { DelegatingDisposable result = ourInstances.get(parentDisposable); if (result == null) { DelegatingDisposable newDisposable = new DelegatingDisposable(parentDisposable); result = ConcurrencyUtil.cacheOrGet(ourInstances, parentDisposable, newDisposable); if (result == newDisposable) { Disposer.register(parentDisposable, result); } } synchronized (result) { result.myCounts.put(pointer, result.myCounts.get(pointer) + 1); } }