Skip to content

Commit 6fc0528

Browse files
Refresh variables with new variable formatters (#369)
1 parent f9aa964 commit 6fc0528

File tree

5 files changed

+100
-1
lines changed

5 files changed

+100
-1
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"java.configuration.updateBuildConfiguration": "automatic",
32
"files.exclude": {
43
"**/.git": true,
54
"**/*.class": true,

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/DebugAdapter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.microsoft.java.debug.core.adapter.handler.InitializeRequestHandler;
3333
import com.microsoft.java.debug.core.adapter.handler.InlineValuesRequestHandler;
3434
import com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler;
35+
import com.microsoft.java.debug.core.adapter.handler.RefreshVariablesHandler;
3536
import com.microsoft.java.debug.core.adapter.handler.RestartFrameHandler;
3637
import com.microsoft.java.debug.core.adapter.handler.ScopesRequestHandler;
3738
import com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler;
@@ -123,6 +124,7 @@ private void initialize() {
123124
registerHandlerForDebug(new DataBreakpointInfoRequestHandler());
124125
registerHandlerForDebug(new SetDataBreakpointsRequestHandler());
125126
registerHandlerForDebug(new InlineValuesRequestHandler());
127+
registerHandlerForDebug(new RefreshVariablesHandler());
126128

127129
// NO_DEBUG mode only
128130
registerHandlerForNoDebug(new DisconnectRequestWithoutDebuggingHandler());
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2021 Microsoft Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Microsoft Corporation - initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.microsoft.java.debug.core.adapter.handler;
13+
14+
import java.util.Arrays;
15+
import java.util.List;
16+
import java.util.concurrent.CompletableFuture;
17+
18+
import com.microsoft.java.debug.core.DebugSettings;
19+
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
20+
import com.microsoft.java.debug.core.adapter.IDebugRequestHandler;
21+
import com.microsoft.java.debug.core.protocol.Events.InvalidatedAreas;
22+
import com.microsoft.java.debug.core.protocol.Events.InvalidatedEvent;
23+
import com.microsoft.java.debug.core.protocol.Messages.Response;
24+
import com.microsoft.java.debug.core.protocol.Requests.Arguments;
25+
import com.microsoft.java.debug.core.protocol.Requests.Command;
26+
import com.microsoft.java.debug.core.protocol.Requests.RefreshVariablesArguments;
27+
28+
public class RefreshVariablesHandler implements IDebugRequestHandler {
29+
30+
@Override
31+
public List<Command> getTargetCommands() {
32+
return Arrays.asList(Command.REFRESHVARIABLES);
33+
}
34+
35+
@Override
36+
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response,
37+
IDebugAdapterContext context) {
38+
RefreshVariablesArguments refreshArgs = (RefreshVariablesArguments) arguments;
39+
if (refreshArgs != null) {
40+
DebugSettings.getCurrent().showHex = refreshArgs.showHex;
41+
DebugSettings.getCurrent().showQualifiedNames = refreshArgs.showQualifiedNames;
42+
DebugSettings.getCurrent().showStaticVariables = refreshArgs.showStaticVariables;
43+
DebugSettings.getCurrent().showLogicalStructure = refreshArgs.showLogicalStructure;
44+
DebugSettings.getCurrent().showToString = refreshArgs.showToString;
45+
}
46+
47+
context.getProtocolServer().sendEvent(new InvalidatedEvent(InvalidatedAreas.VARIABLES));
48+
return CompletableFuture.completedFuture(response);
49+
}
50+
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/protocol/Events.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package com.microsoft.java.debug.core.protocol;
1313

14+
import com.google.gson.annotations.SerializedName;
1415
import com.microsoft.java.debug.core.protocol.Types.Source;
1516

1617
/**
@@ -244,4 +245,42 @@ public UserNotificationEvent(NotificationType notifyType, String message) {
244245
this.message = message;
245246
}
246247
}
248+
249+
public static enum InvalidatedAreas {
250+
@SerializedName("all")
251+
ALL,
252+
@SerializedName("stacks")
253+
STACKS,
254+
@SerializedName("threads")
255+
THREADS,
256+
@SerializedName("variables")
257+
VARIABLES;
258+
}
259+
260+
public static class InvalidatedEvent extends DebugEvent {
261+
public InvalidatedAreas[] areas;
262+
public long threadId;
263+
public int frameId;
264+
265+
public InvalidatedEvent() {
266+
super("invalidated");
267+
}
268+
269+
public InvalidatedEvent(InvalidatedAreas area) {
270+
super("invalidated");
271+
this.areas = new InvalidatedAreas[]{area};
272+
}
273+
274+
public InvalidatedEvent(InvalidatedAreas area, long threadId) {
275+
super("invalidated");
276+
this.areas = new InvalidatedAreas[]{area};
277+
this.threadId = threadId;
278+
}
279+
280+
public InvalidatedEvent(InvalidatedAreas area, int frameId) {
281+
super("invalidated");
282+
this.areas = new InvalidatedAreas[]{area};
283+
this.frameId = frameId;
284+
}
285+
}
247286
}

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/protocol/Requests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ public static class SetVariableArguments extends Arguments {
297297
public ValueFormat format;
298298
}
299299

300+
public static class RefreshVariablesArguments extends Arguments {
301+
public boolean showStaticVariables = false;
302+
public boolean showQualifiedNames = false;
303+
public boolean showHex = false;
304+
public boolean showLogicalStructure = true;
305+
public boolean showToString = true;
306+
}
307+
300308
public static class SourceArguments extends Arguments {
301309
public int sourceReference;
302310
}
@@ -401,6 +409,7 @@ public static enum Command {
401409
PAUSEALL("pauseAll", ThreadOperationArguments.class),
402410
PAUSEOTHERS("pauseOthers", ThreadOperationArguments.class),
403411
INLINEVALUES("inlineValues", InlineValuesArguments.class),
412+
REFRESHVARIABLES("refreshVariables", RefreshVariablesArguments.class),
404413
UNSUPPORTED("", Arguments.class);
405414

406415
private String command;

0 commit comments

Comments
 (0)