Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"files.exclude": {
"**/.git": true,
"**/*.class": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.microsoft.java.debug.core.adapter.handler.InitializeRequestHandler;
import com.microsoft.java.debug.core.adapter.handler.InlineValuesRequestHandler;
import com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler;
import com.microsoft.java.debug.core.adapter.handler.RefreshVariablesHandler;
import com.microsoft.java.debug.core.adapter.handler.RestartFrameHandler;
import com.microsoft.java.debug.core.adapter.handler.ScopesRequestHandler;
import com.microsoft.java.debug.core.adapter.handler.SetBreakpointsRequestHandler;
Expand Down Expand Up @@ -123,6 +124,7 @@ private void initialize() {
registerHandlerForDebug(new DataBreakpointInfoRequestHandler());
registerHandlerForDebug(new SetDataBreakpointsRequestHandler());
registerHandlerForDebug(new InlineValuesRequestHandler());
registerHandlerForDebug(new RefreshVariablesHandler());

// NO_DEBUG mode only
registerHandlerForNoDebug(new DisconnectRequestWithoutDebuggingHandler());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2021 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*******************************************************************************/

package com.microsoft.java.debug.core.adapter.handler;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import com.microsoft.java.debug.core.DebugSettings;
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
import com.microsoft.java.debug.core.adapter.IDebugRequestHandler;
import com.microsoft.java.debug.core.protocol.Events.InvalidatedAreas;
import com.microsoft.java.debug.core.protocol.Events.InvalidatedEvent;
import com.microsoft.java.debug.core.protocol.Messages.Response;
import com.microsoft.java.debug.core.protocol.Requests.Arguments;
import com.microsoft.java.debug.core.protocol.Requests.Command;
import com.microsoft.java.debug.core.protocol.Requests.RefreshVariablesArguments;

public class RefreshVariablesHandler implements IDebugRequestHandler {

@Override
public List<Command> getTargetCommands() {
return Arrays.asList(Command.REFRESHVARIABLES);
}

@Override
public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response,
IDebugAdapterContext context) {
RefreshVariablesArguments refreshArgs = (RefreshVariablesArguments) arguments;
if (refreshArgs != null) {
DebugSettings.getCurrent().showHex = refreshArgs.showHex;
DebugSettings.getCurrent().showQualifiedNames = refreshArgs.showQualifiedNames;
DebugSettings.getCurrent().showStaticVariables = refreshArgs.showStaticVariables;
DebugSettings.getCurrent().showLogicalStructure = refreshArgs.showLogicalStructure;
DebugSettings.getCurrent().showToString = refreshArgs.showToString;
}

context.getProtocolServer().sendEvent(new InvalidatedEvent(InvalidatedAreas.VARIABLES));
return CompletableFuture.completedFuture(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

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

import com.google.gson.annotations.SerializedName;
import com.microsoft.java.debug.core.protocol.Types.Source;

/**
Expand Down Expand Up @@ -244,4 +245,42 @@ public UserNotificationEvent(NotificationType notifyType, String message) {
this.message = message;
}
}

public static enum InvalidatedAreas {
@SerializedName("all")
ALL,
@SerializedName("stacks")
STACKS,
@SerializedName("threads")
THREADS,
@SerializedName("variables")
VARIABLES;
}

public static class InvalidatedEvent extends DebugEvent {
public InvalidatedAreas[] areas;
public long threadId;
public int frameId;

public InvalidatedEvent() {
super("invalidated");
}

public InvalidatedEvent(InvalidatedAreas area) {
super("invalidated");
this.areas = new InvalidatedAreas[]{area};
}

public InvalidatedEvent(InvalidatedAreas area, long threadId) {
super("invalidated");
this.areas = new InvalidatedAreas[]{area};
this.threadId = threadId;
}

public InvalidatedEvent(InvalidatedAreas area, int frameId) {
super("invalidated");
this.areas = new InvalidatedAreas[]{area};
this.frameId = frameId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ public static class SetVariableArguments extends Arguments {
public ValueFormat format;
}

public static class RefreshVariablesArguments extends Arguments {
public boolean showStaticVariables = false;
public boolean showQualifiedNames = false;
public boolean showHex = false;
public boolean showLogicalStructure = true;
public boolean showToString = true;
}

public static class SourceArguments extends Arguments {
public int sourceReference;
}
Expand Down Expand Up @@ -401,6 +409,7 @@ public static enum Command {
PAUSEALL("pauseAll", ThreadOperationArguments.class),
PAUSEOTHERS("pauseOthers", ThreadOperationArguments.class),
INLINEVALUES("inlineValues", InlineValuesArguments.class),
REFRESHVARIABLES("refreshVariables", RefreshVariablesArguments.class),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REFRESH_VARIABLES would be better human-readable. For consistency just leave it as is. But consider to refactor all the enums one day?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i will use a separate PR to refactor these enums.

UNSUPPORTED("", Arguments.class);

private String command;
Expand Down