This commit is contained in:
Alexey Kudravtsev
2012-03-12 20:08:04 +04:00
parent 1d90430ff0
commit dafec55bd6
@@ -27,7 +27,6 @@ import com.intellij.util.ArrayUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -38,9 +37,9 @@ 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;
@Nullable private RootProvider myCurrentlySubscribedRootProvider = null;
private RootProvider myCurrentlySubscribedRootProvider = null;
LibraryOrderEntryBaseImpl(@NotNull RootModelImpl rootModel, @NotNull ProjectRootManagerImpl instanceImpl) {
LibraryOrderEntryBaseImpl(RootModelImpl rootModel, ProjectRootManagerImpl instanceImpl) {
super(rootModel);
myProjectRootManagerImpl = instanceImpl;
}
@@ -49,65 +48,65 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
updateFromRootProviderAndSubscribe();
}
@Override
@NotNull
public VirtualFile[] getFiles(@NotNull OrderRootType type) {
public VirtualFile[] getFiles(OrderRootType type) {
if (type == OrderRootType.COMPILATION_CLASSES) {
return getRootFiles(OrderRootType.CLASSES);
}
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
else if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
if (!myScope.isForProductionCompile()) {
return VirtualFile.EMPTY_ARRAY;
}
return getRootFiles(OrderRootType.CLASSES);
}
else if (type == OrderRootType.CLASSES_AND_OUTPUT) {
return myScope == DependencyScope.PROVIDED ? VirtualFile.EMPTY_ARRAY : getRootFiles(OrderRootType.CLASSES);
}
return getRootFiles(type);
}
@Override
@NotNull
public String[] getUrls(@NotNull OrderRootType type) {
public String[] getUrls(OrderRootType type) {
LOG.assertTrue(!getRootModel().getModule().isDisposed());
RootProvider rootProvider = getRootProvider();
if (rootProvider == null) return ArrayUtil.EMPTY_STRING_ARRAY;
if (type == OrderRootType.COMPILATION_CLASSES) {
return rootProvider.getUrls(OrderRootType.CLASSES);
}
if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
else if (type == OrderRootType.PRODUCTION_COMPILATION_CLASSES) {
if (!myScope.isForProductionCompile()) {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
return rootProvider.getUrls(OrderRootType.CLASSES);
}
else if (type == OrderRootType.CLASSES_AND_OUTPUT) {
return myScope == DependencyScope.PROVIDED ? ArrayUtil.EMPTY_STRING_ARRAY : rootProvider.getUrls(OrderRootType.CLASSES);
}
return rootProvider.getUrls(type);
}
public VirtualFile[] getRootFiles(@NotNull OrderRootType type) {
public VirtualFile[] getRootFiles(OrderRootType type) {
RootProvider rootProvider = getRootProvider();
return rootProvider == null ? VirtualFile.EMPTY_ARRAY : filterDirectories(rootProvider.getFiles(type));
}
protected VirtualFile[] filterDirectories(@NotNull VirtualFile[] files) {
protected VirtualFile[] filterDirectories(VirtualFile[] files) {
List<VirtualFile> filtered = ContainerUtil.mapNotNull(files, new NullableFunction<VirtualFile, VirtualFile>() {
@Override
public VirtualFile fun(@NotNull VirtualFile file) {
public VirtualFile fun(VirtualFile file) {
return file.isDirectory() ? file : null;
}
});
return VfsUtil.toVirtualFileArray(filtered);
}
@Nullable
protected abstract RootProvider getRootProvider();
@NotNull
@SuppressWarnings({"UnusedDeclaration"})
public String[] getRootUrls(@NotNull OrderRootType type) {
public String[] getRootUrls(OrderRootType type) {
RootProvider rootProvider = getRootProvider();
return rootProvider == null ? ArrayUtil.EMPTY_STRING_ARRAY : rootProvider.getUrls(type);
}
@Override
@NotNull
public final Module getOwnerModule() {
return getRootModel().getModule();
@@ -115,7 +114,6 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
protected void updateFromRootProviderAndSubscribe() {
getRootModel().makeExternalChange(new Runnable() {
@Override
public void run() {
resubscribe(getRootProvider());
}
@@ -127,7 +125,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl {
subscribe(wrapper);
}
private void subscribe(@Nullable RootProvider wrapper) {
private void subscribe(RootProvider wrapper) {
if (wrapper != null) {
myProjectRootManagerImpl.subscribeToRootProvider(this, wrapper);
}