[log] Change api for method PermanentGraph#createVisibleGraph.

Changed Condition<Integer> to Set<Integer> for matched commits.
This commit is contained in:
Stanislav Erokhin
2015-02-02 16:45:43 +03:00
committed by Julia Beliaeva
parent 71c911e9f2
commit 9ca069a628
4 changed files with 8 additions and 22 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.vcs.log.graph;
import com.intellij.openapi.util.Condition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -34,7 +33,7 @@ public interface PermanentGraph<CommitId> {
@NotNull
VisibleGraph<CommitId> createVisibleGraph(@NotNull SortType sortType,
@Nullable Set<CommitId> headsOfVisibleBranches,
@Nullable Condition<CommitId> filter);
@Nullable Set<CommitId> matchedCommits);
@NotNull
List<GraphCommit<CommitId>> getAllCommits();
@@ -17,7 +17,6 @@
package com.intellij.vcs.log.graph.impl.facade;
import com.intellij.openapi.util.Condition;
import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.graph.*;
@@ -106,7 +105,7 @@ public class PermanentGraphImpl<CommitId> implements PermanentGraph<CommitId>, P
@Override
public VisibleGraph<CommitId> createVisibleGraph(@NotNull SortType sortType,
@Nullable Set<CommitId> headsOfVisibleBranches,
@Nullable Condition<CommitId> filter) {
@Nullable Set<CommitId> filter) {
CascadeLinearGraphController controller;
if (sortType == SortType.Bek) {
controller = new CollapsedLinearGraphController(new BekBaseLinearGraphController(this, myBekIntMap), this);
@@ -15,7 +15,6 @@
*/
package com.intellij.vcs.log.data;
import com.intellij.openapi.util.Condition;
import com.intellij.vcs.log.graph.GraphCommit;
import com.intellij.vcs.log.graph.PermanentGraph;
import com.intellij.vcs.log.graph.VisibleGraph;
@@ -38,7 +37,7 @@ public class EmptyPermanentGraph implements PermanentGraph<Integer> {
@NotNull
@Override
public VisibleGraph<Integer> createVisibleGraph(@NotNull SortType sortType, @Nullable Set<Integer> headsOfVisibleBranches,
@Nullable Condition<Integer> filter) {
@Nullable Set<Integer> filter) {
return EmptyVisibleGraph.getInstance();
}
@@ -97,7 +97,7 @@ class VisiblePackBuilder {
visibleGraph = EmptyVisibleGraph.getInstance();
}
else {
visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, matchingHeads, getFilterFromCommits(matchingCommits));
visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, matchingHeads, getMatchedCommitIndex(matchingCommits));
}
return Pair.create(new VisiblePack(dataPack, visibleGraph, canRequestMore), commitCount);
}
@@ -116,12 +116,7 @@ class VisiblePackBuilder {
return hash != null ? myHashMap.getCommitIndex(hash) : null;
}
});
VisibleGraph<Integer> visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, null, new Condition<Integer>() {
@Override
public boolean value(Integer integer) {
return indices.contains(integer);
}
});
VisibleGraph<Integer> visibleGraph = dataPack.getPermanentGraph().createVisibleGraph(sortType, null, indices);
return new VisiblePack(dataPack, visibleGraph, false);
}
@@ -272,23 +267,17 @@ class VisiblePackBuilder {
}
@Nullable
private Condition<Integer> getFilterFromCommits(@Nullable List<Hash> filteredCommits) {
if (filteredCommits == null) {
private Set<Integer> getMatchedCommitIndex(@Nullable List<Hash> commits) {
if (commits == null) {
return null;
}
final Set<Integer> commitSet = ContainerUtil.map2Set(filteredCommits, new Function<Hash, Integer>() {
return ContainerUtil.map2Set(commits, new Function<Hash, Integer>() {
@Override
public Integer fun(Hash hash) {
return myHashMap.getCommitIndex(hash);
}
});
return new Condition<Integer>() {
@Override
public boolean value(Integer integer) {
return commitSet.contains(integer);
}
};
}
}