Skip to content

Commit

Permalink
[DAP] Accept both Boolean true and 'true' string for the new 'stop at…
Browse files Browse the repository at this point in the history
… every statement' option

It's easier to send a "true" string from our launch configuration
dialog, but from VS Code a regular Boolean true value feels more
natural. This commit makes it so the adapter accepts both a "true"
string and a true Boolean value for enabling the option.
  • Loading branch information
agarciadom committed Oct 22, 2024
1 parent 40157b0 commit 4b3f2f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ public CompletableFuture<Void> attach(Map<String, Object> args) {
synchronized(this) {
// If this is the first time we're attaching to the module...
if (this.suspendedState == null) {
this.stopAtEveryStatement = "true".equals(args.get(STOP_AT_EVERY_STATEMENT));
// We accept both the "true" string and a Boolean true value
Object argStop = args.get(STOP_AT_EVERY_STATEMENT);
this.stopAtEveryStatement = "true".equals(argStop) || Boolean.TRUE.equals(argStop);

// Prepare the suspended state
suspendedState = new SuspendedState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,21 @@ public void defaultAndInlineBreakpoints() throws Exception {
}

@Test
public void stopAtAllStatements() throws Exception {
public void stopAtAllStatementsString() throws Exception {
testStopAtEveryStatement("true");
}

@Test
public void stopAtAllStatementsBoolean() throws Exception {
testStopAtEveryStatement(true);
}

private void testStopAtEveryStatement(final Object argStop) throws Exception {
SetBreakpointsResponse stopResult = adapter.setBreakpoints(createBreakpoints(createBreakpoint(2))).get();
assertTrue("The breakpoint at line 2 was verified", stopResult.getBreakpoints()[0].isVerified());

// Attach with the "stop at every statement" option turned on
attach(Collections.singletonMap(EpsilonDebugAdapter.STOP_AT_EVERY_STATEMENT, "true"));
attach(Collections.singletonMap(EpsilonDebugAdapter.STOP_AT_EVERY_STATEMENT, argStop));

// Break on the first static region of line 2
assertStoppedBecauseOf(StoppedEventArgumentsReason.BREAKPOINT);
Expand Down

0 comments on commit 4b3f2f5

Please sign in to comment.