mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileBasedIndex
This commit is contained in:
committed by
Evgeny Pasynkov
parent
12ff84822a
commit
fcdf45c29d
@@ -21,6 +21,7 @@ import com.intellij.psi.search.UsageSearchContext;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -35,9 +36,8 @@ public class IdCacheTest extends CodeInsightTestCase{
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
fileBasedIndex.requestRebuild(IdIndex.NAME);
|
||||
fileBasedIndex.requestRebuild(TodoIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(TodoIndex.NAME);
|
||||
|
||||
String root = JavaTestUtil.getJavaTestDataPath()+ "/psi/impl/cache/";
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
@@ -55,8 +56,8 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
FileBasedIndex.requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.requestRebuild(TodoIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(IdIndex.NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(TodoIndex.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -502,8 +502,7 @@ public class FindInProjectUtil {
|
||||
if (!keys.isEmpty()) {
|
||||
fast = true;
|
||||
List<VirtualFile> hits = new ArrayList<VirtualFile>();
|
||||
FileBasedIndex.getInstance()
|
||||
.getFilesWithKey(TrigramIndex.INDEX_ID, keys, new CommonProcessors.CollectProcessor<VirtualFile>(hits), scope);
|
||||
FileBasedIndex.getInstance().getFilesWithKey(TrigramIndex.INDEX_ID, keys, new CommonProcessors.CollectProcessor<VirtualFile>(hits), scope);
|
||||
|
||||
for (VirtualFile hit : hits) {
|
||||
resultFiles.add(pm.findFile(hit));
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ public class IdTableBuilding {
|
||||
final OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
EditorHighlighter highlighter;
|
||||
|
||||
final EditorHighlighter editorHighlighter = inputData.getUserData(FileBasedIndex.EDITOR_HIGHLIGHTER);
|
||||
final EditorHighlighter editorHighlighter = inputData.getUserData(FileBasedIndexImpl.EDITOR_HIGHLIGHTER);
|
||||
if (editorHighlighter != null && checkCanUseCachedEditorHighlighter(chars, editorHighlighter)) {
|
||||
highlighter = editorHighlighter;
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
messageBus.connect().subscribe(IndexPatternProvider.INDEX_PATTERNS_CHANGED, new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
FileBasedIndex.requestRebuild(NAME);
|
||||
FileBasedIndex.getInstance().requestRebuild(NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
@NotNull final Project project,
|
||||
@Nullable final GlobalSearchScope scope,
|
||||
@NotNull final Processor<? super Psi> processor) {
|
||||
final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
|
||||
final FileBasedIndexImpl fileBasedIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance();
|
||||
fileBasedIndex.ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, scope);
|
||||
|
||||
final PersistentFS fs = (PersistentFS)ManagingFS.getInstance();
|
||||
@@ -211,11 +211,11 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
try {
|
||||
try {
|
||||
// disable up-to-date check to avoid locks on attempt to acquire index write lock while holding at the same time the readLock for this index
|
||||
FileBasedIndex.disableUpToDateCheckForCurrentThread();
|
||||
FileBasedIndexImpl.disableUpToDateCheckForCurrentThread();
|
||||
index.getReadLock().lock();
|
||||
final ValueContainer<TIntArrayList> container = index.getData(key);
|
||||
|
||||
final FileBasedIndex.ProjectIndexableFilesFilter projectFilesFilter = fileBasedIndex.projectIndexableFiles(project);
|
||||
final FileBasedIndexImpl.ProjectIndexableFilesFilter projectFilesFilter = fileBasedIndex.projectIndexableFiles(project);
|
||||
|
||||
return container.forEach(new ValueContainer.ContainerAction<TIntArrayList>() {
|
||||
@Override
|
||||
@@ -320,14 +320,14 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
}
|
||||
finally {
|
||||
index.getReadLock().unlock();
|
||||
FileBasedIndex.enableUpToDateCheckForCurrentThread();
|
||||
FileBasedIndexImpl.enableUpToDateCheckForCurrentThread();
|
||||
}
|
||||
}
|
||||
catch (StorageException e) {
|
||||
forceRebuild(e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = FileBasedIndex.getCauseToRebuildIndex(e);
|
||||
final Throwable cause = FileBasedIndexImpl.getCauseToRebuildIndex(e);
|
||||
if (cause != null) {
|
||||
forceRebuild(cause);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
}
|
||||
|
||||
private static void requestRebuild() {
|
||||
FileBasedIndex.requestRebuild(StubUpdatingIndex.INDEX_ID);
|
||||
FileBasedIndex.getInstance().requestRebuild(StubUpdatingIndex.INDEX_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -232,7 +232,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
FileBasedIndex.requestRebuild(INDEX_ID);
|
||||
FileBasedIndex.getInstance().requestRebuild(INDEX_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -42,12 +42,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FileBasedIndexProjectHandler extends AbstractProjectComponent implements IndexableFileSet {
|
||||
private final FileBasedIndex myIndex;
|
||||
private final FileBasedIndexImpl myIndex;
|
||||
private final ProjectRootManagerEx myRootManager;
|
||||
private final FileTypeManager myFileTypeManager;
|
||||
private final ProjectFileExclusionManagerImpl myExclusionManager;
|
||||
|
||||
public FileBasedIndexProjectHandler(final FileBasedIndex index, final Project project, final ProjectRootManagerEx rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
|
||||
public FileBasedIndexProjectHandler(final FileBasedIndexImpl index, final Project project, final ProjectRootManagerEx rootManager, FileTypeManager ftManager, final ProjectManager projectManager) {
|
||||
super(project);
|
||||
myIndex = index;
|
||||
myRootManager = rootManager;
|
||||
|
||||
@@ -33,11 +33,11 @@ import java.util.List;
|
||||
*/
|
||||
public class UnindexedFilesUpdater implements CacheUpdater {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.util.indexing.UnindexedFilesUpdater");
|
||||
private final FileBasedIndex myIndex;
|
||||
private final FileBasedIndexImpl myIndex;
|
||||
private final Project myProject;
|
||||
private long myStarted;
|
||||
|
||||
public UnindexedFilesUpdater(final Project project, FileBasedIndex index) {
|
||||
public UnindexedFilesUpdater(final Project project, FileBasedIndexImpl index) {
|
||||
myIndex = index;
|
||||
myProject = project;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class UnindexedFilesUpdater implements CacheUpdater {
|
||||
public VirtualFile[] queryNeededFiles(ProgressIndicator indicator) {
|
||||
CollectingContentIterator finder = myIndex.createContentIterator();
|
||||
long l = System.currentTimeMillis();
|
||||
FileBasedIndex.iterateIndexableFiles(finder, myProject, indicator);
|
||||
FileBasedIndexImpl.iterateIndexableFiles(finder, myProject, indicator);
|
||||
LOG.info("Indexable files iterated in " + (System.currentTimeMillis() - l) + " ms");
|
||||
List<VirtualFile> files = finder.getFiles();
|
||||
LOG.info("Unindexed files update started: " + files.size() + " files to update");
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<implementation-class>com.intellij.util.indexing.FileBasedIndex</implementation-class>
|
||||
<interface-class>com.intellij.util.indexing.FileBasedIndex</interface-class>
|
||||
<implementation-class>com.intellij.util.indexing.FileBasedIndexImpl</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<interface-class>com.intellij.psi.stubs.StubIndex</interface-class>
|
||||
|
||||
@@ -93,6 +93,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.LocalTimeCounter;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FileBasedIndexImpl;
|
||||
import com.intellij.util.indexing.IndexableFileSet;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -234,7 +235,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
FileBasedIndex.getInstance().registerIndexableSet(new IndexableFileSet() {
|
||||
((FileBasedIndexImpl)FileBasedIndex.getInstance()).registerIndexableSet(new IndexableFileSet() {
|
||||
@Override
|
||||
public boolean isInSet(@NotNull final VirtualFile file) {
|
||||
return ourSourceRoot != null && file.getFileSystem() == ourSourceRoot.getFileSystem() && ourProject.isOpen();
|
||||
|
||||
Reference in New Issue
Block a user