public static <X> void save(final TIntHashSet x, final DataOutput out) { try { DataInputOutputUtil.writeINT(out, x.size()); x.forEach(new TIntProcedure() { @Override public boolean execute(int value) { try { DataInputOutputUtil.writeINT(out, value); return true; } catch (IOException e) { throw new BuildDataCorruptedException(e); } } }); } catch (IOException c) { throw new BuildDataCorruptedException(c); } }
@Override public void save(@NotNull final DataOutput out, final TIntHashSet value) throws IOException { final Ref<IOException> exRef = new Ref<IOException>(null); value.forEach(new TIntProcedure() { @Override public boolean execute(int elem) { try { DataInputOutputUtil.writeINT(out, elem); } catch (IOException e) { exRef.set(e); return false; } return true; } }); final IOException exception = exRef.get(); if (exception != null) { throw exception; } }
public ClassRepr(final DependencyContext context, final DataInput in) { super(in); try { this.myContext = context; myFileName = DataInputOutputUtil.readINT(in); mySuperClass = (TypeRepr.ClassType)TypeRepr.externalizer(context).read(in); myInterfaces = (Set<TypeRepr.AbstractType>)RW.read(TypeRepr.externalizer(context), new THashSet<TypeRepr.AbstractType>(1), in); myFields = (Set<FieldRepr>)RW.read(FieldRepr.externalizer(context), new THashSet<FieldRepr>(), in); myMethods = (Set<MethodRepr>)RW.read(MethodRepr.externalizer(context), new THashSet<MethodRepr>(), in); myAnnotationTargets = (Set<ElemType>)RW.read(UsageRepr.AnnotationUsage.elementTypeExternalizer, EnumSet.noneOf(ElemType.class), in); final String s = RW.readUTF(in); myRetentionPolicy = s.length() == 0 ? null : RetentionPolicy.valueOf(s); myOuterClassName = DataInputOutputUtil.readINT(in); int flags = DataInputOutputUtil.readINT(in); myIsLocal = (flags & LOCAL_MASK) != 0; myIsAnonymous = (flags & ANONYMOUS_MASK) != 0; myUsages =(Set<UsageRepr.Usage>)RW.read(UsageRepr.externalizer(context), new THashSet<UsageRepr.Usage>(), in); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
@Override public void save(final DataOutput out) { try { super.save(out); DataInputOutputUtil.writeINT(out, myFileName); mySuperClass.save(out); RW.save(myInterfaces, out); RW.save(myFields, out); RW.save(myMethods, out); RW.save(myAnnotationTargets, UsageRepr.AnnotationUsage.elementTypeExternalizer, out); RW.writeUTF(out, myRetentionPolicy == null ? "" : myRetentionPolicy.toString()); DataInputOutputUtil.writeINT(out, myOuterClassName); DataInputOutputUtil.writeINT(out, (myIsLocal ? LOCAL_MASK:0) | (myIsAnonymous ? ANONYMOUS_MASK : 0)); RW.save(myUsages, UsageRepr.externalizer(myContext), out); } catch (IOException e) { throw new BuildDataCorruptedException(e); } }
@Override public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException { final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir); if (iStream != null) { try { final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream); if (oldLevelOrdinal == level.ordinal()) return; } finally { iStream.close(); } } final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir); DataInputOutputUtil.writeINT(oStream, level.ordinal()); oStream.close(); for (VirtualFile child : fileOrDir.getChildren()) { if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) { PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child); } } }
public static Change readChange(DataInput in) throws IOException { int type = DataInputOutputUtil.readINT(in); switch (type) { case 1: return new CreateFileChange(in); case 2: return new CreateDirectoryChange(in); case 3: return new ContentChange(in); case 4: return new RenameChange(in); case 5: return new ROStatusChange(in); case 6: return new MoveChange(in); case 7: return new DeleteChange(in); case 8: return new PutLabelChange(in); case 9: return new PutSystemLabelChange(in); } throw new IOException("unexpected change type: " + type); }
public static void writeChange(DataOutput out, Change change) throws IOException { int id = -1; Class c = change.getClass(); if (c.equals(CreateFileChange.class)) id = 1; if (c.equals(CreateDirectoryChange.class)) id = 2; if (c.equals(ContentChange.class)) id = 3; if (c.equals(RenameChange.class)) id = 4; if (c.equals(ROStatusChange.class)) id = 5; if (c.equals(MoveChange.class)) id = 6; if (c.equals(DeleteChange.class)) id = 7; if (c.equals(PutLabelChange.class)) id = 8; if (c.equals(PutSystemLabelChange.class)) id = 9; if (id == -1) throw new IOException("unexpected change type: " + c); DataInputOutputUtil.writeINT(out, id); change.write(out); }
private void saveToFile(@NotNull T instance) throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(myFile, true); DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream)); try { if (myFile.length() == 0) { DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp()); DataInputOutputUtil.writeINT(output, myVersion); } myKeyDescriptor.save(output, instance); } finally { try { output.close(); fileOutputStream.getFD().sync(); } catch (IOException ignore) {} } }
public static int writeCompressedWithoutOriginalBufferLength(@NotNull DataOutput out, @NotNull byte[] bytes, int length) throws IOException { long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0; final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length)); int compressedSize = Snappy.compress(bytes, 0, length, compressedOutputBuffer, 0); final long time = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started; mySizeAfterCompression.addAndGet(compressedSize); mySizeBeforeCompression.addAndGet(length); int requests = myCompressionRequests.incrementAndGet(); long l = myCompressionTime.addAndGet(time); if (DUMP_COMPRESSION_STATS && requests % 1000 == 0) { System.out.println("Compressed " + requests + " times, size:" + mySizeBeforeCompression + "->" + mySizeAfterCompression + " for " + (l / 1000000) + "ms"); } DataInputOutputUtil.writeINT(out, compressedSize); out.write(compressedOutputBuffer, 0, compressedSize); return compressedSize; }
@NotNull public static byte[] readCompressedWithoutOriginalBufferLength(@NotNull DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); byte[] bytes = spareBufferLocal.getBuffer(size); in.readFully(bytes, 0, size); int decompressedRequests = myDecompressionRequests.incrementAndGet(); long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0; byte[] decompressedResult = Snappy.uncompress(bytes, 0, size); long doneTime = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started; long decompressedSize = myDecompressedSize.addAndGet(size); long decompressedTime = myDecompressionTime.addAndGet(doneTime); if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) { System.out.println("Decompressed " + decompressedRequests + " times, size: " + decompressedSize + " for " + (decompressedTime / 1000000) + "ms"); } return decompressedResult; }
public SerializedStubTree(DataInput in) throws IOException { if (PersistentHashMapValueStorage.COMPRESSION_ENABLED) { int serializedStubsLength = DataInputOutputUtil.readINT(in); byte[] bytes = new byte[serializedStubsLength]; in.readFully(bytes); myBytes = bytes; myLength = myBytes.length; myByteContentLength = DataInputOutputUtil.readLONG(in); myCharContentLength = DataInputOutputUtil.readINT(in); } else { myBytes = CompressionUtil.readCompressed(in); myLength = myBytes.length; myByteContentLength = in.readLong(); myCharContentLength = in.readInt(); } }
@Override public void save(@NotNull final DataOutput out, @NotNull final StubIdList value) throws IOException { int size = value.size(); if (size == 0) { DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE); } else if (size == 1) { DataInputOutputUtil.writeINT(out, value.get(0)); // most often case } else { DataInputOutputUtil.writeINT(out, -size); for(int i = 0; i < size; ++i) { DataInputOutputUtil.writeINT(out, value.get(i)); } } }
@NotNull @Override public StubIdList read(@NotNull final DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); if (size == Integer.MAX_VALUE) { return new StubIdList(); } else if (size >= 0) { return new StubIdList(size); } else { size = -size; int[] result = new int[size]; for(int i = 0; i < size; ++i) { result[i] = DataInputOutputUtil.readINT(in); } return new StubIdList(result, size); } }
public static String getIndexingStampInfo(VirtualFile file) { try { DataInputStream stream = INDEXED_STAMP.readAttribute(file); if (stream == null) { return "no data"; } long stamp = DataInputOutputUtil.readTIME(stream); long size = DataInputOutputUtil.readLONG(stream); stream.close(); return "indexed at " + stamp + " with size " + size; } catch (IOException e) { return ExceptionUtil.getThrowableText(e); } }
@NotNull private Stub deserialize(@NotNull StubInputStream stream, @Nullable Stub parentStub) throws IOException, SerializerNotFoundException { final int id = DataInputOutputUtil.readINT(stream); final ObjectStubSerializer serializer = getClassById(id); if (serializer == null) { String externalId = null; try { externalId = myNameStorage.valueOf(id); } catch (Throwable ignore) {} throw new SerializerNotFoundException("No serializer registered for stub: ID=" + id + ", externalId:" + externalId + "; parent stub class=" + (parentStub != null? parentStub.getClass().getName() : "null")); } Stub stub = serializer.deserialize(stream, parentStub); int childCount = DataInputOutputUtil.readINT(stream); for (int i = 0; i < childCount; i++) { deserialize(stream, stub); } return stub; }
@Override public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException { if (needsCompacting()) { getMergedData().saveTo(out, externalizer); } else { final TIntHashSet set = myInvalidated; if (set != null && set.size() > 0) { for (int inputId : set.toArray()) { DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom } } final ValueContainer<Value> toAppend = getAddedDelta(); if (toAppend != null && toAppend.size() > 0) { toAppend.saveTo(out, externalizer); } } }
public static boolean versionDiffers(@NotNull File versionFile, final int currentIndexVersion) { try { ourLastStamp = Math.max(ourLastStamp, versionFile.lastModified()); final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(versionFile))); try { final int savedIndexVersion = DataInputOutputUtil.readINT(in); final int commonVersion = DataInputOutputUtil.readINT(in); final long vfsCreationStamp = DataInputOutputUtil.readTIME(in); return savedIndexVersion != currentIndexVersion || commonVersion != VERSION || vfsCreationStamp != FSRecords.getCreationTimestamp() ; } finally { in.close(); } } catch (IOException e) { return true; } }
@Override public void save(@NotNull DataOutput out, TIntArrayList list) throws IOException { if (list.size() == 2) { DataInputOutputUtil.writeINT(out, list.getQuick(0)); DataInputOutputUtil.writeINT(out, list.getQuick(1)); } else { DataInputOutputUtil.writeINT(out, -list.size()); int prev = 0; for (int i = 0, len = list.size(); i < len; i+=2) { int value = list.getQuick(i); DataInputOutputUtil.writeINT(out, value - prev); prev = value; DataInputOutputUtil.writeINT(out, list.getQuick(i + 1)); } } }
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException { final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir); if (iStream != null) { try { final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream); if (oldLevelOrdinal == level.ordinal()) return; } finally { iStream.close(); } } final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir); DataInputOutputUtil.writeINT(oStream, level.ordinal()); oStream.close(); for (VirtualFile child : fileOrDir.getChildren()) { final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(child.getName()); if (!child.isDirectory() && PythonFileType.INSTANCE.equals(fileType)) { clearSdkPathCache(child); PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child); } } }
@Nullable @Override public Set<MyResourceInfo> read(@NotNull DataInput in) throws IOException { final int size = DataInputOutputUtil.readINT(in); if (size < 0 || size > 65535) { // Something is very wrong; trigger an index rebuild throw new IOException("Corrupt Index: Size " + size); } if (size == 0) { return Collections.emptySet(); } final Set<MyResourceInfo> result = Sets.newHashSetWithExpectedSize(size); for (int i = 0; i < size; i++) { final String type = IOUtil.readUTF(in); final String name = IOUtil.readUTF(in); final String context = IOUtil.readUTF(in); final int offset = DataInputOutputUtil.readINT(in); result.add(new MyResourceInfo(new ResourceEntry(type, name, context), offset)); } return result; }
@Override public void save(DataOutput dataOutput, List<Unity3dYMLAsset> list) throws IOException { DataInputOutputUtil.writeSeq(dataOutput, list, asset -> { dataOutput.writeUTF(asset.getGuild()); dataOutput.writeInt(asset.getStartOffset()); String gameObjectName = asset.getGameObjectName(); dataOutput.writeBoolean(gameObjectName != null); if(gameObjectName != null) { dataOutput.writeUTF(gameObjectName); } DataInputOutputUtil.writeSeq(dataOutput, asset.getValues(), it -> { dataOutput.writeUTF(it.getName()); dataOutput.writeUTF(it.getValue()); dataOutput.writeInt(it.getOffset()); }); }); }
@Override public List<Unity3dYMLAsset> read(DataInput dataInput) throws IOException { return DataInputOutputUtil.readSeq(dataInput, () -> { String guid = dataInput.readUTF(); int startOffset = dataInput.readInt(); boolean gameObjectCheck = dataInput.readBoolean(); String gameObjectName = null; if(gameObjectCheck) { gameObjectName = dataInput.readUTF(); } List<Unity3dYMLField> values = DataInputOutputUtil.readSeq(dataInput, () -> { String name = dataInput.readUTF(); String value = dataInput.readUTF(); int offset = dataInput.readInt(); return new Unity3dYMLField(name, value, offset); }); return new Unity3dYMLAsset(guid, gameObjectName, startOffset, values); }); }
@Override public void persistAttribute(@NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException { final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir); if (iStream != null) { try { final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream); if (oldLevelOrdinal == level.ordinal()) return; } finally { iStream.close(); } } final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir); DataInputOutputUtil.writeINT(oStream, level.ordinal()); oStream.close(); for (VirtualFile child : fileOrDir.getChildren()) { if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) { FileBasedIndex.getInstance().requestReindex(child); } } }
@Nullable public DataInputStream readAttribute(VirtualFile file) { DataInputStream stream = ManagingFS.getInstance().readAttribute(file, this); if (stream != null) { try { int actualVersion = DataInputOutputUtil.readINT(stream); if (actualVersion != myVersion) { stream.close(); return null; } } catch (IOException e) { return null; } } return stream; }
@NotNull public Stub deserialize(@NotNull InputStream stream) throws IOException, SerializerNotFoundException { FileLocalStringEnumerator storage = new FileLocalStringEnumerator(); StubInputStream inputStream = new StubInputStream(stream, storage); final int size = DataInputOutputUtil.readINT(inputStream); byte[] buffer = IOUtil.allocReadWriteUTFBuffer(); int i = 1; while(i <= size) { String s = myStringInterner.get(IOUtil.readUTFFast(buffer, inputStream)); storage.myStrings.add(s); storage.myEnumerates.put(s, i); ++i; } return deserialize(inputStream, null); }
public static int writeCompressed(DataOutput out, byte[] bytes, int length) throws IOException { if (length > COMPRESSION_THRESHOLD && ourCanUseSnappy) { SoftReference<byte[]> reference = spareBufferLocal.get(); byte[] compressedOutputBuffer = reference != null ? reference.get():null; int maxCompressedSize = 32 + length + length / 6; // snappy.cc#MaxCompressedLength if (compressedOutputBuffer == null || compressedOutputBuffer.length < maxCompressedSize) { compressedOutputBuffer = new byte[maxCompressedSize]; spareBufferLocal.set(new SoftReference<byte[]>(compressedOutputBuffer)); } int compressedSize = Snappy.rawCompress(bytes, 0, length, compressedOutputBuffer, 0); DataInputOutputUtil.writeINT(out, -compressedSize); out.write(compressedOutputBuffer, 0, compressedSize); return compressedSize; } else { DataInputOutputUtil.writeINT(out, length); out.write(bytes, 0, length); return length; } }
@Override public void save(final DataOutput out, @NotNull final StubIdList value) throws IOException { int size = value.size(); if (size == 0) { DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE); } else if (size == 1) { DataInputOutputUtil.writeINT(out, value.get(0)); // most often case } else { DataInputOutputUtil.writeINT(out, -size); for(int i = 0; i < size; ++i) { DataInputOutputUtil.writeINT(out, value.get(i)); } } }
@NotNull @Override public StubIdList read(final DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); if (size == Integer.MAX_VALUE) { return new StubIdList(); } else if (size >= 0) { return new StubIdList(size); } else { size = -size; int[] result = new int[size]; for(int i = 0; i < size; ++i) { result[i] = DataInputOutputUtil.readINT(in); } return new StubIdList(result, size); } }
private Timestamps(@Nullable DataInputStream stream) throws IOException { if (stream != null) { try { long dominatingIndexStamp = DataInputOutputUtil.readTIME(stream); while(stream.available() > 0) { ID<?, ?> id = ID.findById(DataInputOutputUtil.readINT(stream)); if (id != null) { long stamp = IndexInfrastructure.getIndexCreationStamp(id); if (myIndexStamps == null) myIndexStamps = new TObjectLongHashMap<ID<?, ?>>(5, 0.98f); if (stamp <= dominatingIndexStamp) myIndexStamps.put(id, stamp); } } } finally { stream.close(); } } }
private void saveToFile(@Nonnull T instance) throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(myFile, true); DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream)); try { if (myFile.length() == 0) { DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp()); DataInputOutputUtil.writeINT(output, myVersion); } myKeyDescriptor.save(output, instance); } finally { try { output.close(); fileOutputStream.getFD().sync(); } catch (IOException ignore) {} } }
public static int writeCompressedWithoutOriginalBufferLength(@Nonnull DataOutput out, @Nonnull byte[] bytes, int length) throws IOException { long started = System.nanoTime(); final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length)); int compressedSize = Snappy.compress(bytes, 0, length, compressedOutputBuffer, 0); final long time = System.nanoTime() - started; mySizeAfterCompression.addAndGet(compressedSize); mySizeBeforeCompression.addAndGet(length); int requests = myCompressionRequests.incrementAndGet(); long l = myCompressionTime.addAndGet(time); if (DUMP_COMPRESSION_STATS && requests % 1000 == 0) { System.out.println("Compressed " + requests + " times, size:" + mySizeBeforeCompression + "->" + mySizeAfterCompression + " for " + (l / 1000000) + "ms"); } DataInputOutputUtil.writeINT(out, compressedSize); out.write(compressedOutputBuffer, 0, compressedSize); return compressedSize; }
@Nonnull public static byte[] readCompressedWithoutOriginalBufferLength(@Nonnull DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); byte[] bytes = spareBufferLocal.getBuffer(size); in.readFully(bytes, 0, size); int decompressedRequests = myDecompressionRequests.incrementAndGet(); long started = System.nanoTime(); byte[] decompressedResult = Snappy.uncompress(bytes, 0, size); long doneTime = System.nanoTime() - started; long decompressedSize = myDecompressedSize.addAndGet(size); long decompressedTime = myDecompressionTime.addAndGet(doneTime); if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) { System.out.println("Decompressed " + decompressedRequests + " times, size: " + decompressedSize + " for " + (decompressedTime / 1000000) + "ms"); } return decompressedResult; }
@Override public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException { if (needsCompacting()) { getMergedData().saveTo(out, externalizer); } else { final TIntHashSet set = myInvalidated; if (set != null && set.size() > 0) { for (int inputId : set.toArray()) { DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom } } final UpdatableValueContainer<Value> toAppend = getAddedDelta(); if (toAppend != null && toAppend.size() > 0) { toAppend.saveTo(out, externalizer); } } }
@Override public void save(@Nonnull final DataOutput out, @Nonnull final StubIdList value) throws IOException { int size = value.size(); if (size == 0) { DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE); } else if (size == 1) { DataInputOutputUtil.writeINT(out, value.get(0)); // most often case } else { DataInputOutputUtil.writeINT(out, -size); for(int i = 0; i < size; ++i) { DataInputOutputUtil.writeINT(out, value.get(i)); } } }
@Nonnull @Override public StubIdList read(@Nonnull final DataInput in) throws IOException { int size = DataInputOutputUtil.readINT(in); if (size == Integer.MAX_VALUE) { return new StubIdList(); } else if (size >= 0) { return new StubIdList(size); } else { size = -size; int[] result = new int[size]; for(int i = 0; i < size; ++i) { result[i] = DataInputOutputUtil.readINT(in); } return new StubIdList(result, size); } }
private void doSerialize(@Nonnull Stub rootStub, @Nonnull StubOutputStream stream) throws IOException { final ObjectStubSerializer serializer = StubSerializationUtil.getSerializer(rootStub); if (((ObjectStubBase)rootStub).isDangling()) { stream.writeByte(0); } DataInputOutputUtil.writeINT(stream, getClassId(serializer)); serializer.serialize(rootStub, stream); final List<? extends Stub> children = rootStub.getChildrenStubs(); final int childrenSize = children.size(); DataInputOutputUtil.writeINT(stream, childrenSize); for (int i = 0; i < childrenSize; ++i) { doSerialize(children.get(i), stream); } }
public static boolean versionDiffers(@Nonnull File versionFile, final int currentIndexVersion) { try { ourLastStamp = Math.max(ourLastStamp, versionFile.lastModified()); final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(versionFile))); try { final int savedIndexVersion = DataInputOutputUtil.readINT(in); final int commonVersion = DataInputOutputUtil.readINT(in); final long vfsCreationStamp = DataInputOutputUtil.readTIME(in); return savedIndexVersion != currentIndexVersion || commonVersion != VERSION || vfsCreationStamp != FSRecords.getCreationTimestamp() ; } finally { in.close(); } } catch (IOException e) { return true; } }
@Override public Data getFileData(@Nonnull Project project, @Nonnull VirtualFile file) { ApplicationManager.getApplication().assertReadAccessAllowed(); ProgressManager.checkCanceled(); if (!(file instanceof VirtualFileWithId)) return myCalculator.calcData(project, file); int stamp = PersistentFS.getInstance().getModificationCount(file) + ((GistManagerImpl)GistManager.getInstance()).getReindexCount(); try (DataInputStream stream = getFileAttribute(project).readAttribute(file)) { if (stream != null && DataInputOutputUtil.readINT(stream) == stamp) { return stream.readBoolean() ? myExternalizer.read(stream) : null; } } catch (IOException e) { LOG.error(e); } Data result = myCalculator.calcData(project, file); cacheResult(stamp, result, project, file); return result; }
private static PreContract readContract(DataInput in) throws IOException { switch(in.readByte()) { case 0: return new DelegationContract(readRange(in), in.readBoolean()); case 1: return new KnownContract(new StandardMethodContract(readContractArguments(in).stream().toArray(MethodContract.ValueConstraint[]::new), readValueConstraint(in))); case 2: return new MethodCallContract(readRange(in), DataInputOutputUtil.readSeq(in, () -> readContractArguments(in))); case 3: return new NegatingContract(readContract(in)); default: return new SideEffectFilter(readRanges(in), DataInputOutputUtil.readSeq(in, () -> readContract(in))); } }