CIDR: debugger: (testing) Reuse XDebuggerTestUtil.collectChildren()

GitOrigin-RevId: 7e41ec357d56dbf58d5a3c59f399dfa63acd6028
This commit is contained in:
Eldar Abusalimov
2019-10-01 21:12:59 +00:00
committed by intellij-monorepo-bot
parent b4578320b9
commit a83cb32937
2 changed files with 24 additions and 14 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xdebugger;
import com.intellij.execution.impl.ConsoleViewImpl;
@@ -201,30 +201,40 @@ public class XDebuggerTestUtil {
return Pair.create(all, container.frameToSelect);
}
/**
* @deprecated use {@link XDebuggerTestUtil#collectChildren(XValueContainer)}
*/
@Deprecated
public static List<XValue> collectVariables(XStackFrame frame) {
return collectChildren(frame);
}
@NotNull
public static List<XValue> collectChildren(XValueContainer value) {
return collectChildren(value, XDebuggerTestUtil::waitFor);
}
@NotNull
public static List<XValue> collectChildren(XValueContainer value, BiFunction<Semaphore, Long, Boolean> waitFunction) {
final Pair<List<XValue>, String> childrenWithError = collectChildrenWithError(value, waitFunction);
final String error = childrenWithError.second;
assertNull("Error getting children: " + error, error);
return childrenWithError.first;
}
@NotNull
public static Pair<List<XValue>, String> collectChildrenWithError(XValueContainer value) {
return collectChildrenWithError(value, XDebuggerTestUtil::waitFor);
}
@NotNull
public static Pair<List<XValue>, String> collectChildrenWithError(XValueContainer value,
BiFunction<Semaphore, Long, Boolean> waitFunction) {
XTestCompositeNode container = new XTestCompositeNode();
value.computeChildren(container);
return container.waitFor(TIMEOUT_MS, waitFunction).first;
return container.waitFor(TIMEOUT_MS, waitFunction);
}
public static Pair<XValue, String> evaluate(XDebugSession session, XExpression expression) {
return evaluate(session, expression, TIMEOUT_MS);
}
public static Pair<XValue, String> evaluate(XDebugSession session, XExpression expression, BiFunction<Semaphore, Long, Boolean> waitFunction) {
public static Pair<XValue, String> evaluate(XDebugSession session,
XExpression expression,
BiFunction<Semaphore, Long, Boolean> waitFunction) {
return evaluate(session, expression, TIMEOUT_MS, waitFunction);
}
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xdebugger;
import com.intellij.openapi.util.Pair;
@@ -41,10 +39,12 @@ public class XTestContainer<T> {
myFinished.release();
}
@NotNull
public Pair<List<T>, String> waitFor(long timeoutMs) {
return waitFor(timeoutMs, (semaphore, timeout) -> XDebuggerTestUtil.waitFor(myFinished, timeout));
}
@NotNull
public Pair<List<T>, String> waitFor(long timeoutMs, BiFunction<? super Semaphore, ? super Long, Boolean> waitFunction) {
if (!waitFunction.apply(myFinished, timeoutMs)) {
throw new AssertionError("Waiting timed out");