Skip to content

Commit

Permalink
Provide context menu to continue/pause all/other threads (#748)
Browse files Browse the repository at this point in the history
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
  • Loading branch information
testforstephen committed Jan 16, 2020
1 parent 71e82d3 commit 5f15f9a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
50 changes: 50 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@
{
"command": "java.debug.debugJavaFile",
"title": "Debug"
},
{
"command": "java.debug.continueAll",
"title": "Continue All"
},
{
"command": "java.debug.continueOthers",
"title": "Continue Others"
},
{
"command": "java.debug.pauseAll",
"title": "Pause All"
},
{
"command": "java.debug.pauseOthers",
"title": "Pause Others"
}
],
"menus": {
Expand Down Expand Up @@ -98,6 +114,24 @@
"when": "inDebugMode && debugType == java && javaHotReload == 'manual'"
}
],
"debug/callstack/context": [
{
"command": "java.debug.continueAll",
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
},
{
"command": "java.debug.continueOthers",
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
},
{
"command": "java.debug.pauseAll",
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
},
{
"command": "java.debug.pauseOthers",
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
}
],
"commandPalette": [
{
"command": "java.debug.hotCodeReplace",
Expand All @@ -110,6 +144,22 @@
{
"command": "java.debug.debugJavaFile",
"when": "false"
},
{
"command": "java.debug.continueAll",
"when": "false"
},
{
"command": "java.debug.continueOthers",
"when": "false"
},
{
"command": "java.debug.pauseAll",
"when": "false"
},
{
"command": "java.debug.pauseOthers",
"when": "false"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { initializeCodeLensProvider, startDebugging } from "./debugCodeLensProvi
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace, NO_BUTTON, YES_BUTTON } from "./hotCodeReplace";
import { IMainMethod, resolveMainMethod } from "./languageServerPlugin";
import { logger, Type } from "./logger";
import { initializeThreadOperations } from "./threadOperations";
import * as utility from "./utility";

export async function activate(context: vscode.ExtensionContext) {
Expand Down Expand Up @@ -42,6 +43,7 @@ function initializeExtension(operationId: string, context: vscode.ExtensionConte
}));
initializeHotCodeReplace(context);
initializeCodeLensProvider(context);
initializeThreadOperations(context);
}

// this method is called when your extension is deactivated
Expand Down
36 changes: 36 additions & 0 deletions src/threadOperations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import * as vscode from "vscode";
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";

export function initializeThreadOperations(context: vscode.ExtensionContext) {
context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.continueAll", async (threadId) => {
await operateThread("continueAll", threadId);
}));

context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.continueOthers", async (threadId) => {
await operateThread("continueOthers", threadId);
}));

context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.pauseAll", async (threadId) => {
await operateThread("pauseAll", threadId);
}));

context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.pauseOthers", async (threadId) => {
await operateThread("pauseOthers", threadId);
}));
}

async function operateThread(request: string, threadId: any): Promise<void> {
const debugSession: vscode.DebugSession = vscode.debug.activeDebugSession;
if (!debugSession) {
return;
}

if (debugSession.configuration.noDebug) {
return;
}

await debugSession.customRequest(request, { threadId });
}

0 comments on commit 5f15f9a

Please sign in to comment.