summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/util
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/util')
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java2
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/DebugAssertions.java2
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java51
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java2
-rw-r--r--platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java6
5 files changed, 34 insertions, 29 deletions
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java b/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java
index 34f80dae5cc9..451b0e7c1954 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/ContentHashesSupport.java
@@ -84,7 +84,7 @@ class ContentHashesSupport {
messageDigest.update((byte)0);
messageDigest.update(String.valueOf(bytes.length).getBytes(defaultCharset));
messageDigest.update((byte)0);
- messageDigest.update((charset != null ? charset.displayName():"null_charset").getBytes(defaultCharset));
+ messageDigest.update((charset != null ? charset.name():"null_charset").getBytes(defaultCharset));
messageDigest.update((byte)0);
messageDigest.update(bytes, 0, bytes.length);
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/DebugAssertions.java b/platform/lang-impl/src/com/intellij/util/indexing/DebugAssertions.java
index 6c866ad2283f..09aeea33b71e 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/DebugAssertions.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/DebugAssertions.java
@@ -31,7 +31,7 @@ public class DebugAssertions {
public static final boolean EXTRA_SANITY_CHECKS = SystemProperties.getBooleanProperty(
"intellij.idea.indices.debug.extra.sanity",
- true
+ DEBUG
);
public static void assertTrue(boolean value) {
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
index 5242ee3b70cf..85077380ea6e 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
@@ -1964,33 +1964,38 @@ public class FileBasedIndexImpl extends FileBasedIndex {
// For 'normal indices' schedule the file for update and reset stamps for all affected indices (there
// can be client that used indices between before and after events, in such case indices are up to date due to force update
// with old content)
- if (!fileIsDirectory && !isTooLarge(file)) {
- FileTypeManagerImpl.cacheFileType(file, file.getFileType());
- try {
- final List<ID<?, ?>> candidates = getAffectedIndexCandidates(file);
- //noinspection ForLoopReplaceableByForEach
- boolean scheduleForUpdate = false;
- boolean resetStamp = false;
-
- //noinspection ForLoopReplaceableByForEach
- for (int i = 0, size = candidates.size(); i < size; ++i) {
- final ID<?, ?> indexId = candidates.get(i);
- if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
- if (IndexingStamp.isFileIndexedStateCurrent(file, indexId)) {
- IndexingStamp.setFileIndexedStateOutdated(file, indexId);
- resetStamp = true;
+ if (!fileIsDirectory) {
+ if (isTooLarge(file)) {
+ // large file might be scheduled for update in before event when its size was not large
+ myChangedFilesCollector.myFilesToUpdate.remove(file);
+ } else {
+ FileTypeManagerImpl.cacheFileType(file, file.getFileType());
+ try {
+ final List<ID<?, ?>> candidates = getAffectedIndexCandidates(file);
+ //noinspection ForLoopReplaceableByForEach
+ boolean scheduleForUpdate = false;
+ boolean resetStamp = false;
+
+ //noinspection ForLoopReplaceableByForEach
+ for (int i = 0, size = candidates.size(); i < size; ++i) {
+ final ID<?, ?> indexId = candidates.get(i);
+ if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
+ if (IndexingStamp.isFileIndexedStateCurrent(file, indexId)) {
+ IndexingStamp.setFileIndexedStateOutdated(file, indexId);
+ resetStamp = true;
+ }
+ scheduleForUpdate = true;
}
- scheduleForUpdate = true;
}
- }
- if (scheduleForUpdate) {
- if (resetStamp) IndexingStamp.flushCache(file);
- scheduleForUpdate(file);
+ if (scheduleForUpdate) {
+ if (resetStamp) IndexingStamp.flushCache(file);
+ scheduleForUpdate(file);
+ }
+ }
+ finally {
+ FileTypeManagerImpl.cacheFileType(file, null);
}
- }
- finally {
- FileTypeManagerImpl.cacheFileType(file, null);
}
}
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java b/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
index 6bdd55b1d343..5ef1379eaaf4 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java
@@ -59,7 +59,7 @@ public class IndexingStamp {
private static final long UNINDEXED_STAMP = -1L; // we don't store trivial "absent" state
private static final long INDEX_DATA_OUTDATED_STAMP = -2L;
- private static final int VERSION = 12;
+ private static final int VERSION = 13;
private static final ConcurrentHashMap<ID<?, ?>, Long> ourIndexIdToCreationStamp = new ConcurrentHashMap<ID<?, ?>, Long>();
private static volatile long ourLastStamp; // ensure any file index stamp increases
diff --git a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
index ebb7911e82be..6427765295c5 100644
--- a/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
+++ b/platform/lang-impl/src/com/intellij/util/indexing/MapReduceIndex.java
@@ -354,7 +354,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
FileContent fileContent = (FileContent)content;
hashId = getHashOfContent(fileContent);
if (doReadSavedPersistentData) {
- if (!myContents.isBusyReading()) { // avoid blocking read, we can calculate index value
+ if (!myContents.isBusyReading() || DebugAssertions.EXTRA_SANITY_CHECKS) { // avoid blocking read, we can calculate index value
ByteSequence bytes = myContents.get(hashId);
if (bytes != null) {
data = deserializeSavedPersistentData(bytes);
@@ -367,7 +367,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
"Unexpected difference in indexing of %s by index %s, file type %s, charset %s\ndiff %s\nprevious indexed info %s",
fileContent.getFile(),
myIndexId,
- fileContent.getFileType(),
+ fileContent.getFileType().getName(),
((FileContentImpl)fileContent).getCharset(),
buildDiff(data, contentData),
myIndexingTrace.get(hashId)
@@ -396,7 +396,7 @@ public class MapReduceIndex<Key, Value, Input> implements UpdatableIndex<Key,Val
FileContent fileContent = (FileContent)content;
try {
- myIndexingTrace.put(hashId, ((FileContentImpl)fileContent).getCharset() + "," + fileContent.getFileType()+"," + fileContent.getFile().getPath() + "," +
+ myIndexingTrace.put(hashId, ((FileContentImpl)fileContent).getCharset() + "," + fileContent.getFileType().getName()+"," + fileContent.getFile().getPath() + "," +
ExceptionUtil.getThrowableText(new Throwable()));
} catch (IOException ex) {
LOG.error(ex);