diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java index 1b113d01ebb8..33b2495a0364 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java @@ -24,7 +24,7 @@ import com.intellij.openapi.roots.RootProvider; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; -import com.intellij.util.Function; +import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -37,7 +37,6 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.LibraryOrderEntryBaseImpl"); protected final ProjectRootManagerImpl myProjectRootManagerImpl; @NotNull protected DependencyScope myScope = DependencyScope.COMPILE; - private final MyRootSetChangedListener myRootSetChangedListener = new MyRootSetChangedListener(); private RootProvider myCurrentlySubscribedRootProvider = null; LibraryOrderEntryBaseImpl(RootModelImpl rootModel, ProjectRootManagerImpl instanceImpl) { @@ -92,7 +91,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl { } protected VirtualFile[] filterDirectories(VirtualFile[] files) { - List filtered = ContainerUtil.mapNotNull(files, new Function() { + List filtered = ContainerUtil.mapNotNull(files, new NullableFunction() { public VirtualFile fun(VirtualFile file) { return file.isDirectory() ? file : null; } @@ -128,37 +127,19 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl { private void subscribe(RootProvider wrapper) { if (wrapper != null) { - addListenerToWrapper(wrapper, myRootSetChangedListener); + myProjectRootManagerImpl.subscribeToRootProvider(this, wrapper); } myCurrentlySubscribedRootProvider = wrapper; } - private void addListenerToWrapper(final RootProvider wrapper, - final RootProvider.RootSetChangedListener rootSetChangedListener) { - myProjectRootManagerImpl.addRootSetChangedListener(rootSetChangedListener, wrapper); - } - private void unsubscribe() { if (myCurrentlySubscribedRootProvider != null) { - final RootProvider wrapper = myCurrentlySubscribedRootProvider; - removeListenerFromWrapper(wrapper, myRootSetChangedListener); + myProjectRootManagerImpl.unsubscribeFromRootProvider(this, myCurrentlySubscribedRootProvider); } myCurrentlySubscribedRootProvider = null; } - protected void removeListenerFromWrapper(final RootProvider wrapper, - final RootProvider.RootSetChangedListener rootSetChangedListener) { - myProjectRootManagerImpl.removeRootSetChangedListener(rootSetChangedListener, wrapper); - } - - - private class MyRootSetChangedListener implements RootProvider.RootSetChangedListener { - public void rootSetChanged(RootProvider wrapper) { - updateFromRootProviderAndSubscribe(); - } - } - @Override public void dispose() { unsubscribe();