Commit 47d96d10 authored by Dmitry Trofimov's avatar Dmitry Trofimov Committed by Mikhail Golubev
Browse files

Filter should accept roots

parent 21c65b39
Branches unavailable Tags unavailable
No related merge requests found
Showing with 32 additions and 24 deletions
+32 -24
......@@ -3,7 +3,6 @@
package com.intellij.util.indexing;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.intellij.AppTopics;
import com.intellij.history.LocalHistory;
import com.intellij.ide.plugins.PluginManager;
......@@ -38,7 +37,10 @@ import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileWithId;
import com.intellij.openapi.vfs.newvfs.ManagingFS;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
......@@ -95,8 +97,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static com.intellij.util.FileContentUtilCore.reparseFiles;
/**
* @author Eugene Zhuravlev
*/
......@@ -280,21 +280,6 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
}
}
//TODO: move to a better place
public void forceReindex(VirtualFile file) {
List<VirtualFile> filesToReindex = Lists.newArrayList();
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
filesToReindex.add(file);
return true;
}
});
reparseFiles(filesToReindex);
}
boolean processChangedFiles(@NotNull Project project, @NotNull Processor<? super VirtualFile> processor) {
// avoid missing files when events are processed concurrently
return Stream.concat(myChangedFilesCollector.myVfsEventsMerger.getChangedFiles(),
......
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.indexing
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.ProjectComponent
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.roots.*
import com.intellij.openapi.roots.ex.ProjectRootManagerEx
import com.intellij.openapi.vfs.VfsUtil
import com.intellij.openapi.vfs.VirtualFile
......@@ -14,6 +16,7 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
val rootsToIndex = HashSet<VirtualFile>()
fun updateNames(names: Collection<String>) {
var flag = false
for (name in names) {
if (!nameSet.contains(name)) {
......@@ -23,16 +26,20 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
val libFile = canonicalFile.findChild(name)
if (libFile != null) {
rootsToIndex.add(libFile)
(FileBasedIndex.getInstance() as FileBasedIndexImpl).forceReindex(libFile)
flag = true
}
}
}
}
}
nameSet.clear()
nameSet.addAll(names)
if (flag) {
ApplicationManager.getApplication().invokeLater {
ProjectRootManagerEx.getInstanceEx(project).makeRootsChange({}, false, true)
}
}
}
fun isUnusedLibrary(file: VirtualFile): Boolean {
......@@ -40,6 +47,22 @@ class IndexLibraryManager(val project: Project) : ProjectComponent {
return false
}
for (module in ModuleManager.getInstance(project).modules) {
val orderEntries = ModuleRootManager.getInstance(module).orderEntries
for (orderEntry in orderEntries) {
if (orderEntry is LibraryOrSdkOrderEntry) {
if (orderEntry.isValid()) {
for (root in orderEntry.getRootFiles(OrderRootType.SOURCES) +
orderEntry.getRootFiles(OrderRootType.CLASSES)) {
if (root == file) {
return false
}
}
}
}
}
}
for (root in rootsToIndex) {
if (VfsUtil.isAncestor(root, file, false)) {
return false
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment