/*
 * Copyright 2000-2017 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.debugger.streams.resolve;

import com.intellij.debugger.streams.trace.TraceElement;
import com.intellij.debugger.streams.trace.TraceInfo;
import org.jetbrains.annotations.NotNull;

import java.util.*;

/**
 * @author Vitaliy.Bibaev
 */
public class MapResolver implements ValuesOrderResolver {
  @NotNull
  @Override
  public Result resolve(@NotNull TraceInfo info) {
    final Map<Integer, TraceElement> before = info.getValuesOrderBefore();
    final Map<Integer, TraceElement> after = info.getValuesOrderAfter();
    assert before.size() == after.size();
    final Iterator<TraceElement> leftIterator = before.values().iterator();
    final Iterator<TraceElement> rightIterator = after.values().iterator();

    final Map<TraceElement, List<TraceElement>> forward = new LinkedHashMap<>();
    final Map<TraceElement, List<TraceElement>> backward = new LinkedHashMap<>();
    while (leftIterator.hasNext()) {
      final TraceElement left = leftIterator.next();
      final TraceElement right = rightIterator.next();

      forward.put(left, Collections.singletonList(right));
      backward.put(right, Collections.singletonList(left));
    }

    return Result.of(forward, backward);
  }
}

@@ -1135,50 +1135,9 @@
 ();%0A
-    assert before.size() == after.size();
 %0A
+
     
@@ -1481,16 +1481,43 @@
 asNext()
+ && rightIterator.hasNext()
 ) %7B%0A    
@@ -1676,24 +1676,24 @@
 st(right));%0A
-
       backwa
@@ -1747,16 +1747,125 @@
 %0A    %7D%0A%0A
+    while (leftIterator.hasNext()) %7B%0A      forward.put(leftIterator.next(), Collections.emptyList());%0A    %7D%0A%0A
     retu

Fix small bug when assertion failed if exception in user code happen