Commit 58620725 authored by Julia Beliaeva's avatar Julia Beliaeva Committed by intellij-monorepo-bot
Browse files

[vcs-log] refactor DataGetter function names

GitOrigin-RevId: c547887b301950bc4c73f90bd7de5ec2a83bac89
parent 7eee743f
Showing with 22 additions and 22 deletions
+22 -22
......@@ -31,7 +31,7 @@ abstract class AbstractDataGetter<T : VcsShortCommitDetails> internal constructo
consumer: Consumer<in List<T>>,
errorConsumer: Consumer<in Throwable>,
indicator: ProgressIndicator?) {
val detailsFromCache = getCommitDataIfAvailable(commits)
val detailsFromCache = getCachedData(commits)
if (detailsFromCache.size == commits.size) {
// client of this code expect start/stop methods to get called for the provided indicator
runInCurrentThread(indicator) {
......@@ -79,7 +79,7 @@ abstract class AbstractDataGetter<T : VcsShortCommitDetails> internal constructo
consumer: (Int, T) -> Unit) {
val toLoad = IntOpenHashSet()
for (id in commits) {
val details = getCommitDataIfAvailable(id)
val details = getCachedData(id)
if (details == null || details is LoadingDetails) {
toLoad.add(id)
}
......@@ -114,7 +114,7 @@ abstract class AbstractDataGetter<T : VcsShortCommitDetails> internal constructo
}
}
protected abstract fun getCommitDataIfAvailable(commits: List<Int>): Int2ObjectMap<T>
protected abstract fun getCachedData(commits: List<Int>): Int2ObjectMap<T>
protected abstract fun saveInCache(commit: Int, details: T)
......
......@@ -33,15 +33,15 @@ class CommitDetailsGetter internal constructor(storage: VcsLogStorage,
}
@CalledInAny
override fun getCommitData(commitId: Int): VcsFullCommitDetails {
return getCommitDataIfAvailable(commitId) ?: placeholdersCache.get(commitId)!!
override fun getCachedDataOrPlaceholder(commitId: Int): VcsFullCommitDetails {
return getCachedData(commitId) ?: placeholdersCache.get(commitId)!!
}
@CalledInAny
override fun getCommitDataIfAvailable(commitId: Int) = cache.getIfPresent(commitId)
override fun getCachedData(commitId: Int) = cache.getIfPresent(commitId)
@CalledInAny
override fun getCommitDataIfAvailable(commits: List<Int>) = Int2ObjectOpenHashMap(cache.getAllPresent(commits))
override fun getCachedData(commits: List<Int>) = Int2ObjectOpenHashMap(cache.getAllPresent(commits))
@CalledInAny
override fun saveInCache(commit: Int, details: VcsFullCommitDetails) = cache.put(commit, details)
......
......@@ -26,11 +26,11 @@ import java.util.List;
public interface DataGetter<T extends VcsShortCommitDetails> {
@NotNull
T getCommitData(int hash);
T getCachedDataOrPlaceholder(int hash);
void loadCommitsData(@NotNull List<Integer> hashes, @NotNull Consumer<? super List<T>> consumer,
@NotNull Consumer<? super Throwable> errorConsumer, @Nullable ProgressIndicator indicator);
@Nullable
T getCommitDataIfAvailable(int hash);
T getCachedData(int hash);
}
......@@ -42,7 +42,7 @@ class MiniDetailsGetter internal constructor(project: Project,
private var currentTaskIndex: Long = 0
private val loadingFinishedListeners = ArrayList<Runnable>()
override fun getCommitData(commit: Int): VcsCommitMetadata {
override fun getCachedDataOrPlaceholder(commit: Int): VcsCommitMetadata {
return getCommitData(commit, emptySet())
}
......@@ -84,12 +84,12 @@ class MiniDetailsGetter internal constructor(project: Project,
return topCommitsDetailsCache[commit]
}
override fun getCommitDataIfAvailable(commit: Int): VcsCommitMetadata? {
override fun getCachedData(commit: Int): VcsCommitMetadata? {
return cache.getIfPresent(commit).takeIf { it !is LoadingDetails } ?: topCommitsDetailsCache[commit]
}
override fun getCommitDataIfAvailable(commits: List<Int>): Int2ObjectMap<VcsCommitMetadata> {
return commits.associateNotNull { getCommitDataIfAvailable(it) }
override fun getCachedData(commits: List<Int>): Int2ObjectMap<VcsCommitMetadata> {
return commits.associateNotNull { getCachedData(it) }
}
override fun saveInCache(commit: Int, details: VcsCommitMetadata) = cache.put(commit, details)
......
......@@ -281,7 +281,7 @@ public final class VcsLogData implements Disposable, VcsLogDataProvider {
@Override
public @Nullable CommitId getCommitId(int commitIndex) {
VcsCommitMetadata cachedData = myMiniDetailsGetter.getCommitDataIfAvailable(commitIndex);
VcsCommitMetadata cachedData = myMiniDetailsGetter.getCachedData(commitIndex);
if (cachedData != null) {
return new CommitId(cachedData.getId(), cachedData.getRoot());
}
......
......@@ -121,7 +121,7 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
myChangesBrowser = new VcsLogChangesBrowser(logData.getProject(), myUiProperties, (commitId) -> {
int index = myLogData.getCommitIndex(commitId.getHash(), commitId.getRoot());
return myLogData.getMiniDetailsGetter().getCommitData(index);
return myLogData.getMiniDetailsGetter().getCachedDataOrPlaceholder(index);
}, withEditorDiffPreview, this);
myChangesBrowser.getDiffAction().registerCustomShortcutSet(myChangesBrowser.getDiffAction().getShortcutSet(), getGraphTable());
JBLoadingPanel changesLoadingPane = new JBLoadingPanel(new BorderLayout(), this,
......
......@@ -40,7 +40,7 @@ internal class CommitSelectionImpl(private val logData: VcsLogData,
}
internal fun <T : VcsShortCommitDetails> VcsLogCommitSelection.getCachedDetails(dataGetter: DataGetter<T>): List<T> {
return getDetails(dataGetter::getCommitData)
return getDetails(dataGetter::getCachedDataOrPlaceholder)
}
}
}
\ No newline at end of file
......@@ -139,7 +139,7 @@ public final class GraphTableModel extends AbstractTableModel {
public @NotNull VcsFullCommitDetails getFullDetails(int row) {
Integer id = getIdAtRow(row);
return myLogData.getCommitDetailsGetter().getCommitData(id);
return myLogData.getCommitDetailsGetter().getCachedDataOrPlaceholder(id);
}
public @NotNull VcsCommitMetadata getCommitMetadata(int row) {
......
......@@ -641,7 +641,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
baseStyle.getBackground(), VcsLogHighlighter.TextStyle.NORMAL);
int commitId = rowInfo.getCommit();
VcsShortCommitDetails details = myLogData.getMiniDetailsGetter().getCommitDataIfAvailable(commitId);
VcsShortCommitDetails details = myLogData.getMiniDetailsGetter().getCachedData(commitId);
if (details != null) {
int columnModelIndex = convertColumnIndexToModel(column);
List<VcsCommitStyle> styles = ContainerUtil.map(myHighlighters, highlighter -> {
......
......@@ -435,7 +435,7 @@ class VcsLogFiltererImpl(private val logProviders: Map<VirtualFile, VcsLogProvid
}
private fun getDetailsFromCache(commitIndex: Int): VcsCommitMetadata? {
return topCommitsDetailsCache.get(commitIndex) ?: commitDetailsGetter.getCommitDataIfAvailable(commitIndex)
return topCommitsDetailsCache.get(commitIndex) ?: commitDetailsGetter.getCachedData(commitIndex)
}
private fun Collection<VcsRef>.toReferencedCommitIndexes(): Set<Int> {
......
......@@ -297,7 +297,7 @@ class VcsLogFiltererTest {
private fun newTrivialDataGetter(): DataGetter<VcsFullCommitDetails> {
return object : DataGetter<VcsFullCommitDetails> {
override fun getCommitData(row: Int): VcsFullCommitDetails {
override fun getCachedDataOrPlaceholder(row: Int): VcsFullCommitDetails {
throw UnsupportedOperationException()
}
......@@ -307,7 +307,7 @@ class VcsLogFiltererTest {
indicator: ProgressIndicator?) {
}
override fun getCommitDataIfAvailable(hash: Int): VcsFullCommitDetails? {
override fun getCachedData(hash: Int): VcsFullCommitDetails? {
return null
}
}
......
......@@ -294,7 +294,7 @@ class GitInteractiveRebaseLesson : GitLesson("Git.InteractiveRebase", GitLessons
private fun VcsLogData.getCommitMetadata(hash: Hash): VcsCommitMetadata {
val index = getCommitIndex(hash, roots.single())
return topCommitsCache[index] ?: miniDetailsGetter.getCommitData(index)
return topCommitsCache[index] ?: miniDetailsGetter.getCachedDataOrPlaceholder(index)
}
override val helpLinks: Map<String, String> get() = mapOf(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment