From f2a1bc811233dfa84e20a1974972bc029aa020be Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 17 May 2012 13:57:19 +0200 Subject: [PATCH] split JarDirectoryWatcher into interface, implementation and factory; remove cyclic dependencies of projectModel-impl --- .../JarDirectoryWatcherFactoryImpl.java | 28 +++++++++++++ ...cher.java => JarDirectoryWatcherImpl.java} | 6 +-- .../src/META-INF/LangExtensions.xml | 3 ++ .../projectModel-impl/projectModel-impl.iml | 2 - .../impl/libraries/JarDirectoryWatcher.java | 25 +++++++++++ .../libraries/JarDirectoryWatcherFactory.java | 41 +++++++++++++++++++ .../roots/impl/libraries/LibraryImpl.java | 3 +- 7 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactoryImpl.java rename platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/{JarDirectoryWatcher.java => JarDirectoryWatcherImpl.java} (97%) create mode 100644 platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java create mode 100644 platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactory.java diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactoryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactoryImpl.java new file mode 100644 index 000000000000..8df3683ec528 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactoryImpl.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.impl.libraries; + +import com.intellij.openapi.roots.impl.RootProviderBaseImpl; + +/** + * @author yole + */ +public class JarDirectoryWatcherFactoryImpl extends JarDirectoryWatcherFactory { + @Override + public JarDirectoryWatcher createWatcher(JarDirectories jarDirectories, RootProviderBaseImpl rootProvider) { + return new JarDirectoryWatcherImpl(jarDirectories, rootProvider); + } +} diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java similarity index 97% rename from platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java rename to platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java index 04c562b01fe2..a0b9b4a42731 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherImpl.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.roots.impl.libraries; -import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.impl.RootProviderBaseImpl; @@ -33,17 +32,18 @@ import java.util.*; /** * @author ksafonov */ -public class JarDirectoryWatcher implements Disposable { +public class JarDirectoryWatcherImpl implements JarDirectoryWatcher { private final JarDirectories myJarDirectories; private final RootProviderBaseImpl myRootProvider; private MessageBusConnection myBusConnection = null; private Collection myWatchRequests = Collections.emptySet(); - public JarDirectoryWatcher(JarDirectories jarDirectories, RootProviderBaseImpl rootProvider) { + public JarDirectoryWatcherImpl(JarDirectories jarDirectories, RootProviderBaseImpl rootProvider) { myJarDirectories = jarDirectories; myRootProvider = rootProvider; } + @Override public void updateWatchedRoots() { final LocalFileSystem fs = LocalFileSystem.getInstance(); if (!myJarDirectories.isEmpty()) { diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index ff268fe07ccc..14f36537edae 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -168,6 +168,9 @@ + + diff --git a/platform/projectModel-impl/projectModel-impl.iml b/platform/projectModel-impl/projectModel-impl.iml index d2fbf8188c3c..3805bfde7570 100644 --- a/platform/projectModel-impl/projectModel-impl.iml +++ b/platform/projectModel-impl/projectModel-impl.iml @@ -8,8 +8,6 @@ - - diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java new file mode 100644 index 000000000000..8a5c02cd708b --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcher.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.impl.libraries; + +import com.intellij.openapi.Disposable; + +/** + * @author yole + */ +public interface JarDirectoryWatcher extends Disposable { + void updateWatchedRoots(); +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactory.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactory.java new file mode 100644 index 000000000000..032f606ff846 --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/JarDirectoryWatcherFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.roots.impl.libraries; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.roots.impl.RootProviderBaseImpl; + +/** + * @author yole + */ +public class JarDirectoryWatcherFactory { + public static JarDirectoryWatcherFactory getInstance() { + final JarDirectoryWatcherFactory factory = ServiceManager.getService(JarDirectoryWatcherFactory.class); + return factory != null ? factory : new JarDirectoryWatcherFactory(); + } + + public JarDirectoryWatcher createWatcher(JarDirectories jarDirectories, RootProviderBaseImpl rootProvider) { + return new JarDirectoryWatcher() { + @Override + public void updateWatchedRoots() { + } + + @Override + public void dispose() { + } + }; + } +} diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index f983e7329dc8..ed42a437fad9 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -73,7 +73,8 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { private final ModifiableRootModel myRootModel; private boolean myDisposed; private final Disposable myPointersDisposable = Disposer.newDisposable(); - private final JarDirectoryWatcher myRootsWatcher = new JarDirectoryWatcher(myJarDirectories, myRootProvider); + private final JarDirectoryWatcher myRootsWatcher = JarDirectoryWatcherFactory.getInstance().createWatcher(myJarDirectories, + myRootProvider); LibraryImpl(LibraryTable table, Element element, ModifiableRootModel rootModel) throws InvalidDataException { myLibraryTable = table;