mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
properly determine set of keys to be invalidated if snapshot index has no prior unsaved keys (IDEA-167050), EA-92612, r=Dmitry.Batkovich
This commit is contained in:
@@ -43,6 +43,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.impl.PsiManagerEx
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndex
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndexEntry
|
||||
import com.intellij.psi.impl.cache.impl.id.IdIndexImpl
|
||||
import com.intellij.psi.impl.file.impl.FileManagerImpl
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaStubIndexKeys
|
||||
import com.intellij.psi.impl.source.JavaFileElementType
|
||||
@@ -443,6 +444,24 @@ class IndexTest extends JavaCodeInsightFixtureTestCase {
|
||||
assertTrue(stamp != ((FileBasedIndexImpl)FileBasedIndex.instance).getIndexModificationStamp(IdIndex.NAME, project))
|
||||
}
|
||||
|
||||
void "test snapshot index in memory state after commit of unsaved document"() throws IOException {
|
||||
final VirtualFile vFile = myFixture.addClass("class Foo {}").getContainingFile().getVirtualFile()
|
||||
def classEntry = new IdIndexEntry("class", true)
|
||||
def findValueProcessor = { file, value -> file != vFile } as FileBasedIndex.ValueProcessor
|
||||
|
||||
def projectScope = GlobalSearchScope.projectScope(project)
|
||||
def result = FileBasedIndex.instance.processValues(IdIndexImpl.NAME, classEntry, null, findValueProcessor,
|
||||
projectScope)
|
||||
assertFalse(result)
|
||||
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(vFile)
|
||||
document.setText("")
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments()
|
||||
result = FileBasedIndex.instance.processValues(IdIndexImpl.NAME, classEntry, null, findValueProcessor,
|
||||
projectScope)
|
||||
assertTrue(result)
|
||||
}
|
||||
|
||||
void "test no stub index stamp update when no change"() throws IOException {
|
||||
final VirtualFile vFile = myFixture.addClass("class Foo {}").getContainingFile().getVirtualFile()
|
||||
def stamp = ((StubIndexImpl)StubIndex.instance).getIndexModificationStamp(JavaStubIndexKeys.CLASS_SHORT_NAMES, project)
|
||||
|
||||
@@ -107,6 +107,10 @@ public class VfsAwareMapReduceIndex<Key, Value, Input> extends MapReduceIndex<Ke
|
||||
return new CollectionInputDataDiffBuilder<>(inputId, keys);
|
||||
}
|
||||
}
|
||||
|
||||
if (mySnapshotInputMappings != null) {
|
||||
return new MapInputDataDiffBuilder<>(inputId, mySnapshotInputMappings.readInputKeys(inputId));
|
||||
}
|
||||
}
|
||||
if (myForwardIndex != null) {
|
||||
return getKeysDiffBuilder(inputId);
|
||||
|
||||
Reference in New Issue
Block a user