From 81c423a5d68f924e18e28881d6a7a71e4decfccb Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 24 Oct 2016 18:50:46 +0300 Subject: [PATCH] fixed condition extraction in tests --- .../ExecutionWithDebuggerToolsTestCase.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java index 11dab6c6ebd5..90a81779dbb4 100644 --- a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java @@ -82,10 +82,33 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa protected String readValue(String comment, String valueName) { int valueStart = comment.indexOf(valueName); - if (valueStart == -1) return null; + if (valueStart == -1) { + return null; + } - int valueEnd = comment.indexOf(')', valueStart); - return comment.substring(valueStart + valueName.length() + 1, valueEnd); + valueStart += valueName.length(); + return comment.substring(valueStart + 1, findMatchingParenthesis(comment, valueStart)); + } + + private static int findMatchingParenthesis(String input, int startPos) { + int depth = 0; + while (startPos < input.length()) { + switch (input.charAt(startPos)) { + case '(': + depth++; + break; + case ')': + if (depth == 1) { + return startPos; + } + else { + depth--; + } + break; + } + startPos++; + } + return -1; } protected void resume(SuspendContextImpl context) {