mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
added OrderEnumerator for collection of modules
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
@@ -24,6 +25,8 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Allows to query and modify the list of root directories belonging to a project.
|
||||
*/
|
||||
@@ -84,6 +87,14 @@ public abstract class ProjectRootManager implements ModificationTracker {
|
||||
@NotNull
|
||||
public abstract OrderEnumerator orderEntries();
|
||||
|
||||
/**
|
||||
* Creates new enumerator instance to process dependencies of several modules in the project. Caching is not supported for this enumerator
|
||||
* @param modules modules to process
|
||||
* @return new enumerator instance
|
||||
*/
|
||||
@NotNull
|
||||
public abstract OrderEnumerator orderEntries(@NotNull Collection<? extends Module> modules);
|
||||
|
||||
/**
|
||||
* Unlike getContentRoots(), this includes the project base dir. Is this really necessary?
|
||||
* TODO: remove this method?
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.util.Processor;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModulesOrderEnumerator extends OrderEnumeratorBase {
|
||||
private Collection<? extends Module> myModules;
|
||||
|
||||
public ModulesOrderEnumerator(@NotNull Project project, @NotNull Collection<? extends Module> modules) {
|
||||
super(null, project, null);
|
||||
myModules = modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(@NotNull Processor<OrderEntry> processor) {
|
||||
myRecursivelyExportedOnly = false;
|
||||
final THashSet<Module> processed = new THashSet<Module>();
|
||||
for (Module module : myModules) {
|
||||
processEntries(getRootModel(module), processor, processed, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,11 +48,11 @@ abstract class OrderEnumeratorBase extends OrderEnumerator {
|
||||
protected boolean myWithoutDepModules;
|
||||
private boolean myWithoutThisModuleContent;
|
||||
protected boolean myRecursively;
|
||||
private boolean myRecursivelyExportedOnly;
|
||||
protected boolean myRecursivelyExportedOnly;
|
||||
private boolean myExportedOnly;
|
||||
private Condition<OrderEntry> myCondition;
|
||||
private List<OrderEnumerationHandler> myCustomHandlers;
|
||||
private ModulesProvider myModulesProvider;
|
||||
protected ModulesProvider myModulesProvider;
|
||||
private OrderRootsCache myCache;
|
||||
|
||||
public OrderEnumeratorBase(@Nullable Module module, @NotNull Project project, @Nullable OrderRootsCache cache) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.openapi.roots.impl;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.util.Processor;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -40,8 +39,9 @@ public class ProjectOrderEnumerator extends OrderEnumeratorBase {
|
||||
myRecursively = false;
|
||||
myWithoutDepModules = true;
|
||||
final THashSet<Module> processed = new THashSet<Module>();
|
||||
for (Module module : ModuleManager.getInstance(myProject).getSortedModules()) {
|
||||
processEntries(ModuleRootManager.getInstance(module), processor, processed, true);
|
||||
final Module[] modules = myModulesProvider != null ? myModulesProvider.getModules() : ModuleManager.getInstance(myProject).getSortedModules();
|
||||
for (Module module : modules) {
|
||||
processEntries(getRootModel(module), processor, processed, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,11 +305,18 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
return VfsUtil.toVirtualFileArray(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OrderEnumerator orderEntries() {
|
||||
return new ProjectOrderEnumerator(myProject, myRootsCache);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OrderEnumerator orderEntries(@NotNull Collection<? extends Module> modules) {
|
||||
return new ModulesOrderEnumerator(myProject, modules);
|
||||
}
|
||||
|
||||
public VirtualFile[] getContentRootsFromAllModules() {
|
||||
List<VirtualFile> result = new ArrayList<VirtualFile>();
|
||||
final Module[] modules = getModuleManager().getSortedModules();
|
||||
|
||||
+1
@@ -97,6 +97,7 @@ public abstract class StubProjectRootManagerEx extends ProjectRootManagerEx {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OrderEnumerator orderEntries() {
|
||||
throw new UnsupportedOperationException("'orderEntries' not implemented in " + getClass().getName());
|
||||
|
||||
Reference in New Issue
Block a user