split JarDirectoryWatcher into interface, implementation and factory; remove cyclic dependencies of projectModel-impl

This commit is contained in:
Dmitry Jemerov
2012-05-17 13:57:19 +02:00
parent 639e684513
commit f2a1bc8112
7 changed files with 102 additions and 6 deletions
@@ -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);
}
}
@@ -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<LocalFileSystem.WatchRequest> 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()) {
@@ -168,6 +168,9 @@
<applicationService serviceInterface="com.intellij.openapi.fileEditor.UniqueVFilePathBuilder"
serviceImplementation="com.intellij.openapi.fileEditor.impl.UniqueVFilePathBuilderImpl"/>
<applicationService serviceInterface="com.intellij.openapi.roots.impl.libraries.JarDirectoryWatcherFactory"
serviceImplementation="com.intellij.openapi.roots.impl.libraries.JarDirectoryWatcherFactoryImpl"/>
<projectService serviceInterface="com.intellij.ui.EditorTextFieldProvider"
serviceImplementation="com.intellij.ui.EditorTextFieldProviderImpl"/>
@@ -8,8 +8,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="projectModel-api" exported="" />
<orderEntry type="module" module-name="lang-impl" exported="" />
<orderEntry type="module" module-name="platform-api" exported="" />
</component>
</module>
@@ -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();
}
@@ -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() {
}
};
}
}
@@ -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;