From a83cb329372ef7bd85df299eee7753ac48b28df3 Mon Sep 17 00:00:00 2001 From: Eldar Abusalimov Date: Mon, 30 Sep 2019 22:09:24 +0300 Subject: [PATCH] CIDR: debugger: (testing) Reuse XDebuggerTestUtil.collectChildren() GitOrigin-RevId: 7e41ec357d56dbf58d5a3c59f399dfa63acd6028 --- .../intellij/xdebugger/XDebuggerTestUtil.java | 32 ++++++++++++------- .../intellij/xdebugger/XTestContainer.java | 6 ++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XDebuggerTestUtil.java b/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XDebuggerTestUtil.java index a7f01fc27492..9d1ff552ce29 100644 --- a/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XDebuggerTestUtil.java +++ b/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XDebuggerTestUtil.java @@ -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 collectVariables(XStackFrame frame) { - return collectChildren(frame); - } - + @NotNull public static List collectChildren(XValueContainer value) { return collectChildren(value, XDebuggerTestUtil::waitFor); } + @NotNull public static List collectChildren(XValueContainer value, BiFunction waitFunction) { + final Pair, String> childrenWithError = collectChildrenWithError(value, waitFunction); + final String error = childrenWithError.second; + assertNull("Error getting children: " + error, error); + return childrenWithError.first; + } + + @NotNull + public static Pair, String> collectChildrenWithError(XValueContainer value) { + return collectChildrenWithError(value, XDebuggerTestUtil::waitFor); + } + + @NotNull + public static Pair, String> collectChildrenWithError(XValueContainer value, + BiFunction waitFunction) { XTestCompositeNode container = new XTestCompositeNode(); value.computeChildren(container); - return container.waitFor(TIMEOUT_MS, waitFunction).first; + return container.waitFor(TIMEOUT_MS, waitFunction); } public static Pair evaluate(XDebugSession session, XExpression expression) { return evaluate(session, expression, TIMEOUT_MS); } - public static Pair evaluate(XDebugSession session, XExpression expression, BiFunction waitFunction) { + public static Pair evaluate(XDebugSession session, + XExpression expression, + BiFunction waitFunction) { return evaluate(session, expression, TIMEOUT_MS, waitFunction); } diff --git a/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XTestContainer.java b/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XTestContainer.java index 928b60843a8e..d313c6370bbd 100644 --- a/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XTestContainer.java +++ b/platform/xdebugger-testFramework/src/com/intellij/xdebugger/XTestContainer.java @@ -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 { myFinished.release(); } + @NotNull public Pair, String> waitFor(long timeoutMs) { return waitFor(timeoutMs, (semaphore, timeout) -> XDebuggerTestUtil.waitFor(myFinished, timeout)); } + @NotNull public Pair, String> waitFor(long timeoutMs, BiFunction waitFunction) { if (!waitFunction.apply(myFinished, timeoutMs)) { throw new AssertionError("Waiting timed out");