package io.flutter.vmService.frame;

import com.intellij.xdebugger.XSourcePosition;
import io.flutter.vmService.DartVmServiceDebugProcess;
import org.dartlang.vm.service.element.Frame;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class DartVmServiceEvaluatorInFrame extends DartVmServiceEvaluator {

  @NotNull private final String myIsolateId;
  @NotNull private final Frame myFrame;

  public DartVmServiceEvaluatorInFrame(@NotNull final DartVmServiceDebugProcess debugProcess,
                                       @NotNull final String isolateId,
                                       @NotNull final Frame vmFrame) {
    super(debugProcess);
    myIsolateId = isolateId;
    myFrame = vmFrame;
  }

  @Override
  public void evaluate(@NotNull final String expression,
                       @NotNull final XEvaluationCallback callback,
                       @Nullable final XSourcePosition expressionPosition) {
    myDebugProcess.getVmServiceWrapper().evaluateInFrame(myIsolateId, myFrame, expression, callback);
  }
}

@@ -30,16 +30,61 @@
 frame;%0A%0A
+import com.intellij.openapi.util.SystemInfo;%0A
 import c
@@ -1084,16 +1084,32 @@
 yFrame, 
+replaceNewlines(
 expressi
@@ -1110,16 +1110,17 @@
 pression
+)
 , callba
@@ -1127,11 +1127,285 @@
 ck);%0A  %7D
+%0A%0A  private String replaceNewlines(String expr) %7B%0A    if (SystemInfo.isWindows) %7B%0A      // Doing separately in case we only have %5Cn in this string.%0A      return expr.replaceAll(%22%5Cn%22, %22 %22).replaceAll(%22%5Cr%22, %22 %22);%0A    %7D else %7B%0A      return expr.replaceAll(%22%5Cn%22, %22 %22);%0A    %7D%0A  %7D
 %0A%7D%0A

Remove newlines prior to sending eval expr to VM (#5187)