From 89f4853a3bed7009b82783c669ada30ab54bd6ac Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 24 Oct 2013 15:45:06 +0200 Subject: [PATCH] inline RootIndex.initialize --- .../openapi/roots/impl/RootIndex.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootIndex.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootIndex.java index ec3894c89774..1047e66215d6 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootIndex.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/RootIndex.java @@ -41,7 +41,6 @@ import java.util.*; class RootIndex { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.RootIndex"); - private final Project myProject; private final Set myProjectExcludedRoots = ContainerUtil.newHashSet(); private final Set myLibraryExcludedRoots = ContainerUtil.newHashSet(); @@ -52,37 +51,12 @@ class RootIndex { private final List> myRootTypes = ContainerUtil.newArrayList(); private final TObjectIntHashMap> myRootTypeId = new TObjectIntHashMap>(); - public RootIndex(@NotNull final Project project) { - myProject = project; - - initialize(); - } - - public void checkConsistency() { - for (VirtualFile file : myProjectExcludedRoots) { - assert file.exists() : file.getPath() + " does not exist"; - } - for (VirtualFile file : myLibraryExcludedRoots) { - assert file.exists() : file.getPath() + " does not exist"; - } - - for (VirtualFile file : myRoots.keySet()) { - assert file.exists() : file.getPath() + " does not exist"; - } - - for (HashSet virtualFiles : myPackagePrefixRoots.values()) { - for (VirtualFile file : virtualFiles) { - assert file.exists() : file.getPath() + " does not exist"; - } - } - } - - public void initialize() { + RootIndex(@NotNull final Project project) { final MultiMap depEntries = new MultiMap(); final MultiMap libClassRootEntries = new MultiMap(); final MultiMap libSourceRootEntries = new MultiMap(); - for (final Module module : ModuleManager.getInstance(myProject).getModules()) { + for (final Module module : ModuleManager.getInstance(project).getModules()) { final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries(); final ContentEntry[] contentEntries = moduleRootManager.getContentEntries(); @@ -151,7 +125,7 @@ class RootIndex { final LibraryOrSdkOrderEntry entry = (LibraryOrSdkOrderEntry)orderEntry; final VirtualFile[] sourceRoots = entry.getRootFiles(OrderRootType.SOURCES); final VirtualFile[] classRoots = entry.getRootFiles(OrderRootType.CLASSES); - + // init library classes for (final VirtualFile classRoot : classRoots) { libClassRootEntries.putValue(classRoot, orderEntry); @@ -184,7 +158,7 @@ class RootIndex { } } - for (DirectoryIndexExcludePolicy policy : Extensions.getExtensions(DirectoryIndexExcludePolicy.EP_NAME, myProject)) { + for (DirectoryIndexExcludePolicy policy : Extensions.getExtensions(DirectoryIndexExcludePolicy.EP_NAME, project)) { Collections.addAll(myProjectExcludedRoots, policy.getExcludeRootsForProject()); } @@ -200,6 +174,25 @@ class RootIndex { } } + public void checkConsistency() { + for (VirtualFile file : myProjectExcludedRoots) { + assert file.exists() : file.getPath() + " does not exist"; + } + for (VirtualFile file : myLibraryExcludedRoots) { + assert file.exists() : file.getPath() + " does not exist"; + } + + for (VirtualFile file : myRoots.keySet()) { + assert file.exists() : file.getPath() + " does not exist"; + } + + for (HashSet virtualFiles : myPackagePrefixRoots.values()) { + for (VirtualFile file : virtualFiles) { + assert file.exists() : file.getPath() + " does not exist"; + } + } + } + private int getRootTypeId(JpsModuleSourceRootType rootType) { if (myRootTypeId.containsKey(rootType)) { return myRootTypeId.get(rootType);