vcs: cleanup - @NotNull

GitOrigin-RevId: c12bcaaf58c6a5062258993a4e623c0640684af4
This commit is contained in:
Aleksey Pivovarov
2023-09-13 13:10:08 +02:00
committed by intellij-monorepo-bot
parent 73fd45aa66
commit 09441d69e2
4 changed files with 37 additions and 20 deletions

View File

@@ -42,7 +42,11 @@ public final class ContentRevisionCache {
myCounter = 0;
}
private void put(FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey, @NotNull UniqueType type, final byte @Nullable [] bytes) {
private void put(@NotNull FilePath path,
@NotNull VcsRevisionNumber number,
@NotNull VcsKey vcsKey,
@NotNull UniqueType type,
byte @Nullable [] bytes) {
if (bytes == null) return;
synchronized (myLock) {
myCache.put(new Key(path, number, vcsKey, type), new SoftReference<>(bytes));
@@ -51,7 +55,7 @@ public final class ContentRevisionCache {
public void clearAllCurrent() {
synchronized (myLock) {
++ myCounter;
++myCounter;
myCurrentRevisionsCache.clear();
}
}
@@ -110,7 +114,7 @@ public final class ContentRevisionCache {
public static @NotNull String getOrLoadAsString(@NotNull Project project,
@NotNull FilePath file,
VcsRevisionNumber number,
@NotNull VcsRevisionNumber number,
@NotNull VcsKey key,
@NotNull UniqueType type,
@NotNull Throwable2Computable<byte[], ? extends VcsException, ? extends IOException> loader,
@@ -121,8 +125,12 @@ public final class ContentRevisionCache {
}
public static @NotNull String getOrLoadAsString(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
@NotNull UniqueType type, final Throwable2Computable<byte[], ? extends VcsException, ? extends IOException> loader)
public static @NotNull String getOrLoadAsString(@NotNull Project project,
@NotNull FilePath path,
@NotNull VcsRevisionNumber number,
@NotNull VcsKey vcsKey,
@NotNull UniqueType type,
@NotNull Throwable2Computable<byte[], ? extends VcsException, ? extends IOException> loader)
throws VcsException, IOException {
return getOrLoadAsString(project, path, number, vcsKey, type, loader, null);
}
@@ -156,8 +164,12 @@ public final class ContentRevisionCache {
return loader.compute();
}
public static byte @NotNull [] getOrLoadAsBytes(final Project project, FilePath path, VcsRevisionNumber number, @NotNull VcsKey vcsKey,
@NotNull UniqueType type, final Throwable2Computable<byte @NotNull [], ? extends VcsException, ? extends IOException> loader)
public static byte @NotNull [] getOrLoadAsBytes(@NotNull Project project,
@NotNull FilePath path,
@NotNull VcsRevisionNumber number,
@NotNull VcsKey vcsKey,
@NotNull UniqueType type,
@NotNull Throwable2Computable<byte @NotNull [], ? extends VcsException, ? extends IOException> loader)
throws VcsException, IOException {
ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
byte[] bytes = cache.getBytes(path, number, vcsKey, type);
@@ -190,10 +202,10 @@ public final class ContentRevisionCache {
}
}
private static VcsRevisionNumber putIntoCurrentCache(final ContentRevisionCache cache,
FilePath path,
@NotNull VcsKey vcsKey,
final CurrentRevisionProvider loader) throws VcsException {
private static @NotNull VcsRevisionNumber putIntoCurrentCache(@NotNull ContentRevisionCache cache,
@NotNull FilePath path,
@NotNull VcsKey vcsKey,
@NotNull CurrentRevisionProvider loader) throws VcsException {
CurrentKey key = new CurrentKey(path, vcsKey);
while (true) {
VcsRevisionNumber loadedRevisionNumber = loader.getCurrentRevision();
@@ -239,8 +251,10 @@ public final class ContentRevisionCache {
myConstantCache.clear();
}
public static Pair<VcsRevisionNumber, byte[]> getOrLoadCurrentAsBytes(final Project project, FilePath path, @NotNull VcsKey vcsKey,
final CurrentRevisionProvider loader)
public static Pair<VcsRevisionNumber, byte[]> getOrLoadCurrentAsBytes(@NotNull Project project,
@NotNull FilePath path,
@NotNull VcsKey vcsKey,
@NotNull CurrentRevisionProvider loader)
throws VcsException, IOException {
ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache();
@@ -347,7 +361,7 @@ public final class ContentRevisionCache {
public void clearAll() {
synchronized (myLock) {
++ myCounter;
++myCounter;
myCurrentRevisionsCache.clear();
myCache.clear();
myConstantCache.clear();

View File

@@ -18,8 +18,11 @@ package com.intellij.openapi.vcs.impl;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface CurrentRevisionProvider {
VcsRevisionNumber getCurrentRevision() throws VcsException;
Pair<VcsRevisionNumber, byte[]> get() throws VcsException;
@NotNull VcsRevisionNumber getCurrentRevision() throws VcsException;
@NotNull Pair<@NotNull VcsRevisionNumber, byte @Nullable []> get() throws VcsException;
}

View File

@@ -77,12 +77,12 @@ public final class VcsCurrentRevisionProxy implements ByteBackedContentRevision
return ContentRevisionCache.getOrLoadCurrentAsBytes(myProject, getFile(), myVcsKey,
new CurrentRevisionProvider() {
@Override
public VcsRevisionNumber getCurrentRevision() throws VcsException {
public @NotNull VcsRevisionNumber getCurrentRevision() throws VcsException {
return getCurrentRevisionNumber();
}
@Override
public Pair<VcsRevisionNumber, byte[]> get() throws VcsException {
public @NotNull Pair<VcsRevisionNumber, byte[]> get() throws VcsException {
return loadContent();
}
});

View File

@@ -71,12 +71,12 @@ public class SvnContentRevision extends SvnBaseContentRevision implements ByteBa
return ContentRevisionCache.getOrLoadCurrentAsBytes(myVcs.getProject(), myFile, myVcs.getKeyInstanceMethod(),
new CurrentRevisionProvider() {
@Override
public VcsRevisionNumber getCurrentRevision() {
public @NotNull VcsRevisionNumber getCurrentRevision() {
return getRevisionNumber();
}
@Override
public Pair<VcsRevisionNumber, byte[]> get()
public @NotNull Pair<VcsRevisionNumber, byte[]> get()
throws VcsException {
return Pair.create(getRevisionNumber(), getUpToDateBinaryContent());
}