[vcs-log] reformat code

This commit is contained in:
Julia Beliaeva
2015-02-13 15:52:01 +03:00
parent 763c926b88
commit 86d3416cbe
83 changed files with 520 additions and 611 deletions
@@ -2,7 +2,7 @@
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="com.intellij.vcs.log.graph.PermanentGraphBuilder"
serviceImplementation="com.intellij.vcs.log.graph.PermanentGraphBuilderImpl" />
serviceImplementation="com.intellij.vcs.log.graph.PermanentGraphBuilderImpl"/>
</extensions>
</idea-plugin>
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class GraphCommitImpl<CommitId> extends ImmutableList<CommitId> implements GraphCommit<CommitId>{
public class GraphCommitImpl<CommitId> extends ImmutableList<CommitId> implements GraphCommit<CommitId> {
@NotNull private final CommitId myId;
@NotNull private final Object myParents;
@@ -32,10 +32,12 @@ public class GraphCommitImpl<CommitId> extends ImmutableList<CommitId> implement
myTimestamp = timestamp;
if (parents.isEmpty()) {
myParents = ArrayUtil.EMPTY_OBJECT_ARRAY;
} else if (parents.size() == 1) {
}
else if (parents.size() == 1) {
myParents = parents.get(0);
assert !(myParents instanceof Object[]);
} else {
}
else {
myParents = parents.toArray();
}
}
@@ -26,6 +26,9 @@ public interface GraphLayout {
// nodeIndex must be in [0..graph.nodesCount() - 1]
int getLayoutIndex(int nodeIndex);
int getOneOfHeadNodeIndex(int nodeIndex);
@NotNull List<Integer> getHeadNodeIndex();
@NotNull
List<Integer> getHeadNodeIndex();
}
@@ -19,9 +19,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
import static com.intellij.vcs.log.graph.api.EdgeFilter.NORMAL_ALL;
import static com.intellij.vcs.log.graph.api.EdgeFilter.NORMAL_DOWN;
import static com.intellij.vcs.log.graph.api.EdgeFilter.NORMAL_UP;
import static com.intellij.vcs.log.graph.api.EdgeFilter.*;
public interface LiteLinearGraph {
int nodesCount();
@@ -36,8 +34,7 @@ public interface LiteLinearGraph {
public final boolean up;
public final boolean down;
@NotNull
public final EdgeFilter edgeFilter;
@NotNull public final EdgeFilter edgeFilter;
NodeFilter(boolean up, boolean down, @NotNull EdgeFilter edgeFilter) {
this.up = up;
@@ -17,7 +17,6 @@ package com.intellij.vcs.log.graph.api.permanent;
import com.intellij.vcs.log.graph.GraphColorManager;
import com.intellij.vcs.log.graph.api.GraphLayout;
import com.intellij.vcs.log.graph.api.LinearGraph;
import com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl;
import org.jetbrains.annotations.NotNull;
@@ -28,7 +28,8 @@ import java.util.Set;
public class BranchMatchedNodesGenerator {
@NotNull
public static UnsignedBitSet generateVisibleNodes(@NotNull PermanentLinearGraphImpl permanentGraph, @Nullable Set<Integer> headNodeIndexes) {
public static UnsignedBitSet generateVisibleNodes(@NotNull PermanentLinearGraphImpl permanentGraph,
@Nullable Set<Integer> headNodeIndexes) {
if (headNodeIndexes == null) {
UnsignedBitSet nodesVisibility = new UnsignedBitSet();
nodesVisibility.set(0, permanentGraph.nodesCount() - 1, true);
@@ -41,14 +42,11 @@ public class BranchMatchedNodesGenerator {
return generator.myNodesVisibility;
}
@NotNull
private final LiteLinearGraph myGraph;
@NotNull private final LiteLinearGraph myGraph;
@NotNull
private final UnsignedBitSet myNodesVisibility;
@NotNull private final UnsignedBitSet myNodesVisibility;
@NotNull
private final DfsUtil myDfsUtil = new DfsUtil();
@NotNull private final DfsUtil myDfsUtil = new DfsUtil();
BranchMatchedNodesGenerator(@NotNull LiteLinearGraph graph) {
myGraph = graph;
@@ -40,7 +40,10 @@ public class DottedFilterEdgesGenerator {
private final int myDownIndex;
@NotNull private final ShiftNumber myNumbers;
private DottedFilterEdgesGenerator(@NotNull CollapsedGraph collapsedGraph, @NotNull CollapsedGraph.Modification modification, int upIndex, int downIndex) {
private DottedFilterEdgesGenerator(@NotNull CollapsedGraph collapsedGraph,
@NotNull CollapsedGraph.Modification modification,
int upIndex,
int downIndex) {
myCollapsedGraph = collapsedGraph;
myModification = modification;
myLiteDelegateGraph = LinearGraphUtils.asLiteLinearGraph(collapsedGraph.getDelegatedGraph());
@@ -99,19 +102,23 @@ public class DottedFilterEdgesGenerator {
continue;
}
if (nodeIsVisible(upNode))
if (nodeIsVisible(upNode)) {
maxAdjNumber = Math.max(maxAdjNumber, myNumbers.getNumber(upNode));
else
}
else {
nearlyUp = Math.max(nearlyUp, myNumbers.getNumber(upNode));
}
}
if (nearlyUp == maxAdjNumber || nearlyUp == Integer.MIN_VALUE) {
myNumbers.setNumber(currentNodeIndex, maxAdjNumber);
} else {
}
else {
addDottedEdge(currentNodeIndex, nearlyUp);
myNumbers.setNumber(currentNodeIndex, nearlyUp);
}
} else {
}
else {
// node currentNodeIndex invisible
int nearlyUp = Integer.MIN_VALUE;
@@ -139,19 +146,23 @@ public class DottedFilterEdgesGenerator {
continue;
}
if (nodeIsVisible(downNode))
if (nodeIsVisible(downNode)) {
minAdjNumber = Math.min(minAdjNumber, myNumbers.getNumber(downNode));
else
}
else {
nearlyDown = Math.min(nearlyDown, myNumbers.getNumber(downNode));
}
}
if (nearlyDown == minAdjNumber || nearlyDown == Integer.MAX_VALUE) {
myNumbers.setNumber(currentNodeIndex, minAdjNumber);
} else {
}
else {
addDottedEdge(currentNodeIndex, nearlyDown);
myNumbers.setNumber(currentNodeIndex, nearlyDown);
}
} else {
}
else {
// node currentNodeIndex invisible
int nearlyDown = Integer.MAX_VALUE;
@@ -169,7 +180,6 @@ public class DottedFilterEdgesGenerator {
}
static class ShiftNumber {
private final int startIndex;
private final int endIndex;
@@ -15,7 +15,6 @@
*/
package com.intellij.vcs.log.graph.collapsing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
@@ -23,7 +22,6 @@ import com.intellij.vcs.log.graph.api.EdgeFilter;
import com.intellij.vcs.log.graph.api.LinearGraph;
import com.intellij.vcs.log.graph.api.elements.GraphEdge;
import com.intellij.vcs.log.graph.api.elements.GraphEdgeType;
import com.intellij.vcs.log.graph.utils.LinearGraphUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -130,10 +128,12 @@ public class EdgeStorageWrapper {
private static boolean matchedEdge(int startNodeIndex, @Nullable GraphEdge edge, @NotNull EdgeFilter filter) {
if (edge == null) return false;
if (edge.getType().isNormalEdge()) {
return (startNodeIndex == convertToInt(edge.getDownNodeIndex()) && filter.upNormal)
|| (startNodeIndex == convertToInt(edge.getUpNodeIndex()) && filter.downNormal);
return (startNodeIndex == convertToInt(edge.getDownNodeIndex()) && filter.upNormal) ||
(startNodeIndex == convertToInt(edge.getUpNodeIndex()) && filter.downNormal);
}
else {
return filter.special;
}
else return filter.special;
}
private static int convertToInt(@Nullable Integer value) {
@@ -21,14 +21,17 @@ import com.intellij.vcs.log.graph.api.LiteLinearGraph;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class FragmentGenerator {
public static class GreenFragment {
@Nullable private final Integer myUpRedNode;
@Nullable private final Integer myDownRedNode;
@NotNull private final Set<Integer> myMiddleGreenNodes;
@NotNull private final Set<Integer> myMiddleGreenNodes;
private GreenFragment(@Nullable Integer upRedNode, @Nullable Integer downRedNode, @NotNull Set<Integer> middleGreenNodes) {
myUpRedNode = upRedNode;
@@ -52,10 +55,8 @@ public class FragmentGenerator {
}
}
@NotNull
private final LiteLinearGraph myGraph;
@NotNull
private final Condition<Integer> myRedNodes;
@NotNull private final LiteLinearGraph myGraph;
@NotNull private final Condition<Integer> myRedNodes;
public FragmentGenerator(@NotNull LiteLinearGraph graph, @NotNull Condition<Integer> redNodes) {
myGraph = graph;
@@ -110,13 +111,11 @@ public class FragmentGenerator {
Integer upRedNode = getNearRedNode(startNode, maxWalkSize, true);
Integer downRedNode = getNearRedNode(startNode, maxWalkSize, false);
Set<Integer> upPart = upRedNode != null ?
getMiddleNodes(upRedNode, startNode, false) :
getWalkNodes(startNode, true, createStopFunction(maxWalkSize));
Set<Integer> upPart =
upRedNode != null ? getMiddleNodes(upRedNode, startNode, false) : getWalkNodes(startNode, true, createStopFunction(maxWalkSize));
Set<Integer> downPart = downRedNode != null ?
getMiddleNodes(startNode, downRedNode, false) :
getWalkNodes(startNode, false, createStopFunction(maxWalkSize));
Set<Integer> downPart =
downRedNode != null ? getMiddleNodes(startNode, downRedNode, false) : getWalkNodes(startNode, false, createStopFunction(maxWalkSize));
Set<Integer> middleNodes = ContainerUtil.union(upPart, downPart);
if (upRedNode != null) middleNodes.remove(upRedNode);
@@ -150,6 +149,7 @@ public class FragmentGenerator {
private static Condition<Integer> createStopFunction(final int maxNodeCount) {
return new Condition<Integer>() {
private int count = maxNodeCount;
@Override
public boolean value(Integer integer) {
count--;
@@ -29,8 +29,7 @@ class TreeSetNodeIterator {
myWalkNodes = new TreeSet<Integer>(new Comparator<Integer>() {
@Override
public int compare(@NotNull Integer o1, @NotNull Integer o2) {
if (isUp)
return o2 - o1;
if (isUp) return o2 - o1;
return o1 - o2;
}
});
@@ -33,10 +33,8 @@ import java.util.List;
import static com.intellij.util.containers.ContainerUtil.map;
public class BekBaseLinearGraphController extends CascadeLinearGraphController {
@NotNull
private final BekIntMap myBekIntMap;
@NotNull
private final LinearGraph myBekGraph;
@NotNull private final BekIntMap myBekIntMap;
@NotNull private final LinearGraph myBekGraph;
public BekBaseLinearGraphController(@NotNull PermanentGraphInfo permanentGraphInfo, @NotNull BekIntMap bekIntMap) {
super(null, permanentGraphInfo);
@@ -72,8 +70,10 @@ public class BekBaseLinearGraphController extends CascadeLinearGraphController {
Integer convertedUpIndex = upIndex == null ? null : myBekIntMap.getUsualIndex(upIndex);
Integer convertedDownIndex = downIndex == null ? null : myBekIntMap.getUsualIndex(downIndex);
return new GraphEdge(convertedUpIndex, convertedDownIndex, ((GraphEdge)graphElement).getTargetId(), ((GraphEdge)graphElement).getType());
} else if (graphElement instanceof GraphNode) {
return new GraphEdge(convertedUpIndex, convertedDownIndex, ((GraphEdge)graphElement).getTargetId(),
((GraphEdge)graphElement).getType());
}
else if (graphElement instanceof GraphNode) {
return new GraphNode(myBekIntMap.getUsualIndex((((GraphNode)graphElement).getNodeIndex())), ((GraphNode)graphElement).getType());
}
return null;
@@ -86,8 +86,7 @@ public class BekBaseLinearGraphController extends CascadeLinearGraphController {
}
private class BekLinearGraph implements LinearGraph {
@NotNull
private final LinearGraph myPermanentGraph;
@NotNull private final LinearGraph myPermanentGraph;
private BekLinearGraph() {
myPermanentGraph = myPermanentGraphInfo.getPermanentLinearGraph();
@@ -111,7 +110,8 @@ public class BekBaseLinearGraphController extends CascadeLinearGraphController {
return map(myPermanentGraph.getAdjacentEdges(myBekIntMap.getUsualIndex(nodeIndex), filter), new Function<GraphEdge, GraphEdge>() {
@Override
public GraphEdge fun(GraphEdge edge) {
return new GraphEdge(getNodeIndex(edge.getUpNodeIndex()), getNodeIndex(edge.getDownNodeIndex()), edge.getTargetId(), edge.getType());
return new GraphEdge(getNodeIndex(edge.getUpNodeIndex()), getNodeIndex(edge.getDownNodeIndex()), edge.getTargetId(),
edge.getType());
}
});
}
@@ -23,10 +23,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class CascadeLinearGraphController implements LinearGraphController {
@Nullable
private final CascadeLinearGraphController myDelegateLinearGraphController;
@NotNull
protected final PermanentGraphInfo myPermanentGraphInfo;
@Nullable private final CascadeLinearGraphController myDelegateLinearGraphController;
@NotNull protected final PermanentGraphInfo myPermanentGraphInfo;
protected CascadeLinearGraphController(@Nullable CascadeLinearGraphController delegateLinearGraphController,
@NotNull PermanentGraphInfo permanentGraphInfo) {
@@ -39,12 +37,11 @@ public abstract class CascadeLinearGraphController implements LinearGraphControl
public LinearGraphAnswer performLinearGraphAction(@NotNull LinearGraphAction action) {
LinearGraphAnswer answer = performAction(action);
if (answer == null && myDelegateLinearGraphController != null) {
answer = myDelegateLinearGraphController.performLinearGraphAction(new VisibleGraphImpl.LinearGraphActionImpl(
convertToDelegate(action.getAffectedElement()), action.getType()));
answer = myDelegateLinearGraphController.performLinearGraphAction(
new VisibleGraphImpl.LinearGraphActionImpl(convertToDelegate(action.getAffectedElement()), action.getType()));
answer = delegateGraphChanged(answer);
}
if (answer != null)
return answer;
if (answer != null) return answer;
return LinearGraphUtils.DEFAULT_GRAPH_ANSWER;
}
@@ -26,20 +26,15 @@ import java.util.HashSet;
import java.util.Set;
public class ContainingBranchesGetter {
@NotNull
private final LiteLinearGraph myGraph;
@NotNull private final LiteLinearGraph myGraph;
@NotNull
private final Set<Integer> myBranchNodeIndexes;
@NotNull private final Set<Integer> myBranchNodeIndexes;
@NotNull
private final DfsUtil myDfsUtil = new DfsUtil();
@NotNull private final DfsUtil myDfsUtil = new DfsUtil();
@NotNull
private final Flags myTempFlags;
@NotNull private final Flags myTempFlags;
public ContainingBranchesGetter(@NotNull LiteLinearGraph graph,
@NotNull Set<Integer> branchNodeIndexes) {
public ContainingBranchesGetter(@NotNull LiteLinearGraph graph, @NotNull Set<Integer> branchNodeIndexes) {
myGraph = graph;
myBranchNodeIndexes = branchNodeIndexes;
myTempFlags = new BitSetFlags(graph.nodesCount());
@@ -70,7 +65,6 @@ public class ContainingBranchesGetter {
}
private void checkAndAdd(int nodeIndex, Set<Integer> result) {
if (myBranchNodeIndexes.contains(nodeIndex))
result.add(nodeIndex);
if (myBranchNodeIndexes.contains(nodeIndex)) result.add(nodeIndex);
}
}
@@ -18,7 +18,6 @@ package com.intellij.vcs.log.graph.impl.facade;
import com.intellij.vcs.log.graph.actions.GraphAction;
import com.intellij.vcs.log.graph.actions.GraphAnswer;
import com.intellij.vcs.log.graph.api.LinearGraph;
import com.intellij.vcs.log.graph.collapsing.CollapsedGraph;
import com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -48,8 +48,7 @@ class PrintElementManagerImpl implements PrintElementManager {
@Override
public Integer fun(Integer nodeIndex) {
int nodeId = linearGraph.getNodeId(nodeIndex);
if (nodeId < 0)
return nodeId;
if (nodeId < 0) return nodeId;
return myPermanentGraph.getPermanentGraphLayout().getLayoutIndex(nodeId);
}
});
@@ -31,15 +31,12 @@ class BekBranch {
private static final int SMALL_DELTA_TIME = 60 * 60 * 4 * 1000;
@NotNull
private final LinearGraph myPermanentGraph;
@NotNull
private final List<Integer> myNodeIndexes;
@NotNull private final LinearGraph myPermanentGraph;
@NotNull private final List<Integer> myNodeIndexes;
private int myNoInsertSize;
@Nullable
private List<Integer> myPrepareForInsertPart = null;
@Nullable private List<Integer> myPrepareForInsertPart = null;
public BekBranch(@NotNull LinearGraph permanentGraph, @NotNull List<Integer> nodeIndexes) {
myPermanentGraph = permanentGraph;
@@ -51,8 +48,7 @@ class BekBranch {
assert myPrepareForInsertPart == null;
int currentNode = myNodeIndexes.get(myNoInsertSize - 1);
if (edgeRestrictions.hasRestriction(currentNode))
return;
if (edgeRestrictions.hasRestriction(currentNode)) return;
int prevIndex;
for (prevIndex = myNoInsertSize - 1; prevIndex > 0; prevIndex--) {
@@ -60,27 +56,22 @@ class BekBranch {
int downNode = myNodeIndexes.get(prevIndex);
// for correct topological order
if (edgeRestrictions.hasRestriction(upNode))
break;
if (edgeRestrictions.hasRestriction(upNode)) break;
// upNode is mergeCommit
List<Integer> downNodes = getDownNodes(myPermanentGraph, upNode);
if (downNodes.size() > 1 && downNodes.contains(downNode))
continue;
if (downNodes.size() > 1 && downNodes.contains(downNode)) continue;
// division
if (!downNodes.contains(downNode))
break;
if (!downNodes.contains(downNode)) break;
long delta = Math.abs(timestampGetter.getTimestamp(upNode) - timestampGetter.getTimestamp(downNode));
// long time between commits
if (delta > MAX_DELTA_TIME)
break;
if (delta > MAX_DELTA_TIME) break;
// if block so long
if (prevIndex < myNoInsertSize - MAX_BLOCK_SIZE && delta > SMALL_DELTA_TIME)
break;
if (prevIndex < myNoInsertSize - MAX_BLOCK_SIZE && delta > SMALL_DELTA_TIME) break;
}
myPrepareForInsertPart = myNodeIndexes.subList(prevIndex, myNoInsertSize);
@@ -30,17 +30,12 @@ import static com.intellij.vcs.log.graph.utils.LinearGraphUtils.getDownNodes;
import static com.intellij.vcs.log.graph.utils.LinearGraphUtils.getUpNodes;
class BekBranchCreator {
@NotNull
private final LinearGraph myPermanentGraph;
@NotNull
private final GraphLayoutImpl myGraphLayout;
@NotNull
private final Flags myDoneNodes;
@NotNull private final LinearGraph myPermanentGraph;
@NotNull private final GraphLayoutImpl myGraphLayout;
@NotNull private final Flags myDoneNodes;
@NotNull
private final DfsUtil myDfsUtil = new DfsUtil();
@NotNull
private final BekEdgeRestrictions myEdgeRestrictions = new BekEdgeRestrictions();
@NotNull private final DfsUtil myDfsUtil = new DfsUtil();
@NotNull private final BekEdgeRestrictions myEdgeRestrictions = new BekEdgeRestrictions();
public BekBranchCreator(@NotNull LinearGraph permanentGraph, @NotNull GraphLayoutImpl graphLayout) {
myPermanentGraph = permanentGraph;
@@ -77,8 +72,7 @@ class BekBranchCreator {
int downNode = downNodes.get(i);
if (myDoneNodes.get(downNode)) {
if (myGraphLayout.getLayoutIndex(downNode) < startLayout)
myEdgeRestrictions.addRestriction(currentNode, downNode);
if (myGraphLayout.getLayoutIndex(downNode) < startLayout) myEdgeRestrictions.addRestriction(currentNode, downNode);
}
else if (currentLayout <= myGraphLayout.getLayoutIndex(downNode)) {
@@ -22,15 +22,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
class BekBranchMerger {
@NotNull
private final List<BekBranch> myBekBranches;
@NotNull
private final BekEdgeRestrictions myEdgeRestrictions;
@NotNull
private final TimestampGetter myTimestampGetter;
@NotNull private final List<BekBranch> myBekBranches;
@NotNull private final BekEdgeRestrictions myEdgeRestrictions;
@NotNull private final TimestampGetter myTimestampGetter;
@NotNull
private final List<Integer> myInverseResultList = ContainerUtil.newArrayList();
@NotNull private final List<Integer> myInverseResultList = ContainerUtil.newArrayList();
public BekBranchMerger(@NotNull List<BekBranch> bekBranches,
@NotNull BekEdgeRestrictions edgeRestrictions,
@@ -44,7 +40,7 @@ class BekBranchMerger {
private boolean prepareLastPartsForBranches() {
boolean hasUndoneBranches = false;
for (BekBranch bekBranch : myBekBranches) {
if (!bekBranch.isDone()){
if (!bekBranch.isDone()) {
hasUndoneBranches = true;
if (bekBranch.getPrepareForInsertPart() == null) {
bekBranch.updatePrepareForInsertPart(myTimestampGetter, myEdgeRestrictions);
@@ -56,8 +52,7 @@ class BekBranchMerger {
private long getBranchLastPartTimestamp(BekBranch bekBranch) {
List<Integer> prepareForInsertPart = bekBranch.getPrepareForInsertPart();
if (prepareForInsertPart == null)
return Long.MAX_VALUE;
if (prepareForInsertPart == null) return Long.MAX_VALUE;
assert !prepareForInsertPart.isEmpty();
int nodeIndex = prepareForInsertPart.get(0);
@@ -74,8 +69,9 @@ class BekBranchMerger {
List<Integer> prepareForInsertPart = selectBranch.getPrepareForInsertPart();
assert prepareForInsertPart != null;
for (int insertedNode: prepareForInsertPart)
for (int insertedNode : prepareForInsertPart) {
myEdgeRestrictions.removeRestriction(insertedNode);
}
myInverseResultList.addAll(ContainerUtil.reverse(prepareForInsertPart));
selectBranch.doneInsertPreparedPart();
@@ -26,15 +26,13 @@ public class BekChecker {
private final static Logger LOG = Logger.getInstance("#com.intellij.vcs.log.graph.impl.facade.bek.BekChecker");
public static boolean checkLinearGraph(@NotNull LinearGraph linearGraph) {
for (int i = 0; i < linearGraph.nodesCount(); i++) {
for (int i = 0; i < linearGraph.nodesCount(); i++) {
for (int downNode : getDownNodes(linearGraph, i)) {
if (downNode <= i)
LOG.error("Illegal node: " + i + ", with downNode: " + downNode);
if (downNode <= i) LOG.error("Illegal node: " + i + ", with downNode: " + downNode);
}
for (int upNode : getUpNodes(linearGraph, i)) {
if (upNode >= i)
LOG.error("Illegal node: " + i + ", with upNode: " + upNode);
if (upNode >= i) LOG.error("Illegal node: " + i + ", with upNode: " + upNode);
}
}
return true;
@@ -19,11 +19,9 @@ import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
class BekEdgeRestrictions {
@NotNull
private final MultiMap<Integer, Integer> myUpToEdge = new MultiMap<Integer, Integer>();
@NotNull private final MultiMap<Integer, Integer> myUpToEdge = new MultiMap<Integer, Integer>();
@NotNull
private final MultiMap<Integer, Integer> myDownToEdge = new MultiMap<Integer, Integer>();
@NotNull private final MultiMap<Integer, Integer> myDownToEdge = new MultiMap<Integer, Integer>();
void addRestriction(int upNode, int downNode) {
myUpToEdge.putValue(upNode, downNode);
@@ -31,7 +29,7 @@ class BekEdgeRestrictions {
}
void removeRestriction(int downNode) {
for (int upNode: myDownToEdge.get(downNode)) {
for (int upNode : myDownToEdge.get(downNode)) {
myUpToEdge.remove(upNode, downNode);
}
}
@@ -20,5 +20,6 @@ public interface BekIntMap {
// usualIndex == id
int getBekIndex(int usualIndex);
int getUsualIndex(int bekIndex);
}
@@ -40,11 +40,9 @@ public class DuplicateParentFixer {
}
private static class DelegateGraphCommit<CommitId> implements GraphCommit<CommitId> {
@NotNull
private final GraphCommit<CommitId> myDelegate;
@NotNull private final GraphCommit<CommitId> myDelegate;
@NotNull
private final List<CommitId> myParents;
@NotNull private final List<CommitId> myParents;
private DelegateGraphCommit(@NotNull GraphCommit<CommitId> delegate, @NotNull List<CommitId> parents) {
myDelegate = delegate;
@@ -72,21 +70,20 @@ public class DuplicateParentFixer {
@NotNull
private static <CommitId> GraphCommit<CommitId> fixParentsDuplicate(@NotNull GraphCommit<CommitId> commit) {
List<CommitId> parents = commit.getParents();
if (parents.size() <= 1)
return commit;
if (parents.size() <= 1) return commit;
if (parents.size() == 2) {
CommitId commitId0 = parents.get(0);
if (!commitId0.equals(parents.get(1))) {
return commit;
} else {
}
else {
return new DelegateGraphCommit<CommitId>(commit, Collections.singletonList(commitId0));
}
}
Set<CommitId> allParents = new HashSet<CommitId>(parents);
if (parents.size() == allParents.size())
return commit;
if (parents.size() == allParents.size()) return commit;
List<CommitId> correctParents = ContainerUtil.newArrayList();
for (CommitId commitId : parents) {
@@ -52,18 +52,13 @@ public class GraphLayoutBuilder {
return builder.build();
}
@NotNull
private final LinearGraph myGraph;
@NotNull
private final int[] myLayoutIndex;
@NotNull private final LinearGraph myGraph;
@NotNull private final int[] myLayoutIndex;
@NotNull
private final List<Integer> myHeadNodeIndex;
@NotNull
private final int[] myStartLayoutIndexForHead;
@NotNull private final List<Integer> myHeadNodeIndex;
@NotNull private final int[] myStartLayoutIndexForHead;
@NotNull
private final DfsUtil myDfsUtil;
@NotNull private final DfsUtil myDfsUtil;
private int currentLayoutIndex = 1;
@@ -82,8 +77,7 @@ public class GraphLayoutBuilder {
@Override
public int fun(int currentNode) {
boolean firstVisit = myLayoutIndex[currentNode] == 0;
if (firstVisit)
myLayoutIndex[currentNode] = currentLayoutIndex;
if (firstVisit) myLayoutIndex[currentNode] = currentLayoutIndex;
int childWithoutLayoutIndex = -1;
for (int childNodeIndex : getDownNodes(myGraph, currentNode)) {
@@ -94,11 +88,11 @@ public class GraphLayoutBuilder {
}
if (childWithoutLayoutIndex == -1) {
if (firstVisit)
currentLayoutIndex++;
if (firstVisit) currentLayoutIndex++;
return DfsUtil.NextNode.NODE_NOT_FOUND;
} else {
}
else {
return childWithoutLayoutIndex;
}
}
@@ -107,7 +101,7 @@ public class GraphLayoutBuilder {
@NotNull
private GraphLayoutImpl build() {
for(int i = 0; i < myHeadNodeIndex.size(); i++) {
for (int i = 0; i < myHeadNodeIndex.size(); i++) {
int headNodeIndex = myHeadNodeIndex.get(i);
myStartLayoutIndexForHead[i] = currentLayoutIndex;
@@ -23,13 +23,10 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class GraphLayoutImpl implements GraphLayout {
@NotNull
private final IntList myLayoutIndex;
@NotNull private final IntList myLayoutIndex;
@NotNull
private final List<Integer> myHeadNodeIndex;
@NotNull
private final int[] myStartLayoutIndexForHead;
@NotNull private final List<Integer> myHeadNodeIndex;
@NotNull private final int[] myStartLayoutIndexForHead;
GraphLayoutImpl(@NotNull int[] layoutIndex, @NotNull List<Integer> headNodeIndex, @NotNull int[] startLayoutIndexForHead) {
myLayoutIndex = CompressedIntList.newInstance(layoutIndex);
@@ -61,10 +58,12 @@ public class GraphLayoutImpl implements GraphLayout {
int b = myStartLayoutIndexForHead.length - 1;
while (b > a) {
int middle = (a + b + 1) / 2;
if (myStartLayoutIndexForHead[middle] <= layoutIndex)
if (myStartLayoutIndexForHead[middle] <= layoutIndex) {
a = middle;
else
}
else {
b = middle - 1;
}
}
return a;
}
@@ -18,12 +18,12 @@ package com.intellij.vcs.log.graph.impl.permanent;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.graph.GraphCommit;
import com.intellij.vcs.log.graph.api.permanent.PermanentCommitsInfo;
import com.intellij.vcs.log.graph.utils.IntList;
import com.intellij.vcs.log.graph.utils.TimestampGetter;
import com.intellij.vcs.log.graph.utils.impl.CompressedIntList;
import com.intellij.vcs.log.graph.utils.impl.IntTimestampGetter;
import com.intellij.vcs.log.graph.GraphCommit;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -50,7 +50,8 @@ public class PermanentCommitsInfoIml<CommitId> implements PermanentCommitsInfo<C
List<CommitId> commitIdIndex;
if (isIntegerCase) {
commitIdIndex = (List<CommitId>)createCompressedIntList((List<? extends GraphCommit<Integer>>)graphCommits);
} else {
}
else {
commitIdIndex = ContainerUtil.map(graphCommits, new Function<GraphCommit<CommitId>, CommitId>() {
@Override
public CommitId fun(GraphCommit<CommitId> graphCommit) {
@@ -88,14 +89,11 @@ public class PermanentCommitsInfoIml<CommitId> implements PermanentCommitsInfo<C
};
}
@NotNull
private final TimestampGetter myTimestampGetter;
@NotNull private final TimestampGetter myTimestampGetter;
@NotNull
private final List<CommitId> myCommitIdIndexes;
@NotNull private final List<CommitId> myCommitIdIndexes;
@NotNull
private final Map<Integer, CommitId> myNotLoadCommits;
@NotNull private final Map<Integer, CommitId> myNotLoadCommits;
public PermanentCommitsInfoIml(@NotNull TimestampGetter timestampGetter,
@NotNull List<CommitId> commitIdIndex,
@@ -108,15 +106,13 @@ public class PermanentCommitsInfoIml<CommitId> implements PermanentCommitsInfo<C
@Override
@NotNull
public CommitId getCommitId(int nodeId) {
if (nodeId < 0)
return myNotLoadCommits.get(nodeId);
if (nodeId < 0) return myNotLoadCommits.get(nodeId);
return myCommitIdIndexes.get(nodeId);
}
@Override
public long getTimestamp(int nodeId) {
if (nodeId < 0)
return 0;
if (nodeId < 0) return 0;
return myTimestampGetter.getTimestamp(nodeId);
}
@@ -129,16 +125,14 @@ public class PermanentCommitsInfoIml<CommitId> implements PermanentCommitsInfo<C
@Override
public int getNodeId(@NotNull CommitId commitId) {
int indexOf = myCommitIdIndexes.indexOf(commitId);
if (indexOf != -1)
return indexOf;
if (indexOf != -1) return indexOf;
return getNotLoadNodeId(commitId);
}
private int getNotLoadNodeId(@NotNull CommitId commitId) {
for (Map.Entry<Integer, CommitId> entry : myNotLoadCommits.entrySet()) {
if (entry.getValue().equals(commitId))
return entry.getKey();
if (entry.getValue().equals(commitId)) return entry.getKey();
}
return -1;
}
@@ -173,8 +167,7 @@ public class PermanentCommitsInfoIml<CommitId> implements PermanentCommitsInfo<C
}
}
for (Map.Entry<Integer, CommitId> entry : myNotLoadCommits.entrySet()) {
if (commitIds.contains(entry.getValue()))
result.add(entry.getKey());
if (commitIds.contains(entry.getValue())) result.add(entry.getKey());
}
return result;
}
@@ -46,7 +46,8 @@ public class PermanentLinearGraphBuilder<CommitId> {
List parents = commit.getParents();
if (parents.size() == 1 && parents.get(0).equals(nextCommitHashIndex)) {
simpleNodes.set(nodeIndex, true);
} else {
}
else {
longEdgesCount += parents.size();
}
}
@@ -56,8 +57,7 @@ public class PermanentLinearGraphBuilder<CommitId> {
@Nullable
private static <CommitId> CommitId nextCommitHashIndex(List<? extends GraphCommit<CommitId>> commits, int nodeIndex) {
if (nodeIndex < commits.size() - 1)
return commits.get(nodeIndex + 1).getId();
if (nodeIndex < commits.size() - 1) return commits.get(nodeIndex + 1).getId();
return null;
}
@@ -107,7 +107,8 @@ public class PermanentLinearGraphBuilder<CommitId> {
if (myLongEdges[edgeIndex] == -1) {
myLongEdges[edgeIndex] = downNodeIndex;
return;
} else {
}
else {
throw new IllegalStateException("Edge was set early!. Up node: " + upNodeIndex + ", down node: " + downNodeIndex);
}
}
@@ -119,8 +120,7 @@ public class PermanentLinearGraphBuilder<CommitId> {
GraphCommit<CommitId> commit = myCommits.get(nodeIndex);
List<Integer> upNodes = upAdjacentNodes.remove(commit.getId());
if (upNodes == null)
upNodes = Collections.emptyList();
if (upNodes == null) upNodes = Collections.emptyList();
int edgeIndex = myNodeToEdgeIndex[nodeIndex];
for (Integer upNodeIndex : upNodes) {
@@ -95,9 +95,11 @@ public class PermanentLinearGraphImpl implements LinearGraph {
@Override
public Integer getNodeIndex(int nodeId) {
if (nodeId >= 0 && nodeId < nodesCount())
if (nodeId >= 0 && nodeId < nodesCount()) {
return nodeId;
else
}
else {
return null;
}
}
}
@@ -33,10 +33,8 @@ import java.util.Collection;
public abstract class AbstractPrintElementGenerator implements PrintElementGenerator {
@NotNull
protected final LinearGraph myLinearGraph;
@NotNull
protected final PrintElementManager myPrintElementManager;
@NotNull protected final LinearGraph myLinearGraph;
@NotNull protected final PrintElementManager myPrintElementManager;
protected AbstractPrintElementGenerator(@NotNull LinearGraph linearGraph, @NotNull PrintElementManager printElementManager) {
myLinearGraph = linearGraph;
@@ -75,7 +73,8 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener
if (type == EdgePrintElement.Type.DOWN) {
positionInCurrentRow = shortEdge.myUpPosition;
positionInOtherRow = shortEdge.myDownPosition;
} else {
}
else {
positionInCurrentRow = shortEdge.myDownPosition;
positionInOtherRow = shortEdge.myUpPosition;
}
@@ -91,8 +90,7 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener
int rowIndex = printElement.getRowIndex();
for (PrintElementWithGraphElement printElementWithGE : getPrintElements(rowIndex)) {
if (printElementWithGE.equals(printElement))
return printElementWithGE;
if (printElementWithGE.equals(printElement)) return printElementWithGE;
}
throw new IllegalStateException("Not found graphElement for this printElement: " + printElement);
}
@@ -105,8 +103,7 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener
protected abstract Collection<SimpleRowElement> getSimpleRowElements(int rowIndex);
protected static class ShortEdge {
@NotNull
public final GraphEdge myEdge;
@NotNull public final GraphEdge myEdge;
public final int myUpPosition;
public final int myDownPosition;
@@ -118,10 +115,8 @@ public abstract class AbstractPrintElementGenerator implements PrintElementGener
}
protected static class SimpleRowElement {
@NotNull
public final GraphElement myElement;
@NotNull
public final SimplePrintElement.Type myType;
@NotNull public final GraphElement myElement;
@NotNull public final SimplePrintElement.Type myType;
public final int myPosition;
public SimpleRowElement(@NotNull GraphElement element, @NotNull SimplePrintElement.Type type, int position) {
@@ -26,10 +26,8 @@ import com.intellij.vcs.log.graph.utils.LinearGraphUtils;
import org.jetbrains.annotations.NotNull;
public class ColorGetterByLayoutIndex<CommitId> {
@NotNull
private final LinearGraph myLinearGraph;
@NotNull
private final PermanentGraphInfo<CommitId> myPermanentGraphInfo;
@NotNull private final LinearGraph myLinearGraph;
@NotNull private final PermanentGraphInfo<CommitId> myPermanentGraphInfo;
public ColorGetterByLayoutIndex(@NotNull LinearGraph linearGraph, @NotNull PermanentGraphInfo<CommitId> permanentGraphInfo) {
myLinearGraph = linearGraph;
@@ -41,13 +39,15 @@ public class ColorGetterByLayoutIndex<CommitId> {
if (element instanceof GraphNode) {
upNodeIndex = ((GraphNode)element).getNodeIndex();
downNodeIndex = upNodeIndex;
} else {
}
else {
GraphEdge edge = (GraphEdge)element;
Pair<Integer, Integer> normalEdge = LinearGraphUtils.asNormalEdge(edge);
if (normalEdge != null) {
upNodeIndex = normalEdge.first;
downNodeIndex = normalEdge.second;
} else {
}
else {
upNodeIndex = LinearGraphUtils.getNotNullNodeIndex(edge);
downNodeIndex = upNodeIndex;
}
@@ -62,17 +62,18 @@ public class ColorGetterByLayoutIndex<CommitId> {
return myColorManager.getColorOfFragment(headCommitId, Math.max(upLayoutIndex, downLayoutIndex));
}
if (upLayoutIndex == myPermanentGraphInfo.getPermanentGraphLayout().getLayoutIndex(getHeadNodeId(upNodeIndex)))
if (upLayoutIndex == myPermanentGraphInfo.getPermanentGraphLayout().getLayoutIndex(getHeadNodeId(upNodeIndex))) {
return myColorManager.getColorOfBranch(headCommitId);
else
}
else {
return myColorManager.getColorOfFragment(headCommitId, upLayoutIndex);
}
}
private int getHeadNodeId(int upNodeIndex) {
int nodeId = getNodeId(upNodeIndex);
if (nodeId < 0)
return 0;
if (nodeId < 0) return 0;
return myPermanentGraphInfo.getPermanentGraphLayout().getOneOfHeadNodeIndex(nodeId);
}
@@ -82,8 +83,7 @@ public class ColorGetterByLayoutIndex<CommitId> {
private int getLayoutIndex(int upNodeIndex) {
int nodeId = getNodeId(upNodeIndex);
if (nodeId < 0)
return nodeId;
if (nodeId < 0) return nodeId;
return myPermanentGraphInfo.getPermanentGraphLayout().getLayoutIndex(nodeId);
}
@@ -31,11 +31,9 @@ public class EdgesInRowGenerator {
private final int WALK_SIZE;
@NotNull
private final LinearGraph myGraph;
@NotNull private final LinearGraph myGraph;
@NotNull
private final SLRUMap<Integer, GraphEdges> cacheNU = new SLRUMap<Integer, GraphEdges>(CACHE_SIZE, CACHE_SIZE * 2);
@NotNull private final SLRUMap<Integer, GraphEdges> cacheNU = new SLRUMap<Integer, GraphEdges>(CACHE_SIZE, CACHE_SIZE * 2);
private final SLRUMap<Integer, GraphEdges> cacheND = new SLRUMap<Integer, GraphEdges>(CACHE_SIZE, CACHE_SIZE * 2);
public EdgesInRowGenerator(@NotNull LinearGraph graph) {
@@ -153,8 +151,7 @@ public class EdgesInRowGenerator {
private static class GraphEdges {
// this must be mutably set
@NotNull
private final Set<GraphEdge> myEdges;
@NotNull private final Set<GraphEdge> myEdges;
private final int myRow;
private GraphEdges(int row) {
@@ -16,7 +16,6 @@
package com.intellij.vcs.log.graph.impl.print;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Function;
import com.intellij.util.NotNullFunction;
import com.intellij.vcs.log.graph.api.elements.GraphEdge;
import com.intellij.vcs.log.graph.api.elements.GraphElement;
@@ -29,8 +28,7 @@ import static com.intellij.vcs.log.graph.utils.LinearGraphUtils.asNormalEdge;
import static com.intellij.vcs.log.graph.utils.LinearGraphUtils.getNotNullNodeIndex;
public class GraphElementComparatorByLayoutIndex implements Comparator<GraphElement> {
@NotNull
private final NotNullFunction<Integer, Integer> myLayoutIndexGetter;
@NotNull private final NotNullFunction<Integer, Integer> myLayoutIndexGetter;
public GraphElementComparatorByLayoutIndex(@NotNull NotNullFunction<Integer, Integer> layoutIndexGetter) {
myLayoutIndexGetter = layoutIndexGetter;
@@ -43,29 +41,29 @@ public class GraphElementComparatorByLayoutIndex implements Comparator<GraphElem
GraphEdge edge2 = (GraphEdge)o2;
Pair<Integer, Integer> normalEdge1 = asNormalEdge(edge1);
Pair<Integer, Integer> normalEdge2 = asNormalEdge(edge2);
if (normalEdge1 == null)
return - compare2(edge2, new GraphNode(getNotNullNodeIndex(edge1)));
if (normalEdge2 == null)
return compare2(edge1, new GraphNode(getNotNullNodeIndex(edge2)));
if (normalEdge1 == null) return -compare2(edge2, new GraphNode(getNotNullNodeIndex(edge1)));
if (normalEdge2 == null) return compare2(edge1, new GraphNode(getNotNullNodeIndex(edge2)));
if (normalEdge1.first.equals(normalEdge2.first)) {
if (getLayoutIndex(normalEdge1.second) != getLayoutIndex(normalEdge2.second))
if (getLayoutIndex(normalEdge1.second) != getLayoutIndex(normalEdge2.second)) {
return getLayoutIndex(normalEdge1.second) - getLayoutIndex(normalEdge2.second);
else
}
else {
return normalEdge1.second - (int)normalEdge2.second;
}
}
if (normalEdge1.first < normalEdge2.first)
if (normalEdge1.first < normalEdge2.first) {
return compare2(edge1, new GraphNode(normalEdge2.first));
else
return - compare2(edge2, new GraphNode(normalEdge1.first));
}
else {
return -compare2(edge2, new GraphNode(normalEdge1.first));
}
}
if (o1 instanceof GraphEdge && o2 instanceof GraphNode)
return compare2((GraphEdge) o1, (GraphNode) o2);
if (o1 instanceof GraphEdge && o2 instanceof GraphNode) return compare2((GraphEdge)o1, (GraphNode)o2);
if (o1 instanceof GraphNode && o2 instanceof GraphEdge)
return - compare2((GraphEdge) o2, (GraphNode) o1);
if (o1 instanceof GraphNode && o2 instanceof GraphEdge) return -compare2((GraphEdge)o2, (GraphNode)o1);
assert false; // both GraphNode
return 0;
@@ -81,10 +79,12 @@ public class GraphElementComparatorByLayoutIndex implements Comparator<GraphElem
int downEdgeLI = getLayoutIndex(normalEdge.second);
int nodeLI = getLayoutIndex(node.getNodeIndex());
if (Math.max(upEdgeLI, downEdgeLI) != nodeLI)
if (Math.max(upEdgeLI, downEdgeLI) != nodeLI) {
return Math.max(upEdgeLI, downEdgeLI) - nodeLI;
else
}
else {
return normalEdge.first - node.getNodeIndex();
}
}
private int getLayoutIndex(int nodeIndex) {
@@ -46,31 +46,29 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
private static final boolean SHOW_ARROW_WHEN_SHOW_LONG_EDGES = true;
@NotNull
private final SLRUMap<Integer, List<GraphElement>> cache = new SLRUMap<Integer, List<GraphElement>>(CACHE_SIZE, CACHE_SIZE * 2);
@NotNull
private final EdgesInRowGenerator myEdgesInRowGenerator;
@NotNull
private final Comparator<GraphElement> myGraphElementComparator;
@NotNull private final SLRUMap<Integer, List<GraphElement>> cache = new SLRUMap<Integer, List<GraphElement>>(CACHE_SIZE, CACHE_SIZE * 2);
@NotNull private final EdgesInRowGenerator myEdgesInRowGenerator;
@NotNull private final Comparator<GraphElement> myGraphElementComparator;
private final int myLongSize;
private final int myShowingPartSize;
private final int myAddNearArrowSize;
public PrintElementGeneratorImpl(@NotNull LinearGraph graph,
@NotNull PrintElementManager printElementManager,
boolean showLongEdges) {
public PrintElementGeneratorImpl(@NotNull LinearGraph graph, @NotNull PrintElementManager printElementManager, boolean showLongEdges) {
super(graph, printElementManager);
myEdgesInRowGenerator = new EdgesInRowGenerator(graph);
myGraphElementComparator = printElementManager.getGraphElementComparator();
if (showLongEdges) {
myLongSize = VERY_LONG_EDGE_SIZE;
myShowingPartSize = VERY_LONG_EDGE_PART_SIZE;
if (SHOW_ARROW_WHEN_SHOW_LONG_EDGES)
if (SHOW_ARROW_WHEN_SHOW_LONG_EDGES) {
myAddNearArrowSize = LONG_EDGE_SIZE;
else
}
else {
myAddNearArrowSize = Integer.MAX_VALUE;
} else {
}
}
else {
myLongSize = LONG_EDGE_SIZE;
myShowingPartSize = LONG_EDGE_PART_SIZE;
myAddNearArrowSize = Integer.MAX_VALUE;
@@ -91,7 +89,7 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
myAddNearArrowSize = addNearArrowSize;
}
@NotNull
@NotNull
@Override
protected List<ShortEdge> getDownShortEdges(int rowIndex) {
NullableFunction<GraphEdge, Integer> endPosition = createEndPositionFunction(rowIndex);
@@ -112,7 +110,7 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
}
if (element instanceof GraphEdge) {
GraphEdge edge = (GraphEdge) element;
GraphEdge edge = (GraphEdge)element;
Integer endPos = endPosition.fun(edge);
if (endPos != null) result.add(new ShortEdge(edge, startPosition, endPos));
}
@@ -126,8 +124,9 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
List<GraphElement> visibleElementsInNextRow = getSortedVisibleElementsInRow(visibleRowIndex + 1);
final Map<GraphElement, Integer> toPosition = new HashMap<GraphElement, Integer>();
for (int position = 0; position < visibleElementsInNextRow.size(); position++)
for (int position = 0; position < visibleElementsInNextRow.size(); position++) {
toPosition.put(visibleElementsInNextRow.get(position), position);
}
return new NullableFunction<GraphEdge, Integer>() {
@Override
@@ -136,8 +135,7 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
Integer position = toPosition.get(edge);
if (position == null) {
Integer downNodeIndex = edge.getDownNodeIndex();
if (downNodeIndex != null)
position = toPosition.get(myLinearGraph.getGraphNode(downNodeIndex));
if (downNodeIndex != null) position = toPosition.get(myLinearGraph.getGraphNode(downNodeIndex));
}
return position;
}
@@ -164,22 +162,24 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
int upOffset = visibleRowIndex - normalEdge.first;
int downOffset = normalEdge.second - visibleRowIndex;
if (edgeSize >= myLongSize)
addArrowIfNeeded(result, edge, position, upOffset, downOffset, myShowingPartSize);
if (edgeSize >= myLongSize) addArrowIfNeeded(result, edge, position, upOffset, downOffset, myShowingPartSize);
if (edgeSize >= myAddNearArrowSize)
addArrowIfNeeded(result, edge, position, upOffset, downOffset, 1);
if (edgeSize >= myAddNearArrowSize) addArrowIfNeeded(result, edge, position, upOffset, downOffset, 1);
} else { // special edges
}
else { // special edges
switch (edge.getType()) {
case DOTTED_ARROW_DOWN:
case NOT_LOAD_COMMIT:
if (intEqual(edge.getUpNodeIndex(), visibleRowIndex - 1))
if (intEqual(edge.getUpNodeIndex(), visibleRowIndex - 1)) {
result.add(new SimpleRowElement(edge, SimplePrintElement.Type.DOWN_ARROW, position));
}
break;
case DOTTED_ARROW_UP:
if (intEqual(edge.getDownNodeIndex(), visibleRowIndex + 1)) // todo case 0-row arrow
{
result.add(new SimpleRowElement(edge, SimplePrintElement.Type.UP_ARROW, position));
}
break;
default:
// todo log some error (nothing here)
@@ -196,20 +196,21 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
int upOffset,
int downOffset,
int showingPartSize) {
if (upOffset == showingPartSize)
result.add(new SimpleRowElement(edge, SimplePrintElement.Type.DOWN_ARROW, position));
if (upOffset == showingPartSize) result.add(new SimpleRowElement(edge, SimplePrintElement.Type.DOWN_ARROW, position));
if (downOffset == showingPartSize)
result.add(new SimpleRowElement(edge, SimplePrintElement.Type.UP_ARROW, position));
if (downOffset == showingPartSize) result.add(new SimpleRowElement(edge, SimplePrintElement.Type.UP_ARROW, position));
}
private boolean edgeIsVisibleInRow(@NotNull GraphEdge edge, int visibleRowIndex) {
Pair<Integer, Integer> normalEdge = LinearGraphUtils.asNormalEdge(edge);
if (normalEdge == null) // e.d. edge is special. See addSpecialEdges
{
return false;
}
if (normalEdge.second - normalEdge.first < myLongSize) {
return true;
} else {
}
else {
return visibleRowIndex - normalEdge.first <= myShowingPartSize || normalEdge.second - visibleRowIndex <= myShowingPartSize;
}
}
@@ -240,8 +241,7 @@ public class PrintElementGeneratorImpl extends AbstractPrintElementGenerator {
result.add(myLinearGraph.getGraphNode(rowIndex));
for (GraphEdge edge : myEdgesInRowGenerator.getEdgesInRow(rowIndex)) {
if (edgeIsVisibleInRow(edge, rowIndex))
result.add(edge);
if (edgeIsVisibleInRow(edge, rowIndex)) result.add(edge);
}
addSpecialEdges(result, rowIndex);
@@ -38,10 +38,8 @@ public class EdgePrintElementImpl extends PrintElementWithGraphElement implement
}
}
@NotNull
private final Type myType;
@NotNull
private final LineStyle myLineStyle;
@NotNull private final Type myType;
@NotNull private final LineStyle myLineStyle;
private final int myPositionInOtherRow;
public EdgePrintElementImpl(int rowIndex,
@@ -20,17 +20,14 @@ import com.intellij.vcs.log.graph.PrintElement;
import com.intellij.vcs.log.graph.api.elements.GraphElement;
import com.intellij.vcs.log.graph.api.printer.PrintElementManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class PrintElementWithGraphElement implements PrintElement {
protected final int myRowIndex;
protected final int myPositionInCurrentRow;
@NotNull
protected final GraphElement myGraphElement;
@NotNull
protected final PrintElementManager myPrintElementManager;
@NotNull protected final GraphElement myGraphElement;
@NotNull protected final PrintElementManager myPrintElementManager;
protected PrintElementWithGraphElement(int rowIndex,
int positionInCurrentRow,
@@ -67,8 +64,10 @@ public abstract class PrintElementWithGraphElement implements PrintElement {
return myPrintElementManager.isSelected(this);
}
public static PrintElementWithGraphElement converted(@NotNull PrintElementWithGraphElement element, @NotNull GraphElement convertedGraphElement) {
return new PrintElementWithGraphElement(element.getRowIndex(), element.getPositionInCurrentRow(), convertedGraphElement, element.myPrintElementManager) {
public static PrintElementWithGraphElement converted(@NotNull PrintElementWithGraphElement element,
@NotNull GraphElement convertedGraphElement) {
return new PrintElementWithGraphElement(element.getRowIndex(), element.getPositionInCurrentRow(), convertedGraphElement,
element.myPrintElementManager) {
};
}
}
@@ -23,8 +23,7 @@ import org.jetbrains.annotations.NotNull;
public class SimplePrintElementImpl extends PrintElementWithGraphElement implements SimplePrintElement {
@NotNull
private final Type myType;
@NotNull private final Type myType;
public SimplePrintElementImpl(int rowIndex,
int positionInCurrentRow,
@@ -37,11 +37,9 @@ public class LinearFragmentGenerator {
private static final int SHORT_FRAGMENT_MAX_SIZE = 10;
private static final int MAX_SEARCH_SIZE = 10;
@NotNull
private final LiteLinearGraph myLinearGraph;
@NotNull private final LiteLinearGraph myLinearGraph;
@NotNull
private final Set<Integer> myPinnedNodes;
@NotNull private final Set<Integer> myPinnedNodes;
private final Function<Integer, List<Integer>> upNodesFun = new Function<Integer, List<Integer>>() {
@Override
@@ -69,7 +67,8 @@ public class LinearFragmentGenerator {
if (element instanceof GraphNode) {
upNodeIndex = ((GraphNode)element).getNodeIndex();
downNodeIndex = upNodeIndex;
} else {
}
else {
Pair<Integer, Integer> graphEdge = LinearGraphUtils.asNormalEdge(((GraphEdge)element));
if (graphEdge == null) return null;
@@ -79,8 +78,7 @@ public class LinearFragmentGenerator {
for (int i = 0; i < MAX_SEARCH_SIZE; i++) {
GraphFragment graphFragment = getDownFragment(upNodeIndex);
if (graphFragment != null && graphFragment.downNodeIndex >= downNodeIndex)
return graphFragment;
if (graphFragment != null && graphFragment.downNodeIndex >= downNodeIndex) return graphFragment;
List<Integer> upNodes = myLinearGraph.getNodes(upNodeIndex, UP);
if (upNodes.size() != 1) {
@@ -122,31 +120,28 @@ public class LinearFragmentGenerator {
@Nullable
private GraphFragment getLongFragment(@Nullable GraphFragment startFragment, int bound) {
if (startFragment == null)
return null;
if (startFragment == null) return null;
GraphFragment shortFragment;
int maxDown = startFragment.downNodeIndex;
while ((shortFragment = getDownFragment(maxDown)) != null && !myPinnedNodes.contains(maxDown)) {
maxDown = shortFragment.downNodeIndex;
if (maxDown - startFragment.downNodeIndex > bound)
break;
if (maxDown - startFragment.downNodeIndex > bound) break;
}
int maxUp = startFragment.upNodeIndex;
while ((shortFragment = getUpFragment(maxUp)) != null && !myPinnedNodes.contains(maxUp)) {
maxUp = shortFragment.upNodeIndex;
if (startFragment.upNodeIndex - maxUp > bound)
break;
if (startFragment.upNodeIndex - maxUp > bound) break;
}
if (maxUp != startFragment.upNodeIndex || maxDown != startFragment.downNodeIndex) {
return new GraphFragment(maxUp, maxDown);
} else {
}
else {
// start fragment is Simple
if (myLinearGraph.getNodes(startFragment.upNodeIndex, DOWN).size() != 1)
return startFragment;
if (myLinearGraph.getNodes(startFragment.upNodeIndex, DOWN).size() != 1) return startFragment;
}
return null;
}
@@ -172,8 +167,7 @@ public class LinearFragmentGenerator {
}
}
if (nextBlackNode == -1)
return null;
if (nextBlackNode == -1) return null;
if (grayNodes.size() == 1) {
endNode = nextBlackNode;
@@ -181,18 +175,19 @@ public class LinearFragmentGenerator {
}
List<Integer> nextGrayNodes = getNextNodes.fun(nextBlackNode);
if (nextGrayNodes.isEmpty() || thisNodeCantBeInMiddle.contains(nextBlackNode))
return null;
if (nextGrayNodes.isEmpty() || thisNodeCantBeInMiddle.contains(nextBlackNode)) return null;
blackNodes.add(nextBlackNode);
grayNodes.remove(nextBlackNode);
grayNodes.addAll(nextGrayNodes);
}
if (endNode != -1)
if (endNode != -1) {
return Pair.create(startNode, endNode);
else
}
else {
return null;
}
}
public static class GraphFragment {
@@ -41,11 +41,12 @@ public class LinearBekController extends CascadeLinearGraphController {
public LinearBekController(@NotNull BekBaseLinearGraphController controller, @NotNull PermanentGraphInfo permanentGraphInfo) {
super(controller, permanentGraphInfo);
myCompiledGraph = new LinearBekGraph(getDelegateLinearGraphController().getCompiledGraph());
myLinearBekGraphBuilder = new LinearBekGraphBuilder(myCompiledGraph, new BekGraphLayout(permanentGraphInfo.getPermanentGraphLayout(), controller.getBekIntMap()));
myLinearBekGraphBuilder = new LinearBekGraphBuilder(myCompiledGraph, new BekGraphLayout(permanentGraphInfo.getPermanentGraphLayout(),
controller.getBekIntMap()));
long start = System.currentTimeMillis();
myLinearBekGraphBuilder.collapseAll();
System.err.println((System.currentTimeMillis() - start) / 1000.0 + " sec");
System.err.println("Linear bek took " + (System.currentTimeMillis() - start) / 1000.0 + " sec");
}
@NotNull
@@ -27,7 +27,10 @@ import com.intellij.vcs.log.graph.utils.LinearGraphUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public class LinearBekGraph implements LinearGraph {
@NotNull protected final LinearGraph myGraph;
@@ -103,7 +106,7 @@ public class LinearBekGraph implements LinearGraph {
}
});
for (GraphEdge graphEdge: downDottedEdges) {
for (GraphEdge graphEdge : downDottedEdges) {
assert graphEdge.getType() == GraphEdgeType.DOTTED;
addedEdges.addAll(expandEdge(graphEdge));
}
@@ -17,7 +17,6 @@ package com.intellij.vcs.log.graph.linearBek;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.vcs.log.graph.api.EdgeFilter;
import com.intellij.vcs.log.graph.api.GraphLayout;
import com.intellij.vcs.log.graph.api.elements.GraphEdge;
@@ -30,7 +29,10 @@ import gnu.trove.TIntIterator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
class LinearBekGraphBuilder {
private static final int MAX_BLOCK_SIZE = 200;
@@ -246,6 +248,7 @@ class LinearBekGraphBuilder {
myBlockBody.add(body);
}
@NotNull
public TIntHashSet getTails() {
return myTails;
}
@@ -37,7 +37,8 @@ public class DfsUtil {
int nextNode = nextNodeFun.fun(myStack.peek());
if (nextNode != NextNode.NODE_NOT_FOUND) {
myStack.push(nextNode);
} else {
}
else {
myStack.pop();
}
}
@@ -20,7 +20,10 @@ package com.intellij.vcs.log.graph.utils;
*/
public interface Flags {
int size();
boolean get(int index);
void set(int index, boolean value);
void setAll(boolean value);
}
@@ -32,11 +32,11 @@ public class IntIntMultiMap {
if (values == null) {
int[] newValues = {value};
myKeyToArrayMap.put(key, newValues);
} else {
}
else {
int[] newValues = new int[values.length + 1];
for (int i = 0; i < values.length; i++) {
if (values[i] == value)
return;
if (values[i] == value) return;
newValues[i] = values[i];
}
newValues[newValues.length - 1] = value;
@@ -47,16 +47,14 @@ public class IntIntMultiMap {
public void remove(int key, int value) {
int removeIndex = -1;
int[] values = myKeyToArrayMap.get(key);
if (values == null)
return;
if (values == null) return;
for (int i = 0; i < values.length; i++) {
if (values[i] == value) {
removeIndex = i;
break;
}
}
if (removeIndex == -1)
return;
if (removeIndex == -1) return;
if (values.length == 1) {
myKeyToArrayMap.remove(key);
@@ -64,11 +62,13 @@ public class IntIntMultiMap {
}
int[] newValues = new int[values.length - 1];
for (int i = 0; i < newValues.length; i++) {
if (i >= removeIndex)
for (int i = 0; i < newValues.length; i++) {
if (i >= removeIndex) {
newValues[i] = values[i + 1];
else
}
else {
newValues[i] = values[i];
}
}
myKeyToArrayMap.put(key, newValues);
}
@@ -93,10 +93,12 @@ public class IntIntMultiMap {
@NotNull
public int[] getAsArray(int key) {
int[] result = myKeyToArrayMap.get(key);
if (result == null)
if (result == null) {
return EMPTY;
else
}
else {
return result;
}
}
public boolean isEmpty() {
@@ -20,5 +20,6 @@ package com.intellij.vcs.log.graph.utils;
*/
public interface IntList {
int size();
int get(int index);
}
@@ -20,7 +20,9 @@ package com.intellij.vcs.log.graph.utils;
*/
public interface IntToIntMap {
int shortSize();
int longSize();
int getLongIndex(int shortIndex); // must be very fast
/**
@@ -21,6 +21,7 @@ package com.intellij.vcs.log.graph.utils;
public interface TimestampGetter {
int size();
long getTimestamp(int index);
}
@@ -20,10 +20,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.BitSet;
public class UnsignedBitSet implements Cloneable {
@NotNull
private final BitSet myPositiveSet;
@NotNull
private final BitSet myNegativeSet;
@NotNull private final BitSet myPositiveSet;
@NotNull private final BitSet myNegativeSet;
public UnsignedBitSet(@NotNull BitSet positiveSet, @NotNull BitSet negativeSet) {
myPositiveSet = positiveSet;
@@ -39,21 +37,26 @@ public class UnsignedBitSet implements Cloneable {
}
public void set(int bitIndex, boolean value) {
if (bitIndex >= 0)
if (bitIndex >= 0) {
myPositiveSet.set(bitIndex, value);
else
}
else {
myNegativeSet.set(toPositive(bitIndex), value);
}
}
// boundaries included
public void set(int fromIndex, int toIndex, boolean value) {
if (fromIndex > toIndex)
if (fromIndex > toIndex) {
throw new IndexOutOfBoundsException("fromIndex: " + fromIndex +
" > toIndex: " + toIndex);
if (fromIndex >= 0)
}
if (fromIndex >= 0) {
myPositiveSet.set(fromIndex, toIndex + 1, value);
else if (toIndex < 0)
}
else if (toIndex < 0) {
myNegativeSet.set(toPositive(toIndex), toPositive(fromIndex) + 1, value);
}
else {
myPositiveSet.set(0, toIndex + 1, value);
myNegativeSet.set(toPositive(-1), toPositive(fromIndex) + 1, value);
@@ -61,10 +64,12 @@ public class UnsignedBitSet implements Cloneable {
}
public boolean get(int bitIndex) {
if (bitIndex >= 0)
if (bitIndex >= 0) {
return myPositiveSet.get(bitIndex);
else
}
else {
return myNegativeSet.get(toPositive(bitIndex));
}
}
@Override
@@ -24,15 +24,15 @@ public abstract class AbstractIntToIntMap implements IntToIntMap {
public int getShortIndex(int longIndex) {
checkLongIndex(longIndex);
if (shortSize() == 0 || getLongIndex(0) > longIndex)
return 0;
if (shortSize() == 0 || getLongIndex(0) > longIndex) return 0;
int a = 0;
int b = shortSize() - 1;
while (b > a + 1) {
int middle = (a + b) / 2;
if (getLongIndex(middle) <= longIndex) {
a = middle;
} else {
}
else {
b = middle;
}
}
@@ -40,18 +40,21 @@ public abstract class AbstractIntToIntMap implements IntToIntMap {
}
protected void checkLongIndex(int longIndex) {
if (longIndex < 0 || longIndex >= longSize())
if (longIndex < 0 || longIndex >= longSize()) {
throw new IndexOutOfBoundsException("LongSize is: " + longSize() + ", but longIndex: " + longIndex);
}
}
protected void checkShortIndex(int shortIndex) {
if (shortIndex < 0 || shortIndex >= shortSize())
if (shortIndex < 0 || shortIndex >= shortSize()) {
throw new IndexOutOfBoundsException("ShortSize is: " + shortSize() + ", but shortIndex: " + shortIndex);
}
}
protected void checkUpdateParameters(int startLongIndex, int endLongIndex) {
if (startLongIndex < 0 || endLongIndex < startLongIndex || endLongIndex >= longSize())
if (startLongIndex < 0 || endLongIndex < startLongIndex || endLongIndex >= longSize()) {
throw new IllegalArgumentException(
"ShortSize is: " + shortSize() + ", but updateRequest is: (" + startLongIndex +", " + endLongIndex + ")");
"ShortSize is: " + shortSize() + ", but updateRequest is: (" + startLongIndex + ", " + endLongIndex + ")");
}
}
}
@@ -25,21 +25,18 @@ public class BitSetFlags implements Flags {
private final int mySize;
@NotNull
private final BitSet myBitSet;
@NotNull private final BitSet myBitSet;
// default value is false
public BitSetFlags(int size) {
if (size < 0)
throw new NegativeArraySizeException("size < 0: " + size);
if (size < 0) throw new NegativeArraySizeException("size < 0: " + size);
mySize = size;
myBitSet = new BitSet();
}
public BitSetFlags(int size, boolean defaultValue) {
this(size);
if (defaultValue)
setAll(true);
if (defaultValue) setAll(true);
}
@Override
@@ -65,10 +62,8 @@ public class BitSetFlags implements Flags {
}
private void checkRange(int index) {
if (index < 0)
throw new IndexOutOfBoundsException("index < 0:" + index);
if (index >= mySize)
throw new IndexOutOfBoundsException("index: " + index + " >= mySize: " + mySize);
if (index < 0) throw new IndexOutOfBoundsException("index < 0:" + index);
if (index >= mySize) throw new IndexOutOfBoundsException("index: " + index + " >= mySize: " + mySize);
}
@@ -35,9 +35,8 @@ class ByteArrayUtils {
if (value < 0) value = ~value;
value >>= BYTE_OFFSET - 1;
for (int i = 1; i < 4; i++) {
if (value == 0)
return i;
for (int i = 1; i < 4; i++) {
if (value == 0) return i;
value >>= BYTE_OFFSET;
}
return 4;
@@ -45,7 +44,7 @@ class ByteArrayUtils {
public static void writeDelta(int startIndex, int value, int sizeOf, byte[] bytes) {
for (int i = sizeOf - 1; i >= 0; i--) {
bytes[startIndex + i] = (byte) value;
bytes[startIndex + i] = (byte)value;
value >>= BYTE_OFFSET;
}
}
@@ -69,8 +68,7 @@ class ByteArrayUtils {
}
public static int groundPointCount(int arraySize, int blockSize) {
if (arraySize == 0)
return 1;
if (arraySize == 0) return 1;
return (arraySize - 1) / blockSize + 1;
}
@@ -44,7 +44,7 @@ public class CompressedIntList implements IntList {
@NotNull
public static IntList newInstance(final IntList delegateList, final int blockSize) {
if (blockSize < 1) throw new IllegalArgumentException("Unsupported blockSize:" + blockSize);
if (blockSize < 1) throw new IllegalArgumentException("Unsupported blockSize:" + blockSize);
if (delegateList.size() == 0) return new FullIntList(new int[0]);
@@ -61,19 +61,18 @@ public class CompressedIntList implements IntList {
});
int[] strongValues = new int[(delegateList.size() - 1) / blockSize + 1];
for (int i = 0; i < strongValues.length; i++)
for (int i = 0; i < strongValues.length; i++) {
strongValues[i] = delegateList.get(i * blockSize);
}
return new CompressedIntList(blockSize, strongValues, intDeltaCompressor);
}
private final int myBlockSize;
@NotNull
private final int[] myStrongValues;
@NotNull private final int[] myStrongValues;
@NotNull
private final IntList myCompressedDeltas;
@NotNull private final IntList myCompressedDeltas;
private CompressedIntList(int blockSize, @NotNull int[] strongValues, @NotNull final IntList compressedDeltas) {
myBlockSize = blockSize;
@@ -20,8 +20,7 @@ import com.intellij.vcs.log.graph.utils.UpdatableIntToIntMap;
import org.jetbrains.annotations.NotNull;
public class IDIntToIntMap implements IntToIntMap {
@NotNull
public static final UpdatableIntToIntMap EMPTY = new EmptyIDIntToIntMap();
@NotNull public static final UpdatableIntToIntMap EMPTY = new EmptyIDIntToIntMap();
private final int size;
@@ -25,15 +25,14 @@ import org.jetbrains.annotations.NotNull;
@NotNull
public static IntDeltaCompressor newInstance(@NotNull IntList deltaList) {
if (deltaList.size() < 0)
throw new NegativeArraySizeException("size < 0: " + deltaList.size());
if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size());
int bytesAfterCompression = ByteArrayUtils.countBytesAfterCompression(deltaList);
Flags startedDeltaIndex = new BitSetFlags(bytesAfterCompression);
byte[] compressedDeltas = new byte[bytesAfterCompression];
int currentStartIndex = 0;
for (int i = 0; i < deltaList.size(); i++) {
for (int i = 0; i < deltaList.size(); i++) {
startedDeltaIndex.set(currentStartIndex, true);
int value = deltaList.get(i);
@@ -59,10 +58,10 @@ import org.jetbrains.annotations.NotNull;
// [left, right)
public int getSumOfInterval(int left, int right) {
if (left < 0 || left > right || right > size())
throw new IllegalArgumentException("Size is: " + size() + ", but interval is: (" + left +", " + right + ")");
if (left == size())
return 0;
if (left < 0 || left > right || right > size()) {
throw new IllegalArgumentException("Size is: " + size() + ", but interval is: (" + left + ", " + right + ")");
}
if (left == size()) return 0;
int startIndex = myStartIndexMap.getLongIndex(left);
int sum = 0;
@@ -76,8 +75,7 @@ import org.jetbrains.annotations.NotNull;
@Override
public int get(int index) {
if (index < 0 || index >= size())
throw new IllegalArgumentException("Size is: " + size() + ", but index is: " + index);
if (index < 0 || index >= size()) throw new IllegalArgumentException("Size is: " + size() + ", but index is: " + index);
int startIndex = myStartIndexMap.getLongIndex(index);
int sizeOf = getNextStartIndex(startIndex) - startIndex;
@@ -91,8 +89,7 @@ import org.jetbrains.annotations.NotNull;
private int getNextStartIndex(int currentIndex) {
for (int i = currentIndex + 1; i < myStartedDeltaIndex.size(); i++) {
if (myStartedDeltaIndex.get(i))
return i;
if (myStartedDeltaIndex.get(i)) return i;
}
return myStartedDeltaIndex.size();
}
@@ -37,14 +37,13 @@ public class IntTimestampGetter implements TimestampGetter {
@NotNull
public static IntTimestampGetter newInstance(@NotNull TimestampGetter delegateGetter, int blockSize) {
if (delegateGetter.size() < 0)
throw new NegativeArraySizeException("delegateGetter.size() < 0: " + delegateGetter.size());
if (delegateGetter.size() == 0)
throw new IllegalArgumentException("Empty TimestampGetter not supported");
if (delegateGetter.size() < 0) throw new NegativeArraySizeException("delegateGetter.size() < 0: " + delegateGetter.size());
if (delegateGetter.size() == 0) throw new IllegalArgumentException("Empty TimestampGetter not supported");
long[] saveTimestamps = new long[(delegateGetter.size() - 1) / blockSize + 1];
for (int i = 0; i < saveTimestamps.length; i++)
for (int i = 0; i < saveTimestamps.length; i++) {
saveTimestamps[i] = delegateGetter.getTimestamp(blockSize * i);
}
Map<Integer, Long> brokenDeltas = new HashMap<Integer, Long>();
int[] deltas = new int[delegateGetter.size()];
@@ -54,19 +53,16 @@ public class IntTimestampGetter implements TimestampGetter {
long delta = delegateGetter.getTimestamp(i) - delegateGetter.getTimestamp(blockIndex);
int intDelta = deltaToInt(delta);
deltas[i] = intDelta;
if (intDelta == BROKEN_DELTA)
brokenDeltas.put(i, delta);
if (intDelta == BROKEN_DELTA) brokenDeltas.put(i, delta);
}
return new IntTimestampGetter(deltas, blockSize, saveTimestamps, brokenDeltas);
}
private static int deltaToInt(long delta) {
if (delta >= 0 && delta <= MAX_DELTA)
return (int)delta;
if (delta >= 0 && delta <= MAX_DELTA) return (int)delta;
if (delta < 0 && -delta <= MAX_DELTA)
return (int)delta;
if (delta < 0 && -delta <= MAX_DELTA) return (int)delta;
return BROKEN_DELTA;
}
@@ -74,8 +70,7 @@ public class IntTimestampGetter implements TimestampGetter {
// myDeltas[i] = getTimestamp(i + 1) - getTimestamp(i)
private final IntList myDeltas;
@NotNull
private final Map<Integer, Long> myBrokenDeltas;
@NotNull private final Map<Integer, Long> myBrokenDeltas;
private final int myBlockSize;
@@ -104,16 +99,13 @@ public class IntTimestampGetter implements TimestampGetter {
private long getDelta(int index) {
int delta = myDeltas.get(index);
if (delta != BROKEN_DELTA)
return delta;
if (delta != BROKEN_DELTA) return delta;
return myBrokenDeltas.get(index);
}
private void checkRange(int index) {
if (index < 0)
throw new IndexOutOfBoundsException("index < 0:" + index);
if (index >= size())
throw new IndexOutOfBoundsException("index: " + index + " >= size: " + size());
if (index < 0) throw new IndexOutOfBoundsException("index < 0:" + index);
if (index >= size()) throw new IndexOutOfBoundsException("index: " + index + " >= size: " + size());
}
}
@@ -40,19 +40,15 @@ public class ListIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
}
/**
*
* @param blockSize
* memory usage is: longSize / blockSize;
* getLongIndex access need: log(longSize) + blockSize
* getShortIndex access need: blockSize
* @param blockSize memory usage is: longSize / blockSize;
* getLongIndex access need: log(longSize) + blockSize
* getShortIndex access need: blockSize
*/
@NotNull
public static UpdatableIntToIntMap newInstance(@NotNull final BooleanFunction<Integer> thisIsVisible, final int longSize, int blockSize) {
if (longSize < 0)
throw new NegativeArraySizeException("size < 0: " + longSize);
if (longSize < 0) throw new NegativeArraySizeException("size < 0: " + longSize);
if (longSize == 0)
return IDIntToIntMap.EMPTY;
if (longSize == 0) return IDIntToIntMap.EMPTY;
int sumSize = (longSize - 1) / blockSize + 1;
ListIntToIntMap listIntToIntMap = new ListIntToIntMap(thisIsVisible, longSize, blockSize, new int[sumSize]);
@@ -60,8 +56,7 @@ public class ListIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
return listIntToIntMap;
}
@NotNull
final BooleanFunction<Integer> myThisIsVisible;
@NotNull final BooleanFunction<Integer> myThisIsVisible;
private final int myLongSize;
@@ -97,23 +92,22 @@ public class ListIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
int b = mySubSumOfBlocks.length - 1;
while (b > a) {
int middle = (a + b) / 2;
if (mySubSumOfBlocks[middle] <= shortIndex)
if (mySubSumOfBlocks[middle] <= shortIndex) {
a = middle + 1;
else
}
else {
b = middle;
}
}
assert a == b;
int blockIndex = a;
int prefVisibleCount = 0;
if (blockIndex > 0)
prefVisibleCount = mySubSumOfBlocks[blockIndex - 1];
if (blockIndex > 0) prefVisibleCount = mySubSumOfBlocks[blockIndex - 1];
for (int longIndex = blockIndex * myBlockSize; longIndex < myLongSize; longIndex++) {
if (myThisIsVisible.fun(longIndex))
prefVisibleCount++;
if (prefVisibleCount > shortIndex)
return longIndex;
if (myThisIsVisible.fun(longIndex)) prefVisibleCount++;
if (prefVisibleCount > shortIndex) return longIndex;
}
throw new IllegalAccessError("This should never happen!");
@@ -125,25 +119,25 @@ public class ListIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
int blockIndex = getRelevantSumIndex(longIndex);
int countVisible = calculateSumForBlock(blockIndex, longIndex);
if (countVisible > 0)
if (countVisible > 0) {
return countVisible - 1;
else
}
else {
return 0;
}
}
// for calculate sum used blocks with index less that blockIndex
private int calculateSumForBlock(int blockIndex, int lastLongIndex) {
int sum = 0;
if (blockIndex > 0)
sum = mySubSumOfBlocks[blockIndex - 1];
if (blockIndex > 0) sum = mySubSumOfBlocks[blockIndex - 1];
for (int longIndex = blockIndex * myBlockSize; longIndex <= lastLongIndex; longIndex++) {
if (myThisIsVisible.fun(longIndex))
sum++;
if (myThisIsVisible.fun(longIndex)) sum++;
}
return sum;
}
private void updateSumWithCorrectPrevious(int blockIndex) {
int endIndex = Math.min(myLongSize, (blockIndex + 1) * myBlockSize);
@@ -157,12 +151,14 @@ public class ListIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
int endSumIndex = getRelevantSumIndex(endLongIndex);
int prevEndSum = mySubSumOfBlocks[endSumIndex];
for (int blockIndex = startSumIndex; blockIndex <= endSumIndex; blockIndex++)
for (int blockIndex = startSumIndex; blockIndex <= endSumIndex; blockIndex++) {
updateSumWithCorrectPrevious(blockIndex);
}
int sumDelta = mySubSumOfBlocks[endSumIndex] - prevEndSum;
for (int blockIndex = endSumIndex + 1; blockIndex < mySubSumOfBlocks.length; blockIndex++)
for (int blockIndex = endSumIndex + 1; blockIndex < mySubSumOfBlocks.length; blockIndex++) {
mySubSumOfBlocks[blockIndex] += sumDelta;
}
}
@@ -29,10 +29,8 @@ public class PermanentListIntToIntMap extends AbstractIntToIntMap implements Int
@NotNull
public static IntToIntMap newInstance(@NotNull final Flags visibleIndexes, int shortSize, int blockSize) {
if (shortSize < 0)
throw new NegativeArraySizeException("shortSize < 0: " + shortSize);
if (shortSize == 0)
return createEmptyIntToIntMap(visibleIndexes);
if (shortSize < 0) throw new NegativeArraySizeException("shortSize < 0: " + shortSize);
if (shortSize == 0) return createEmptyIntToIntMap(visibleIndexes);
int[] strongShortIndexes = new int[(shortSize - 1) / blockSize + 1];
@@ -41,8 +39,7 @@ public class PermanentListIntToIntMap extends AbstractIntToIntMap implements Int
if (visibleIndexes.get(longIndex)) {
currentShortIndex++;
if (currentShortIndex % blockSize == 0)
strongShortIndexes[currentShortIndex / blockSize] = longIndex;
if (currentShortIndex % blockSize == 0) strongShortIndexes[currentShortIndex / blockSize] = longIndex;
}
}
@@ -74,15 +71,13 @@ public class PermanentListIntToIntMap extends AbstractIntToIntMap implements Int
};
}
@NotNull
private final Flags myVisibleIndexes;
@NotNull private final Flags myVisibleIndexes;
private final int myLongSize;
private final int myShortSize;
private final int myBlockSize;
@NotNull
private final int[] myStrongShortIndexes;
@NotNull private final int[] myStrongShortIndexes;
private PermanentListIntToIntMap(@NotNull Flags visibleIndexes, int shortSize, int blockSize, @NotNull int[] strongShortIndexes) {
myVisibleIndexes = visibleIndexes;
@@ -111,13 +106,11 @@ public class PermanentListIntToIntMap extends AbstractIntToIntMap implements Int
int sub = shortIndex - strongIndex * myBlockSize;
for (int longIndex = myStrongShortIndexes[strongIndex]; longIndex < myLongSize; longIndex++) {
if (myVisibleIndexes.get(longIndex))
sub--;
if (sub == -1)
return longIndex;
if (myVisibleIndexes.get(longIndex)) sub--;
if (sub == -1) return longIndex;
}
throw new IllegalStateException("Not found long index for short index: " + shortIndex
+ ". Long & short size is: " + myLongSize + ", " + myShortSize + ".");
throw new IllegalStateException(
"Not found long index for short index: " + shortIndex + ". Long & short size is: " + myLongSize + ", " + myShortSize + ".");
}
}
@@ -45,7 +45,8 @@ public class SetListenerController<Listener> implements ListenerController<Liste
}
public void callListeners(Consumer<Listener> listenerConsumer) {
for (Listener listener : myListeners)
for (Listener listener : myListeners) {
listenerConsumer.consume(listener);
}
}
}
@@ -24,8 +24,7 @@ public class SmartDeltaCompressor implements IntList {
@NotNull
public static SmartDeltaCompressor newInstance(@NotNull IntList deltaList) {
if (deltaList.size() < 0)
throw new NegativeArraySizeException("size < 0: " + deltaList.size());
if (deltaList.size() < 0) throw new NegativeArraySizeException("size < 0: " + deltaList.size());
int bytesAfterCompression = countBytesAfterCompression(deltaList);
byte[] deltas = new byte[bytesAfterCompression];
@@ -43,8 +42,7 @@ public class SmartDeltaCompressor implements IntList {
for (int rem = 0; rem < 64; rem++) {
int index = main * 64 + rem;
if (index >= size)
break;
if (index >= size) break;
int sizeOf = sizeOf(deltaList.get(index));
writeDelta(offset, deltaList.get(index), sizeOf, deltas);
@@ -55,10 +53,8 @@ public class SmartDeltaCompressor implements IntList {
* 2 -> 01
* 1 -> 00
*/
if (sizeOf == 3 || sizeOf == 4)
majorBits[main] |= mask;
if (sizeOf == 2 || sizeOf == 4)
minorBits[main] |= mask;
if (sizeOf == 3 || sizeOf == 4) majorBits[main] |= mask;
if (sizeOf == 2 || sizeOf == 4) minorBits[main] |= mask;
offset += sizeOf;
}
@@ -97,7 +93,7 @@ public class SmartDeltaCompressor implements IntList {
long major = myMajorBits[main] << shift;
long minor = myMinorBits[main] << shift;
int sizeOf = (int) (2 * (major >>> 63) + (minor >>> 63) + 1);
int sizeOf = (int)(2 * (major >>> 63) + (minor >>> 63) + 1);
int endIndex = myStrongIndexes[main] + 2 * Long.bitCount(major) + Long.bitCount(minor) + rem + 1;
@@ -23,19 +23,19 @@ import org.jetbrains.annotations.NotNull;
public class TreeIntToIntMap extends AbstractIntToIntMap implements UpdatableIntToIntMap {
public static UpdatableIntToIntMap newInstance(@NotNull final BooleanFunction<Integer> thisIsVisible, final int longSize) {
if (longSize < 0)
throw new NegativeArraySizeException("size < 0: " + longSize);
if (longSize < 0) throw new NegativeArraySizeException("size < 0: " + longSize);
if (longSize == 0)
return IDIntToIntMap.EMPTY;
if (longSize == 0) return IDIntToIntMap.EMPTY;
int countLevels; // longSize -> countLevels: 1..2 -> 2; 3..4 -> 3; 5..8 -> 4
if (longSize == 1)
if (longSize == 1) {
countLevels = 2;
else
}
else {
countLevels = countDigits(longSize - 1) + 1;
}
int[] emptyTree = new int[(1<<(countLevels - 1))];
int[] emptyTree = new int[(1 << (countLevels - 1))];
TreeIntToIntMap intToIntMap = new TreeIntToIntMap(thisIsVisible, longSize, countLevels, emptyTree);
intToIntMap.update(0, longSize - 1);
return intToIntMap;
@@ -50,8 +50,7 @@ public class TreeIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
return count;
}
@NotNull
private final BooleanFunction<Integer> myThisIsVisible;
@NotNull private final BooleanFunction<Integer> myThisIsVisible;
private final int myLongSize;
private final int myCountLevels;
@@ -83,8 +82,9 @@ public class TreeIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
for (int level = 0; level < myCountLevels - 1; level++) {
int child = node << 1;
int countInChildNode = getCountInNode(child);
if (countInChildNode > shortIndex)
if (countInChildNode > shortIndex) {
node = child;
}
else {
node = child + 1;
shortIndex -= countInChildNode;
@@ -114,8 +114,7 @@ public class TreeIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
}
private int updateNodeCount(int node) {
if (isLastLevel(node))
return getCountInLastLevel(node);
if (isLastLevel(node)) return getCountInLastLevel(node);
int child = node << 1;
myTree[node] = updateNodeCount(child) + updateNodeCount(child + 1);
@@ -124,17 +123,21 @@ public class TreeIntToIntMap extends AbstractIntToIntMap implements UpdatableInt
private int getCountInLastLevel(int node) {
node -= myTree.length;
if (node < myLongSize && myThisIsVisible.fun(node))
if (node < myLongSize && myThisIsVisible.fun(node)) {
return 1;
else
}
else {
return 0;
}
}
private int getCountInNode(int node) {
if (isLastLevel(node))
if (isLastLevel(node)) {
return getCountInLastLevel(node);
else
}
else {
return myTree[node];
}
}
}
@@ -50,10 +50,8 @@ public class PositionUtil {
int r = CIRCLE_RADIUS;
int x0 = WIDTH_NODE * position + WIDTH_NODE / 2;
int y0 = HEIGHT_CELL / 2;
if (type == SimplePrintElement.Type.DOWN_ARROW)
y0 = PrintParameters.HEIGHT_CELL - r;
if (type == SimplePrintElement.Type.UP_ARROW)
y0 = r;
if (type == SimplePrintElement.Type.DOWN_ARROW) y0 = PrintParameters.HEIGHT_CELL - r;
if (type == SimplePrintElement.Type.UP_ARROW) y0 = r;
return distance(x0, y0, x, y) <= r;
}
@@ -34,14 +34,15 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
private static final Color MARK_COLOR = JBColor.BLACK;
private final Stroke usual = new BasicStroke(PrintParameters.THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
private final Stroke hide = new BasicStroke(PrintParameters.THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[]{7}, 0);
private final Stroke hide =
new BasicStroke(PrintParameters.THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[]{7}, 0);
private final Stroke selectUsual = new BasicStroke(PrintParameters.SELECT_THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
private final Stroke selectHide = new BasicStroke(PrintParameters.SELECT_THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[]{7}, 0);
private final Stroke selectHide =
new BasicStroke(PrintParameters.SELECT_THICK_LINE, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[]{7}, 0);
private Graphics2D g2;
@NotNull
private final ColorGenerator myColorGenerator;
@NotNull private final ColorGenerator myColorGenerator;
public SimpleGraphCellPainter(@NotNull ColorGenerator colorGenerator) {
myColorGenerator = colorGenerator;
@@ -126,7 +127,8 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
printer.print(MARK_COLOR);
setStroke(isUsual, false);
printer.print(usualColor);
} else {
}
else {
setStroke(isUsual, false);
printer.print(usualColor);
}
@@ -138,8 +140,7 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
}
private static boolean isUsual(PrintElement printElement) {
if (!(printElement instanceof EdgePrintElement))
return true;
if (!(printElement instanceof EdgePrintElement)) return true;
EdgePrintElement.LineStyle lineStyle = ((EdgePrintElement)printElement).getLineStyle();
return lineStyle == EdgePrintElement.LineStyle.SOLID;
}
@@ -161,7 +162,8 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
if (edgePrintElement.getType() == EdgePrintElement.Type.DOWN) {
paintDownLine(from, to, color);
} else {
}
else {
paintUpLine(from, to, color);
}
}
@@ -175,7 +177,8 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
if (printElement.isSelected()) {
paintCircle(position, MARK_COLOR, true);
paintCircle(position, getColor(printElement), false);
} else {
}
else {
paintCircle(position, getColor(printElement), false);
}
break;
@@ -198,8 +201,7 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
}
}
if (printer != null)
drawLogic(printElement.isSelected(), isUsual(printElement), getColor(printElement), printer);
if (printer != null) drawLogic(printElement.isSelected(), isUsual(printElement), getColor(printElement), printer);
}
}
@@ -221,7 +223,8 @@ public class SimpleGraphCellPainter implements GraphCellPainter {
if (PositionUtil.overDownEdge(edgePrintElement.getPositionInCurrentRow(), edgePrintElement.getPositionInOtherRow(), x, y)) {
return printElement;
}
} else {
}
else {
if (PositionUtil.overUpEdge(edgePrintElement.getPositionInOtherRow(), edgePrintElement.getPositionInCurrentRow(), x, y)) {
return printElement;
}
@@ -35,19 +35,19 @@ import static com.intellij.vcs.log.graph.parser.EdgeNodeCharConverter.toChar;
public class GraphStrUtils {
public static final Comparator<GraphElement> GRAPH_ELEMENT_COMPARATOR = new GraphElementComparatorByLayoutIndex(new NotNullFunction<Integer, Integer>() {
@NotNull
@Override
public Integer fun(Integer nodeIndex) {
return 0;
}
});
public static final Comparator<GraphElement> GRAPH_ELEMENT_COMPARATOR =
new GraphElementComparatorByLayoutIndex(new NotNullFunction<Integer, Integer>() {
@NotNull
@Override
public Integer fun(Integer nodeIndex) {
return 0;
}
});
public static <CommitId> String commitsInfoToStr(PermanentCommitsInfo<CommitId> commitsInfo, int size, Function<CommitId, String> toStr) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < size; i++) {
if (i != 0)
s.append("\n");
if (i != 0) s.append("\n");
CommitId commitId = commitsInfo.getCommitId(i);
int commitIndex = commitsInfo.getNodeId(commitId);
@@ -63,8 +63,7 @@ public class GraphStrUtils {
public static String permanentGraphLayoutModelToStr(GraphLayout graphLayout, int nodesCount) {
StringBuilder s = new StringBuilder();
for (int nodeIndex = 0; nodeIndex < nodesCount; nodeIndex++) {
if (nodeIndex != 0)
s.append("\n");
if (nodeIndex != 0) s.append("\n");
s.append(graphLayout.getLayoutIndex(nodeIndex)).append(CommitParser.SEPARATOR).append(graphLayout.getOneOfHeadNodeIndex(nodeIndex));
}
@@ -74,8 +73,7 @@ public class GraphStrUtils {
public static String containingBranchesGetterToStr(ContainingBranchesGetter containingBranchesGetter, int nodesCount) {
StringBuilder s = new StringBuilder();
for (int nodeIndex = 0; nodeIndex < nodesCount; nodeIndex++) {
if (nodeIndex != 0)
s.append("\n");
if (nodeIndex != 0) s.append("\n");
List<Integer> branchNodeIndexes = new ArrayList<Integer>(containingBranchesGetter.getBranchNodeIndexes(nodeIndex));
if (branchNodeIndexes.isEmpty()) {
@@ -86,10 +84,12 @@ public class GraphStrUtils {
Collections.sort(branchNodeIndexes);
boolean first = true;
for (int branchNodeIndex : branchNodeIndexes) {
if (first)
if (first) {
first = false;
else
}
else {
s.append(" ");
}
s.append(branchNodeIndex);
}
@@ -100,8 +100,7 @@ public class GraphStrUtils {
public static String edgesInRowToStr(@NotNull EdgesInRowGenerator edgesInRowGenerator, int nodesCount) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < nodesCount; i++) {
if (i > 0)
s.append("\n");
if (i > 0) s.append("\n");
Set<GraphEdge> edgesInRow = edgesInRowGenerator.getEdgesInRow(i);
s.append(edgesToStr(edgesInRow));
}
@@ -109,8 +108,7 @@ public class GraphStrUtils {
}
public static String edgesToStr(@NotNull Set<GraphEdge> edges) {
if (edges.isEmpty())
return "none";
if (edges.isEmpty()) return "none";
List<GraphEdge> sortedEdges = new ArrayList<GraphEdge>(edges);
Collections.sort(sortedEdges, GRAPH_ELEMENT_COMPARATOR);
@@ -28,8 +28,7 @@ import com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphEleme
fun LinearGraph.asString(sorted: Boolean = false): String {
val s = StringBuilder()
for (nodeIndex in 0..nodesCount() - 1) {
if (nodeIndex > 0)
s.append("\n");
if (nodeIndex > 0) s.append("\n");
val node = getGraphNode(nodeIndex)
s.append(node.asString()).append(CommitParser.SEPARATOR)
@@ -48,7 +47,7 @@ fun Int?.asString() = if (this == null) "n" else toString()
fun GraphEdge.asString(): String = "${getUpNodeIndex().asString()}:${getDownNodeIndex().asString()}:${getTargetId().asString()}_${toChar(getType())}"
fun GraphElement.asString(): String = when(this) {
fun GraphElement.asString(): String = when (this) {
is GraphNode -> asString()
is GraphEdge -> asString()
else -> throw IllegalArgumentException("Uncown type of PrintElement: $this")
@@ -61,7 +60,7 @@ fun PrintElementWithGraphElement.asString(): String {
val color = getColorId()
val pos = getPositionInCurrentRow()
val sel = if (isSelected()) "Select" else "Unselect"
return when(this) {
return when (this) {
is SimplePrintElement -> {
val t = getType()
"Simple:${t}|-$row:${pos}|-$color:${sel}($element)"
@@ -83,16 +82,14 @@ fun PrintElementGenerator.asString(size: Int): String {
val s = StringBuilder()
for (row in 0..size - 1) {
if (row > 0)
s.append("\n")
if (row > 0) s.append("\n")
val elements = getPrintElements(row).sortBy {
val pos = it.getPositionInCurrentRow()
if (it is SimplePrintElement) {
1024 * pos + it.getType().ordinal()
} else if (it is EdgePrintElement) {
1024 * pos + (it.getType().ordinal() + 1) * 64 + it.getPositionInOtherRow()
} else
0
} else 0
}
elements.map { it.asString() }.joinTo(s, separator = "\n ")
}
@@ -27,7 +27,6 @@ import com.intellij.vcs.log.graph.BaseTestGraphBuilder.SimpleEdge
import com.intellij.vcs.log.graph.BaseTestGraphBuilder.SimpleNode
import com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo
import com.intellij.vcs.log.graph.api.permanent.PermanentCommitsInfo
import com.intellij.openapi.util.Condition
import com.intellij.util.containers.ContainerUtil
import com.intellij.vcs.log.graph.utils.TimestampGetter
import com.intellij.vcs.log.graph.impl.permanent.GraphLayoutBuilder
@@ -37,8 +36,6 @@ import kotlin.test.assertNull
import com.intellij.vcs.log.graph.utils.LinearGraphUtils
import com.intellij.vcs.log.graph.api.EdgeFilter
import com.intellij.vcs.log.graph.impl.permanent.PermanentLinearGraphImpl
import com.intellij.vcs.log.graph.utils.impl.BitSetFlags
import com.intellij.vcs.log.graph.utils.impl.FullIntList
import com.intellij.vcs.log.graph.impl.facade.LinearGraphController
import com.intellij.vcs.log.graph.impl.facade.VisibleGraphImpl
@@ -57,7 +54,7 @@ public trait BaseTestGraphBuilder {
class SimpleNode(val nodeId: Int, val type: GraphNodeType = GraphNodeType.USUAL)
}
public class TestGraphBuilder: BaseTestGraphBuilder {
public class TestGraphBuilder : BaseTestGraphBuilder {
private val nodes = ArrayList<NodeWithEdges>()
public fun done(): LinearGraph = TestLinearGraph(nodes)
@@ -77,6 +74,7 @@ public class TestGraphBuilder: BaseTestGraphBuilder {
private fun newNode(node: SimpleNode, edges: List<SimpleEdge> = listOf()) {
nodes add NodeWithEdges(node.nodeId, edges, node.type)
}
fun node(id: Int, vararg edge: Int) {
nodes add NodeWithEdges(id, edge.map {
SimpleEdge(it, GraphEdgeType.USUAL)
@@ -87,17 +85,17 @@ public class TestGraphBuilder: BaseTestGraphBuilder {
nodes add NodeWithEdges(id, edge.toList())
}
private class TestLinearGraph(buildNodes: List<NodeWithEdges>): LinearGraph {
private class TestLinearGraph(buildNodes: List<NodeWithEdges>) : LinearGraph {
private val nodes: List<GraphNode>
private val nodeIndexToId: Map<Int, Int>
private val nodeIdToIndex: Map<Int, Int>
private val edges = MultiMap<Int, GraphEdge>()
val SimpleEdge.toIndex: Int? get() = toNode?.let{ nodeIdToIndex[it]}
val SimpleEdge.toIndex: Int? get() = toNode?.let { nodeIdToIndex[it] }
;{
val idsMap = HashMap<Int, Int>()
nodes = buildNodes.map2 { (index, it) ->
nodes = buildNodes.map2 {(index, it) ->
idsMap[index] = it.nodeId
GraphNode(index, it.type)
}
@@ -133,7 +131,7 @@ public class TestGraphBuilder: BaseTestGraphBuilder {
= edges[nodeIndex].filter {
if (it.getType().isNormalEdge()) {
(LinearGraphUtils.isEdgeUp(it, nodeIndex) && filter.upNormal)
|| (LinearGraphUtils.isEdgeDown(it, nodeIndex) && filter.downNormal)
|| (LinearGraphUtils.isEdgeDown(it, nodeIndex) && filter.downNormal)
} else {
filter.special
}
@@ -150,8 +148,7 @@ private fun LinearGraph.assertEdge(nodeIndex: Int, edge: GraphEdge) {
if (edge.getType().isNormalEdge()) {
if (nodeIndex == edge.getUpNodeIndex()) {
assertTrue(getAdjacentEdges(edge.getDownNodeIndex(), EdgeFilter.NORMAL_UP).contains(edge))
}
else {
} else {
assertTrue(nodeIndex == edge.getDownNodeIndex())
assertTrue(getAdjacentEdges(edge.getUpNodeIndex(), EdgeFilter.NORMAL_DOWN).contains(edge))
}
@@ -170,11 +167,11 @@ private fun LinearGraph.assertEdge(nodeIndex: Int, edge: GraphEdge) {
}
public fun LinearGraph.asTestGraphString(sorted: Boolean = false): String = StringBuilder {
for(nodeIndex in 0..nodesCount() - 1) {
for (nodeIndex in 0..nodesCount() - 1) {
val node = getGraphNode(nodeIndex)
append(getNodeId(nodeIndex))
assertEquals(nodeIndex, node.getNodeIndex(),
"nodeIndex: $nodeIndex, but for node with this index(nodeId: ${getNodeId(nodeIndex)}) nodeIndex: ${node.getNodeIndex()}"
"nodeIndex: $nodeIndex, but for node with this index(nodeId: ${getNodeId(nodeIndex)}) nodeIndex: ${node.getNodeIndex()}"
)
when (node.getType()) {
GraphNodeType.UNMATCHED -> append(".UNM")
@@ -193,11 +190,9 @@ public fun LinearGraph.asTestGraphString(sorted: Boolean = false): String = Stri
if (it.getUpNodeIndex() == nodeIndex) {
val startId = if (it.getType().isNormalEdge()) {
getNodeId(it.getDownNodeIndex()).toString()
}
else if (it.getTargetId() != null) {
} else if (it.getTargetId() != null) {
it.getTargetId().toString()
}
else {
} else {
"null"
}
@@ -252,12 +247,11 @@ class TestPermanentGraphInfo(
override fun getTimestamp(index: Int) = commitInfo.getTimestamp(graph.getNodeId(index))
}
val graphLayout = GraphLayoutBuilder.build(graph) { (x, y) ->
val graphLayout = GraphLayoutBuilder.build(graph) {(x, y) ->
if (headsOrder.isEmpty()) {
graph.getNodeId(x) - graph.getNodeId(y)
}
else {
val t = if (headsOrder.indexOf(x) == -1) x else if(headsOrder.indexOf(y) == -1) y else -1
} else {
val t = if (headsOrder.indexOf(x) == -1) x else if (headsOrder.indexOf(y) == -1) y else -1
if (t != -1) throw IllegalStateException("Not found headsOrder for $t node by id")
headsOrder.indexOf(x) - headsOrder.indexOf(y)
}
@@ -19,7 +19,7 @@ import org.junit.Assert.*
import org.junit.Test
class TestGraphBuilderTest : AbstractTestWithTextFile("testGraphBuilder") {
class TestGraphBuilderTest : AbstractTestWithTextFile("testGraphBuilder") {
fun runTest(testName: String, builder: TestGraphBuilder.() -> Unit) {
val actual = graph(builder).asString()
@@ -54,9 +54,9 @@ object TestGraphs {
3 4 5
*/
val downTree = graph {
0(1,2)
1(3,4)
2(4,5)
0(1, 2)
1(3, 4)
2(4, 5)
3()
4()
5()
@@ -71,7 +71,7 @@ object TestGraphs {
*/
val upTree = graph {
0(3)
1(3,4)
1(3, 4)
2(4)
3(5)
4(5)
@@ -186,13 +186,13 @@ object TestGraphs {
8
*/
val twoInit = graph {
0(1,2)
1(3,4)
0(1, 2)
1(3, 4)
2(6)
3(5)
4(6)
5(7,8)
6(7,8)
5(7, 8)
6(7, 8)
7()
8()
}
@@ -30,7 +30,7 @@ public class DottedFilterEdgesGeneratorTest {
fun LinearGraph.assert(upIndex: Int = 0, downIndex: Int = nodesCount() - 1, result: TestGraphBuilder.() -> Unit) {
val nodesVisibility = UnsignedBitSet()
for(nodeIndex in 0..nodesCount() - 1) {
for (nodeIndex in 0..nodesCount() - 1) {
val graphNode = getGraphNode(nodeIndex)
nodesVisibility.set(getNodeId(nodeIndex), graphNode.getType() == GraphNodeType.USUAL)
}
@@ -82,9 +82,9 @@ public class DottedFilterEdgesGeneratorTest {
3 4 5
*/
Test fun downTree() = graph {
0(1,2)
1.UNM(3,4)
2.UNM(4,5)
0(1, 2)
1.UNM(3, 4)
2.UNM(4, 5)
3()
4()
5()
@@ -104,7 +104,7 @@ public class DottedFilterEdgesGeneratorTest {
*/
Test fun upTree() = graph {
0(3)
1(3,4)
1(3, 4)
2(4)
3.UNM(5)
4.UNM(5)
@@ -21,11 +21,8 @@ import com.intellij.vcs.log.graph.collapsing.EdgeStorage
import com.intellij.vcs.log.graph.BaseTestGraphBuilder
import com.intellij.vcs.log.graph.BaseTestGraphBuilder.SimpleEdge
import com.intellij.vcs.log.graph.api.elements.GraphEdgeType
import java.util.ArrayList
import com.intellij.vcs.log.graph.utils.sortR
import com.intellij.vcs.log.graph.api.elements.GraphEdge
import com.intellij.vcs.log.graph.asString
import com.intellij.vcs.log.graph.api.LinearGraph
import com.intellij.vcs.log.graph.api.EdgeFilter
import com.intellij.vcs.log.graph.collapsing.EdgeStorageWrapper
@@ -44,6 +41,7 @@ public class EdgeStorageTest : BaseTestGraphBuilder {
createEdge(edge.mainId, edge.additionId ?: EdgeStorage.NULL_ID, edge.edgeType)
return this
}
fun EdgeStorage.remove(edge: FullEdge): EdgeStorage {
removeEdge(edge.mainId, edge.additionId ?: EdgeStorage.NULL_ID, edge.edgeType)
return this
@@ -52,7 +50,7 @@ public class EdgeStorageTest : BaseTestGraphBuilder {
fun EdgeStorage.assert(s: String) = assertEquals(s, asString())
fun EdgeStorage.asString(): String = getKnownIds().sortR().map {
adapter.getAdjacentEdges(nodeIndexById(it), EdgeFilter.ALL).map { it.asString() }.joinToString(",")
adapter.getAdjacentEdges(nodeIndexById(it), EdgeFilter.ALL).map { it.asString() }.joinToString(",")
}.joinToString("|-")
val EdgeStorage.adapter: EdgeStorageWrapper get() = EdgeStorageWrapper(this, nodeIndexById, nodeIdByIndex)
@@ -26,7 +26,7 @@ import com.intellij.vcs.log.graph.api.LiteLinearGraph
private val LinearGraph.lite: LiteLinearGraph get() = LinearGraphUtils.asLiteLinearGraph(this)
private fun LinearGraph.getMiddleNodes(upNode: Int, downNode: Int) = FragmentGenerator(lite) {false}.getMiddleNodes(upNode, downNode, false)
private fun LinearGraph.getMiddleNodes(upNode: Int, downNode: Int) = FragmentGenerator(lite) { false }.getMiddleNodes(upNode, downNode, false)
private fun Collection<Int>.assert(s: String) = assertEquals(s, sort().joinToString(","))
private fun Int?.assert(i: Int?) = assertEquals(i, this)
@@ -52,7 +52,7 @@ private fun FragmentGenerator.GreenFragment.assert(s: String)
2
*/
val simple = graph {
0(1,2)
0(1, 2)
1(2)
2()
}
@@ -77,9 +77,9 @@ val twoBranch = graph {
3 4 5
*/
val downTree = graph {
0(1,2)
1(3,4)
2(4,5)
0(1, 2)
1(3, 4)
2(4, 5)
3()
4()
5()
@@ -94,7 +94,7 @@ val downTree = graph {
*/
val upTree = graph {
0(3)
1(3,4)
1(3, 4)
2(4)
3(5)
4(5)
@@ -116,13 +116,13 @@ val upTree = graph {
8
*/
val difficult = graph {
0(1,2)
1(3,4)
0(1, 2)
1(3, 4)
2(6)
3(5)
4(6)
5(7,8)
6(7,8)
5(7, 8)
6(7, 8)
7()
8()
}
@@ -16,11 +16,11 @@
package com.intellij.vcs.log.graph.impl.permanent;
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
import com.intellij.vcs.log.graph.GraphCommit;
import com.intellij.vcs.log.graph.api.LinearGraph;
import com.intellij.vcs.log.graph.impl.CommitIdManager;
import com.intellij.vcs.log.graph.impl.facade.ContainingBranchesGetter;
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
import com.intellij.vcs.log.graph.utils.LinearGraphUtils;
import org.junit.Test;
@@ -53,8 +53,8 @@ public abstract class ContainingBranchesTest<CommitId> extends AbstractTestWithT
List<GraphCommit<CommitId>> commits = getCommitIdManager().parseCommitList(in.substring(0, i));
LinearGraph graph = PermanentLinearGraphBuilder.newInstance(commits).build();
ContainingBranchesGetter containingBranchesGetter = new ContainingBranchesGetter(LinearGraphUtils.asLiteLinearGraph(graph),
parseBranchNodeIndex(in.substring(i + SEPARATOR.length())));
ContainingBranchesGetter containingBranchesGetter =
new ContainingBranchesGetter(LinearGraphUtils.asLiteLinearGraph(graph), parseBranchNodeIndex(in.substring(i + SEPARATOR.length())));
assertEquals(out, containingBranchesGetterToStr(containingBranchesGetter, graph.nodesCount()));
}
@@ -16,10 +16,10 @@
package com.intellij.vcs.log.graph.impl.permanent;
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
import com.intellij.vcs.log.graph.GraphCommit;
import com.intellij.vcs.log.graph.api.permanent.PermanentCommitsInfo;
import com.intellij.vcs.log.graph.impl.CommitIdManager;
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile;
import org.junit.Test;
import java.io.IOException;
@@ -17,8 +17,6 @@
package com.intellij.vcs.log.graph.impl.permanent
import com.intellij.util.NotNullFunction
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile
import com.intellij.vcs.log.graph.GraphCommit
import com.intellij.vcs.log.graph.*
import com.intellij.vcs.log.graph.impl.CommitIdManager
import org.junit.Test
@@ -15,12 +15,8 @@
*/
package com.intellij.vcs.log.graph.impl.print
import com.intellij.openapi.util.Pair
import com.intellij.util.NotNullFunction
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile
import com.intellij.vcs.log.graph.*
import com.intellij.vcs.log.graph.api.GraphLayout
import com.intellij.vcs.log.graph.api.LinearGraph
import com.intellij.vcs.log.graph.api.elements.GraphEdge
import com.intellij.vcs.log.graph.api.elements.GraphElement
import com.intellij.vcs.log.graph.api.elements.GraphNode
@@ -15,9 +15,7 @@
*/
package com.intellij.vcs.log.graph.impl.print
import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile
import com.intellij.vcs.log.graph.*
import com.intellij.vcs.log.graph.api.LinearGraph
import com.intellij.vcs.log.graph.parser.LinearGraphParser
import org.junit.Test
@@ -68,7 +68,7 @@ public class CommitParser {
@NotNull
public static List<GraphCommit<String>> parseStringCommitList(@NotNull String input) {
List<GraphCommit<String>> vcsCommitParentses = new ArrayList<GraphCommit<String>>();
for(String line : toLines(input)) {
for (String line : toLines(input)) {
vcsCommitParentses.add(CommitParser.parseCommitParentsAsString(line));
}
return vcsCommitParentses;
@@ -77,7 +77,7 @@ public class CommitParser {
@NotNull
public static List<GraphCommit<Integer>> parseIntegerCommitList(@NotNull String input) {
List<GraphCommit<Integer>> vcsCommitParentses = new ArrayList<GraphCommit<Integer>>();
for(String line : toLines(input)) {
for (String line : toLines(input)) {
vcsCommitParentses.add(CommitParser.parseCommitParentsAsInteger(line));
}
return vcsCommitParentses;
@@ -47,16 +47,14 @@ public class EdgeNodeCharConverter {
@NotNull
public static GraphNodeType parseGraphNodeType(char type) {
GraphNodeType nodeType = GRAPH_NODE_TYPE_MAP.get(type);
if (nodeType == null)
throw new IllegalStateException("Illegal char for graph node type: " + type);
if (nodeType == null) throw new IllegalStateException("Illegal char for graph node type: " + type);
return nodeType;
}
@NotNull
public static GraphEdgeType parseGraphEdgeType(char type) {
GraphEdgeType nodeType = GRAPH_EDGE_TYPE_MAP.get(type);
if (nodeType == null)
throw new IllegalStateException("Illegal char for graph edge type: " + type);
if (nodeType == null) throw new IllegalStateException("Illegal char for graph edge type: " + type);
return nodeType;
}
@@ -137,12 +137,12 @@ public class LinearGraphParser {
public List<GraphEdge> getAdjacentEdges(int nodeIndex, @NotNull EdgeFilter filter) {
List<GraphEdge> result = ContainerUtil.newArrayList();
for(GraphEdge upEdge : myUpEdges.get(nodeIndex)) {
for (GraphEdge upEdge : myUpEdges.get(nodeIndex)) {
if (upEdge.getType().isNormalEdge() && filter.upNormal) result.add(upEdge);
if (!upEdge.getType().isNormalEdge() && filter.special) result.add(upEdge);
}
for(GraphEdge downEdge : myDownEdges.get(nodeIndex)) {
for (GraphEdge downEdge : myDownEdges.get(nodeIndex)) {
if (downEdge.getType().isNormalEdge() && filter.downNormal) result.add(downEdge);
if (!downEdge.getType().isNormalEdge() && filter.special) result.add(downEdge);
}
@@ -158,15 +158,14 @@ public class LinearGraphParser {
@Override
public int getNodeId(int nodeIndex) {
assert nodeIndex > 0 && nodeIndex < nodesCount() : "Bad nodeIndex: "+ nodeIndex;
assert nodeIndex > 0 && nodeIndex < nodesCount() : "Bad nodeIndex: " + nodeIndex;
return nodeIndex;
}
@Override
@Nullable
public Integer getNodeIndex(int nodeId) {
if (nodeId >= 0 && nodeId < nodesCount())
return nodeId;
if (nodeId >= 0 && nodeId < nodesCount()) return nodeId;
return null;
}
}
@@ -48,10 +48,8 @@ public class SimpleCommit<CommitId> implements com.intellij.vcs.log.graph.GraphC
return new SimpleCommit<String>(commitHash, parents, timestamp);
}
@NotNull
private final CommitId myId;
@NotNull
private final List<CommitId> myParents;
@NotNull private final CommitId myId;
@NotNull private final List<CommitId> myParents;
private final long myTimestamp;
public SimpleCommit(@NotNull CommitId id, @NotNull List<CommitId> parents, long timestamp) {
@@ -30,8 +30,9 @@ public class BitSetFlagsTest {
private static String toStr(@NotNull Flags flags) {
StringBuilder s = new StringBuilder();
for(int i = 0; i < flags.size(); i++)
for (int i = 0; i < flags.size(); i++) {
s.append(bitToChar(flags.get(i)));
}
return s.toString();
}
@@ -32,14 +32,13 @@ public class CompressedIntListTest {
private static String toStr(@NotNull IntList intList) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < intList.size(); i++) {
if (i != 0)
s.append(", ");
if (i != 0) s.append(", ");
s.append(intList.get(i));
}
return s.toString();
}
private static IntList toDataList(final int ... list) {
private static IntList toDataList(final int... list) {
return new IntList() {
@Override
public int size() {
@@ -53,7 +52,7 @@ public class CompressedIntListTest {
};
}
protected void runTest(int ... list) {
protected void runTest(int... list) {
IntList intList = CompressedIntList.newInstance(list, 3);
String expected = toStr(toDataList(list));
assertEquals(expected, toStr(intList));
@@ -107,7 +106,7 @@ public class CompressedIntListTest {
runTest(-2 * BYTE3_MAX, 0, -2 * BYTE3_MAX);
runTest(-2 * BYTE2_MAX, 0, -2 * BYTE2_MAX);
runTest(-2 * BYTE_MAX, 0, -2 * BYTE_MAX);
runTest(-2 * BYTE_MAX, 0, -2 * BYTE_MAX);
runTest(BYTE_MAX, 0, BYTE_MAX);
runTest(BYTE2_MAX, 0, BYTE2_MAX);
@@ -115,7 +114,7 @@ public class CompressedIntListTest {
runTest(2 * BYTE3_MAX, 0, 2 * BYTE3_MAX);
runTest(2 * BYTE2_MAX, 0, 2 * BYTE2_MAX);
runTest(2 * BYTE_MAX, 0, 2 * BYTE_MAX);
runTest(2 * BYTE_MAX, 0, 2 * BYTE_MAX);
}
@Test
@@ -45,14 +45,13 @@ public class IntTimestampGetterTest {
private static String toStr(@NotNull TimestampGetter timestampGetter) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < timestampGetter.size(); i++) {
if (i != 0)
s.append(", ");
if (i != 0) s.append(", ");
s.append(timestampGetter.getTimestamp(i));
}
return s.toString();
}
protected void runTest(long ... timestamp) {
protected void runTest(long... timestamp) {
TimestampGetter timestampGetter = create(timestamp);
IntTimestampGetter intTimestampGetter = IntTimestampGetter.newInstance(timestampGetter, BLOCK_SIZE);
assertEquals(toStr(timestampGetter), toStr(intTimestampGetter));
@@ -67,7 +66,8 @@ public class IntTimestampGetterTest {
public void checkEmpty() {
try {
runTest();
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException e) {
return;
}
@@ -46,10 +46,8 @@ public class PermanentListIntToIntMapTest extends UpdatableIntToIntMapTest {
}
private static class UpdatableIntToIntMapWrapper implements UpdatableIntToIntMap {
@NotNull
private final Flags myFlags;
@NotNull
private IntToIntMap myIntToIntMap;
@NotNull private final Flags myFlags;
@NotNull private IntToIntMap myIntToIntMap;
private UpdatableIntToIntMapWrapper(@NotNull Flags flags) {
myFlags = flags;
@@ -58,9 +56,9 @@ public class PermanentListIntToIntMapTest extends UpdatableIntToIntMapTest {
private void createIntToIntMap() {
int shortSize = 0;
for (int i = 0; i < myFlags.size(); i++)
if (myFlags.get(i))
shortSize++;
for (int i = 0; i < myFlags.size(); i++) {
if (myFlags.get(i)) shortSize++;
}
myIntToIntMap = PermanentListIntToIntMap.newInstance(myFlags, shortSize, 2);
}
@@ -18,17 +18,19 @@ package com.intellij.vcs.log.graph.utils;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
public class UnsignedBitSetTest {
private static String toStr(@NotNull UnsignedBitSet bitSet) {
StringBuilder s = new StringBuilder();
for (int i = -5; i <= 5; i++) {
if (bitSet.get(i))
if (bitSet.get(i)) {
s.append(1);
else
}
else {
s.append(0);
}
}
return s.toString();
}
@@ -29,8 +29,7 @@ public abstract class UpdatableIntToIntMapTest {
private static Set<Integer> parseSet(String visibility) {
Set<Integer> visibleNodes = new HashSet<Integer>();
if (visibility.length() == 0)
return visibleNodes;
if (visibility.length() == 0) return visibleNodes;
for (String number : visibility.split("\\|")) {
visibleNodes.add(Integer.decode(number));
@@ -38,7 +37,7 @@ public abstract class UpdatableIntToIntMapTest {
return visibleNodes;
}
private static class Tester {
private final Set<Integer> myVisibleNodes;
@@ -61,8 +60,7 @@ public abstract class UpdatableIntToIntMapTest {
public String mapToString() {
StringBuilder s = new StringBuilder();
for (int shortIndex = 0; shortIndex < myUpdatableIntToIntMap.shortSize(); shortIndex++) {
if (shortIndex != 0)
s.append("|");
if (shortIndex != 0) s.append("|");
s.append(myUpdatableIntToIntMap.getLongIndex(shortIndex));
}
@@ -72,8 +70,7 @@ public abstract class UpdatableIntToIntMapTest {
public String reverseMapToString() {
StringBuilder s = new StringBuilder();
for (int longIndex = 0; longIndex < myUpdatableIntToIntMap.longSize(); longIndex++) {
if (longIndex != 0)
s.append("|");
if (longIndex != 0) s.append("|");
s.append(myUpdatableIntToIntMap.getShortIndex(longIndex));
}