mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
do not try to merge stubs if version changed: reverted
This commit is contained in:
+1
-1
@@ -149,7 +149,7 @@ public abstract class CompilerOutputBaseIndex<K, V> {
|
||||
}
|
||||
|
||||
public final void update(final int id, final ClassNode inputData) {
|
||||
final Boolean result = myIndex.update(id, inputData, true).compute();
|
||||
final Boolean result = myIndex.update(id, inputData).compute();
|
||||
if (result == Boolean.FALSE) throw new RuntimeException();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class StringIndex {
|
||||
}
|
||||
|
||||
public void update(final String path, @Nullable String content, @Nullable String oldContent) throws StorageException {
|
||||
myIndex.update(path.hashCode(), toInput(path, content), true).compute();
|
||||
myIndex.update(path.hashCode(), toInput(path, content)).compute();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -429,7 +429,7 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
public Collection<K> call() throws Exception {
|
||||
return oldValues.keySet();
|
||||
}
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
@@ -443,11 +443,8 @@ public class StubIndexImpl extends StubIndex implements ApplicationComponent, Pe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWithMap(final int inputId,
|
||||
@NotNull final Map<K, StubIdList> newData,
|
||||
@NotNull Callable<Collection<K>> oldKeysGetter,
|
||||
boolean merge) throws StorageException {
|
||||
super.updateWithMap(inputId, newData, oldKeysGetter, merge);
|
||||
public void updateWithMap(final int inputId, @NotNull final Map<K, StubIdList> newData, @NotNull Callable<Collection<K>> oldKeysGetter) throws StorageException {
|
||||
super.updateWithMap(inputId, newData, oldKeysGetter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
return true;
|
||||
}
|
||||
final ID indexId = IndexInfrastructure.getStubId(INDEX_ID, fileType);
|
||||
if (IndexingStamp.getIndexingState(file, indexId) == IndexingStamp.State.INDEXED) {
|
||||
if (IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -298,10 +298,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWithMap(final int inputId,
|
||||
@NotNull final Map<Integer, SerializedStubTree> newData,
|
||||
@NotNull Callable<Collection<Integer>> oldKeysGetter,
|
||||
boolean merge)
|
||||
protected void updateWithMap(final int inputId, @NotNull final Map<Integer, SerializedStubTree> newData, @NotNull Callable<Collection<Integer>> oldKeysGetter)
|
||||
throws StorageException {
|
||||
|
||||
checkNameStorage();
|
||||
@@ -324,8 +321,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
try {
|
||||
getWriteLock().lock();
|
||||
|
||||
final Map<Integer, SerializedStubTree> oldData =
|
||||
merge ? readOldData(inputId) : Collections.<Integer, SerializedStubTree>emptyMap();
|
||||
final Map<Integer, SerializedStubTree> oldData = readOldData(inputId);
|
||||
final Map<StubIndexKey, Map<Object, StubIdList>> oldStubTree;
|
||||
try {
|
||||
oldStubTree = getStubTree(oldData);
|
||||
@@ -334,7 +330,7 @@ public class StubUpdatingIndex extends CustomImplementationFileBasedIndexExtensi
|
||||
throw new StorageException(e);
|
||||
}
|
||||
|
||||
super.updateWithMap(inputId, newData, oldKeysGetter, merge);
|
||||
super.updateWithMap(inputId, newData, oldKeysGetter);
|
||||
|
||||
updateStubIndices(getAffectedIndices(oldStubTree, newStubTree), inputId, oldStubTree, newStubTree);
|
||||
}
|
||||
|
||||
@@ -1573,7 +1573,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
|
||||
final int inputId = Math.abs(getFileId(vFile));
|
||||
try {
|
||||
getIndex(requestedIndexId).update(inputId, newFc, true).compute();
|
||||
getIndex(requestedIndexId).update(inputId, newFc).compute();
|
||||
} catch (ProcessCanceledException pce) {
|
||||
myLastIndexedDocStamps.getAndSet(document, requestedIndexId, previousDocStamp);
|
||||
throw pce;
|
||||
@@ -1709,9 +1709,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, size = affectedIndexCandidates.size(); i < size; ++i) {
|
||||
final ID<?, ?> indexId = affectedIndexCandidates.get(i);
|
||||
if (!getInputFilter(indexId).acceptInput(file)) continue;
|
||||
IndexingStamp.State state = isMock(file) ? IndexingStamp.State.FILE_CONTENT_CHANGED : getIndexingState(file, indexId);
|
||||
if (state != IndexingStamp.State.INDEXED) {
|
||||
if (shouldIndexFile(file, indexId)) {
|
||||
if (fc == null) {
|
||||
byte[] currentBytes;
|
||||
try {
|
||||
@@ -1731,7 +1729,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
|
||||
try {
|
||||
ProgressManager.checkCanceled();
|
||||
updateSingleIndex(indexId, file, fc, state == IndexingStamp.State.FILE_CONTENT_CHANGED);
|
||||
updateSingleIndex(indexId, file, fc);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
cleanFileContent(fc, psiFile);
|
||||
@@ -1779,7 +1777,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
}
|
||||
|
||||
private void updateSingleIndex(final ID<?, ?> indexId, @NotNull final VirtualFile file, @Nullable FileContent currentFC, boolean merge)
|
||||
private void updateSingleIndex(final ID<?, ?> indexId, @NotNull final VirtualFile file, @Nullable FileContent currentFC)
|
||||
throws StorageException {
|
||||
if (ourRebuildStatus.get(indexId).get() == REQUIRES_REBUILD) {
|
||||
return; // the index is scheduled for rebuild, no need to update
|
||||
@@ -1791,7 +1789,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
assert index != null;
|
||||
|
||||
// important: no hard referencing currentFC to avoid OOME, the methods introduced for this purpose!
|
||||
final Computable<Boolean> update = index.update(inputId, currentFC, merge);
|
||||
final Computable<Boolean> update = index.update(inputId, currentFC);
|
||||
final FileType fileType = file.getFileType();
|
||||
|
||||
scheduleUpdate(indexId,
|
||||
@@ -1977,7 +1975,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
if (fileContent == null) {
|
||||
fileContent = new FileContentImpl(file);
|
||||
}
|
||||
updateSingleIndex(indexId, file, fileContent, true);
|
||||
updateSingleIndex(indexId, file, fileContent);
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
@@ -2000,7 +1998,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
final ID<?, ?> indexId = candidates.get(i);
|
||||
if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
|
||||
ID id = IndexInfrastructure.getStubId(indexId, fileType);
|
||||
if (IndexingStamp.getIndexingState(file, id) != IndexingStamp.State.INDEXED) {
|
||||
if (IndexingStamp.isFileIndexed(file, id, IndexInfrastructure.getIndexCreationStamp(id))) {
|
||||
IndexingStamp.update(file, id, IndexInfrastructure.INVALID_STAMP2);
|
||||
resetStamp = true;
|
||||
}
|
||||
@@ -2068,7 +2066,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
try {
|
||||
if (!needsFileContentLoading(indexId)) {
|
||||
if (shouldUpdateIndex(file, indexId)) {
|
||||
updateSingleIndex(indexId, file, null, true); // todo: set merge to false?
|
||||
updateSingleIndex(indexId, file, null);
|
||||
}
|
||||
}
|
||||
else { // the index requires file content
|
||||
@@ -2132,7 +2130,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
Throwable unexpectedError = null;
|
||||
for (ID<?, ?> indexId : affectedIndices) {
|
||||
try {
|
||||
updateSingleIndex(indexId, file, null, true); // todo: set merge to false?
|
||||
updateSingleIndex(indexId, file, null);
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
@@ -2400,7 +2398,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
if (fileContent == null) {
|
||||
fileContent = new FileContentImpl(file);
|
||||
}
|
||||
updateSingleIndex(indexId, file, fileContent, true);
|
||||
updateSingleIndex(indexId, file, fileContent);
|
||||
}
|
||||
catch (StorageException e) {
|
||||
LOG.info(e);
|
||||
@@ -2427,11 +2425,6 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
}
|
||||
}
|
||||
|
||||
private static IndexingStamp.State getIndexingState(VirtualFile file, ID<?, ?> indexId) {
|
||||
ID id = IndexInfrastructure.getStubId(indexId, file.getFileType());
|
||||
return IndexingStamp.getIndexingState(file, id);
|
||||
}
|
||||
|
||||
private boolean shouldUpdateIndex(final VirtualFile file, final ID<?, ?> indexId) {
|
||||
return getInputFilter(indexId).acceptInput(file) &&
|
||||
(isMock(file) || isFileIndexed(file, indexId));
|
||||
@@ -2443,7 +2436,8 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
}
|
||||
|
||||
private static boolean isFileIndexed(VirtualFile file, ID<?, ?> indexId) {
|
||||
return getIndexingState(file, indexId) == IndexingStamp.State.INDEXED;
|
||||
ID id = IndexInfrastructure.getStubId(indexId, file.getFileType());
|
||||
return IndexingStamp.isFileIndexed(file, id, IndexInfrastructure.getIndexCreationStamp(id));
|
||||
}
|
||||
|
||||
private static long getIndexCreationStamp(ID<?, ?> indexId, FileType fileType) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.openapi.vfs.InvalidVirtualFileAccessException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileWithId;
|
||||
import com.intellij.openapi.vfs.newvfs.FileAttribute;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
@@ -57,7 +58,7 @@ public class IndexingStamp {
|
||||
if (id != null) {
|
||||
long stamp = IndexInfrastructure.getIndexCreationStamp(id);
|
||||
if (myIndexStamps == null) myIndexStamps = new TObjectLongHashMap<ID<?, ?>>(5, 0.98f);
|
||||
myIndexStamps.put(id, stamp <= dominatingIndexStamp ? stamp : INDEX_VERSION_CHANGED_STAMP);
|
||||
if (stamp <= dominatingIndexStamp) myIndexStamps.put(id, stamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,20 +126,10 @@ public class IndexingStamp {
|
||||
private static final ConcurrentHashMap<VirtualFile, Timestamps> myTimestampsCache = new ConcurrentHashMap<VirtualFile, Timestamps>();
|
||||
private static final int CAPACITY = 100;
|
||||
private static final ArrayBlockingQueue<VirtualFile> myFinishedFiles = new ArrayBlockingQueue<VirtualFile>(CAPACITY);
|
||||
private static final long INDEX_VERSION_CHANGED_STAMP = 1l;
|
||||
|
||||
public enum State {
|
||||
INDEXED, INDEX_VERSION_CHANGED, FILE_CONTENT_CHANGED
|
||||
}
|
||||
|
||||
public static State getIndexingState(VirtualFile file, ID<?, ?> indexName) {
|
||||
public static boolean isFileIndexed(VirtualFile file, ID<?, ?> indexName, final long indexCreationStamp) {
|
||||
try {
|
||||
long stamp = getIndexStamp(file, indexName);
|
||||
if (stamp == INDEX_VERSION_CHANGED_STAMP) {
|
||||
return State.INDEX_VERSION_CHANGED;
|
||||
}
|
||||
long indexCreationStamp = IndexInfrastructure.getIndexCreationStamp(indexName);
|
||||
return stamp == indexCreationStamp ? State.INDEXED : State.FILE_CONTENT_CHANGED;
|
||||
return getIndexStamp(file, indexName) == indexCreationStamp;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
@@ -147,7 +138,7 @@ public class IndexingStamp {
|
||||
}
|
||||
}
|
||||
|
||||
return State.FILE_CONTENT_CHANGED;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static long getIndexStamp(VirtualFile file, ID<?, ?> indexName) {
|
||||
|
||||
@@ -202,7 +202,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Computable<Boolean> update(final int inputId, @Nullable final Input content, final boolean merge) {
|
||||
public final Computable<Boolean> update(final int inputId, @Nullable Input content) {
|
||||
assert myInputsIndex != null;
|
||||
|
||||
final Map<Key, Value> data = content != null ? myIndexer.map(content) : Collections.<Key, Value>emptyMap();
|
||||
@@ -224,7 +224,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
final Collection<Key> oldKeys = myInputsIndex.get(inputId);
|
||||
return oldKeys == null? Collections.<Key>emptyList() : oldKeys;
|
||||
}
|
||||
}, merge);
|
||||
});
|
||||
} catch (StorageException ex) {
|
||||
exRef.set(ex);
|
||||
}
|
||||
@@ -242,10 +242,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
|
||||
};
|
||||
}
|
||||
|
||||
protected void updateWithMap(final int inputId,
|
||||
@NotNull Map<Key, Value> newData,
|
||||
@NotNull Callable<Collection<Key>> oldKeysGetter,
|
||||
boolean merge) throws StorageException {
|
||||
protected void updateWithMap(final int inputId, @NotNull Map<Key, Value> newData, @NotNull Callable<Collection<Key>> oldKeysGetter) throws StorageException {
|
||||
getWriteLock().lock();
|
||||
try {
|
||||
try {
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.ThrowableComputable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
@@ -31,10 +33,7 @@ public interface UpdatableIndex<Key, Value, Input> extends AbstractIndex<Key,Val
|
||||
|
||||
void flush() throws StorageException;
|
||||
|
||||
/**
|
||||
* @param merge true if merge with old data needed (e.g. file content changed), false if not needed (e.g. index version changed)
|
||||
*/
|
||||
Computable<Boolean> update(int inputId, @Nullable Input content, boolean merge);
|
||||
Computable<Boolean> update(int inputId, @Nullable Input content);
|
||||
|
||||
Lock getReadLock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user