mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RootIndex: cache non-existent packages (IDEA-127942)
This commit is contained in:
@@ -25,13 +25,16 @@ import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.CollectionQuery;
|
||||
import com.intellij.util.EmptyQuery;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.ConcurrentHashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
@@ -62,11 +65,20 @@ public class RootIndex {
|
||||
};
|
||||
|
||||
private final Map<String, List<VirtualFile>> myDirectoriesByPackageNameCache = ContainerUtil.newConcurrentMap();
|
||||
private final Set<String> myNonExistentPackages = new ConcurrentHashSet<String>();
|
||||
private final InfoCache myInfoCache;
|
||||
private final List<JpsModuleSourceRootType<?>> myRootTypes = ContainerUtil.newArrayList();
|
||||
private final TObjectIntHashMap<JpsModuleSourceRootType<?>> myRootTypeId = new TObjectIntHashMap<JpsModuleSourceRootType<?>>();
|
||||
@NotNull private final Project myProject;
|
||||
private volatile Map<VirtualFile, OrderEntry[]> myOrderEntries;
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private final LowMemoryWatcher myLowMemoryWatcher = LowMemoryWatcher.register(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myNonExistentPackages.clear();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// made public for Upsource
|
||||
public RootIndex(@NotNull Project project, @NotNull InfoCache cache) {
|
||||
@@ -321,6 +333,8 @@ public class RootIndex {
|
||||
public Query<VirtualFile> getDirectoriesByPackageName(@NotNull final String packageName, final boolean includeLibrarySources) {
|
||||
List<VirtualFile> result = myDirectoriesByPackageNameCache.get(packageName);
|
||||
if (result == null) {
|
||||
if (myNonExistentPackages.contains(packageName)) return EmptyQuery.getEmptyQuery();
|
||||
|
||||
result = ContainerUtil.newSmartList();
|
||||
|
||||
if (StringUtil.isNotEmpty(packageName) && !StringUtil.startsWithChar(packageName, '.')) {
|
||||
@@ -348,6 +362,8 @@ public class RootIndex {
|
||||
|
||||
if (!result.isEmpty()) {
|
||||
myDirectoriesByPackageNameCache.put(packageName, result);
|
||||
} else {
|
||||
myNonExistentPackages.add(packageName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user