From a2da2d2e8a22d6d46db3dcc38ac4ed43451eb6d0 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 29 Aug 2016 20:42:41 +0300 Subject: [PATCH] [vcs-log] minor: convert anonimous to inner --- .../graph/impl/facade/VisibleGraphImpl.java | 79 +++++++++++-------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java index b1566f0f16bb..e88bde7eedbe 100644 --- a/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java +++ b/platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/VisibleGraphImpl.java @@ -24,7 +24,6 @@ import com.intellij.vcs.log.graph.api.elements.GraphEdgeType; import com.intellij.vcs.log.graph.api.elements.GraphElement; import com.intellij.vcs.log.graph.api.elements.GraphNodeType; import com.intellij.vcs.log.graph.api.permanent.PermanentGraphInfo; -import com.intellij.vcs.log.graph.api.printer.PrintElementGenerator; import com.intellij.vcs.log.graph.impl.facade.LinearGraphController.LinearGraphAction; import com.intellij.vcs.log.graph.impl.print.PrintElementGeneratorImpl; import com.intellij.vcs.log.graph.impl.print.elements.PrintElementWithGraphElement; @@ -65,40 +64,7 @@ public class VisibleGraphImpl implements VisibleGraph { public RowInfo getRowInfo(final int visibleRow) { final int nodeId = myGraphController.getCompiledGraph().getNodeId(visibleRow); assert nodeId >= 0; // todo remake for all id - return new RowInfo() { - @NotNull - @Override - public CommitId getCommit() { - return myPermanentGraph.getPermanentCommitsInfo().getCommitId(nodeId); - } - - @NotNull - @Override - public CommitId getOneOfHeads() { - int headNodeId = myPermanentGraph.getPermanentGraphLayout().getOneOfHeadNodeIndex(nodeId); - return myPermanentGraph.getPermanentCommitsInfo().getCommitId(headNodeId); - } - - @NotNull - @Override - public Collection getPrintElements() { - return myPrintElementGenerator.getPrintElements(visibleRow); - } - - @NotNull - @Override - public RowType getRowType() { - GraphNodeType nodeType = myGraphController.getCompiledGraph().getGraphNode(visibleRow).getType(); - switch (nodeType) { - case USUAL: - return RowType.NORMAL; - case UNMATCHED: - return RowType.UNMATCHED; - default: - throw new UnsupportedOperationException("Unsupported node type: " + nodeType); - } - } - }; + return new MyRowInfo(nodeId, visibleRow); } @Override @@ -284,4 +250,47 @@ public class VisibleGraphImpl implements VisibleGraph { return myType; } } + + private class MyRowInfo implements RowInfo { + private final int myNodeId; + private final int myVisibleRow; + + public MyRowInfo(int nodeId, int visibleRow) { + myNodeId = nodeId; + myVisibleRow = visibleRow; + } + + @NotNull + @Override + public CommitId getCommit() { + return myPermanentGraph.getPermanentCommitsInfo().getCommitId(myNodeId); + } + + @NotNull + @Override + public CommitId getOneOfHeads() { + int headNodeId = myPermanentGraph.getPermanentGraphLayout().getOneOfHeadNodeIndex(myNodeId); + return myPermanentGraph.getPermanentCommitsInfo().getCommitId(headNodeId); + } + + @NotNull + @Override + public Collection getPrintElements() { + return myPrintElementGenerator.getPrintElements(myVisibleRow); + } + + @NotNull + @Override + public RowType getRowType() { + GraphNodeType nodeType = myGraphController.getCompiledGraph().getGraphNode(myVisibleRow).getType(); + switch (nodeType) { + case USUAL: + return RowType.NORMAL; + case UNMATCHED: + return RowType.UNMATCHED; + default: + throw new UnsupportedOperationException("Unsupported node type: " + nodeType); + } + } + } }