/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.intellij.vcs.log.graph.impl.visible.adapters;

import com.intellij.vcs.log.graph.api.LinearGraph;
import com.intellij.vcs.log.graph.api.LinearGraphWithHiddenNodes;
import com.intellij.vcs.log.graph.api.elements.GraphEdge;
import com.intellij.vcs.log.graph.api.elements.GraphNode;
import com.intellij.vcs.log.graph.utils.ListenerController;
import com.intellij.vcs.log.graph.utils.impl.SetListenerController;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LinearGraphAsGraphWithHiddenNodes implements LinearGraphWithHiddenNodes {

  @NotNull
  private final LinearGraph delegateGraph;

  @NotNull
  private final SetListenerController<UpdateListener> myListenerController = new SetListenerController<UpdateListener>();

  public LinearGraphAsGraphWithHiddenNodes(@NotNull LinearGraph delegateGraph) {
    this.delegateGraph = delegateGraph;
  }

  @Override
  public boolean nodeIsVisible(int nodeIndex) {
    return true;
  }

  @NotNull
  @Override
  public GraphNode.Type getNodeType(int nodeIndex) {
    return GraphNode.Type.USUAL;
  }

  @NotNull
  @Override
  public GraphEdge.Type getEdgeType(int upNodeIndex, int downNodeIndex) {
    return GraphEdge.Type.USUAL;
  }

  @NotNull
  @Override
  public ListenerController<UpdateListener> getListenerController() {
    return myListenerController;
  }

  @Override
  public int nodesCount() {
    return delegateGraph.nodesCount();
  }

  @NotNull
  @Override
  public List<Integer> getUpNodes(int nodeIndex) {
    return delegateGraph.getUpNodes(nodeIndex);
  }

  @NotNull
  @Override
  public List<Integer> getDownNodes(int nodeIndex) {
    return delegateGraph.getDownNodes(nodeIndex);
  }
}

@@ -887,16 +887,112 @@
 phNode;%0A
+import com.intellij.vcs.log.graph.utils.Flags;%0Aimport com.intellij.vcs.log.graph.utils.IdFlags;%0A
 import c
@@ -1039,24 +1039,24 @@
 Controller;%0A
-
 import com.i
@@ -1178,16 +1178,122 @@
 .List;%0A%0A
+/**%0A * Methods getUpNodes or getDownNodes may return invisible nodes.%0A * It is done for performance,%0A */%0A%0A
 public c
@@ -1403,33 +1403,35 @@
 nal LinearGraph 
-d
+myD
 elegateGraph;%0A%0A 
@@ -1427,16 +1427,65 @@
 teGraph;
+%0A  @NotNull%0A  private final Flags myVisibleNodes;
 %0A%0A  @Not
@@ -1705,38 +1705,257 @@
 this
-.delegateGraph = delegateGraph
+(delegateGraph, new IdFlags(delegateGraph.nodesCount(), true));%0A  %7D%0A%0A  public LinearGraphAsGraphWithHiddenNodes(@NotNull LinearGraph delegateGraph, @NotNull Flags visibleNodes) %7B%0A    myDelegateGraph = delegateGraph;%0A    myVisibleNodes = visibleNodes
 ;%0A  
@@ -2028,20 +2028,45 @@
  return 
-true
+myVisibleNodes.get(nodeIndex)
 ;%0A  %7D%0A%0A 
@@ -2487,33 +2487,35 @@
 () %7B%0A    return 
-d
+myD
 elegateGraph.nod
@@ -2607,33 +2607,35 @@
 x) %7B%0A    return 
-d
+myD
 elegateGraph.get
@@ -2746,17 +2746,19 @@
  return 
-d
+myD
 elegateG

Add constructor.