@@ -0,0 +1,2823 @@
+// Copyright 2000-2021 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.%0Apackage com.intellij.util.indexing;%0A%0Aimport com.intellij.openapi.vfs.VirtualFile;%0Aimport com.intellij.openapi.vfs.VirtualFileWithId;%0Aimport com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;%0Aimport org.jetbrains.jetCheck.Generator;%0Aimport org.jetbrains.jetCheck.PropertyChecker;%0A%0Aimport java.util.Comparator;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;%0A%0Apublic class IndexingStampTest extends LightJavaCodeInsightFixtureTestCase %7B%0A%0A  public void testIndexingStampSerialization() %7B%0A    VirtualFile file = myFixture.getTempDirFixture().createFile(%22tempfile.txt%22);%0A    int fileId = ((VirtualFileWithId)file).getId();%0A%0A    Generator%3CID%3C?, ?%3E%3E indexIds =%0A      Generator.sampledFrom(FileBasedIndexExtension%0A                              .EXTENSION_POINT_NAME%0A                              .extensions()%0A                              .map(ex -%3E ex.getName())%0A                              .sorted(Comparator.comparing(id -%3E id.getName()))%0A                              .collect(Collectors.toList()));%0A%0A    Generator%3CChangeIndexedStampForIndexOp%3E changeIndexedStampOps =%0A      Generator.sampledFrom((id, indexId) -%3E IndexingStamp.setFileIndexedStateCurrent(id, indexId),%0A                            (id, indexId) -%3E IndexingStamp.setFileIndexedStateOutdated(id, indexId),%0A                            (id, indexId) -%3E IndexingStamp.setFileIndexedStateUnindexed(id, indexId));%0A%0A    Generator%3CChangeIndexedStamp%3E stampGenerator =%0A      Generator.zipWith(indexIds, changeIndexedStampOps, (id, op) -%3E new ChangeIndexedStamp(op, id));%0A%0A    PropertyChecker.customized().withIterationCount(30).forAll(stampGenerator, stamp -%3E %7B%0A%0A      stamp.setIndexedStamp(fileId);%0A      Set%3CID%3C?, ?%3E%3E nonTrivialIndexesBeforeFlush = new HashSet%3C%3E(IndexingStamp.getNontrivialFileIndexedStates(fileId));%0A%0A      IndexingStamp.flushCache(fileId);%0A      IndexingStamp.flushCaches();%0A%0A      Set%3CID%3C?, ?%3E%3E nonTrivialIndexesAfterFlush = new HashSet%3C%3E(IndexingStamp.getNontrivialFileIndexedStates(fileId));%0A      boolean equals = nonTrivialIndexesBeforeFlush.equals(nonTrivialIndexesAfterFlush);%0A      IndexingStamp.flushCaches();%0A      return equals;%0A    %7D);%0A  %7D%0A%0A  @FunctionalInterface%0A  private interface ChangeIndexedStampForIndexOp %7B%0A    void setIndexedStamp(int fileId, ID%3C?, ?%3E indexId);%0A  %7D%0A%0A  private static class ChangeIndexedStamp %7B%0A    private final ChangeIndexedStampForIndexOp myOp;%0A    private final ID%3C?, ?%3E myIndexId;%0A%0A    private ChangeIndexedStamp(ChangeIndexedStampForIndexOp op, ID%3C?, ?%3E id) %7B%0A      myOp = op;%0A      myIndexId = id;%0A    %7D%0A%0A    void setIndexedStamp(int fileId) %7B%0A      myOp.setIndexedStamp(fileId, myIndexId);%0A    %7D%0A  %7D%0A%0A%7D%0A

add test for indexing stamp serialization