Skip to content

Commit 5f15f9a

Browse files
Provide context menu to continue/pause all/other threads (#748)
Signed-off-by: Jinbo Wang <[email protected]>
1 parent 71e82d3 commit 5f15f9a

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

package.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@
6464
{
6565
"command": "java.debug.debugJavaFile",
6666
"title": "Debug"
67+
},
68+
{
69+
"command": "java.debug.continueAll",
70+
"title": "Continue All"
71+
},
72+
{
73+
"command": "java.debug.continueOthers",
74+
"title": "Continue Others"
75+
},
76+
{
77+
"command": "java.debug.pauseAll",
78+
"title": "Pause All"
79+
},
80+
{
81+
"command": "java.debug.pauseOthers",
82+
"title": "Pause Others"
6783
}
6884
],
6985
"menus": {
@@ -98,6 +114,24 @@
98114
"when": "inDebugMode && debugType == java && javaHotReload == 'manual'"
99115
}
100116
],
117+
"debug/callstack/context": [
118+
{
119+
"command": "java.debug.continueAll",
120+
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
121+
},
122+
{
123+
"command": "java.debug.continueOthers",
124+
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
125+
},
126+
{
127+
"command": "java.debug.pauseAll",
128+
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
129+
},
130+
{
131+
"command": "java.debug.pauseOthers",
132+
"when": "inDebugMode && debugType == java && callStackItemType == 'thread'"
133+
}
134+
],
101135
"commandPalette": [
102136
{
103137
"command": "java.debug.hotCodeReplace",
@@ -110,6 +144,22 @@
110144
{
111145
"command": "java.debug.debugJavaFile",
112146
"when": "false"
147+
},
148+
{
149+
"command": "java.debug.continueAll",
150+
"when": "false"
151+
},
152+
{
153+
"command": "java.debug.continueOthers",
154+
"when": "false"
155+
},
156+
{
157+
"command": "java.debug.pauseAll",
158+
"when": "false"
159+
},
160+
{
161+
"command": "java.debug.pauseOthers",
162+
"when": "false"
113163
}
114164
]
115165
},

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { initializeCodeLensProvider, startDebugging } from "./debugCodeLensProvi
1313
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace, NO_BUTTON, YES_BUTTON } from "./hotCodeReplace";
1414
import { IMainMethod, resolveMainMethod } from "./languageServerPlugin";
1515
import { logger, Type } from "./logger";
16+
import { initializeThreadOperations } from "./threadOperations";
1617
import * as utility from "./utility";
1718

1819
export async function activate(context: vscode.ExtensionContext) {
@@ -42,6 +43,7 @@ function initializeExtension(operationId: string, context: vscode.ExtensionConte
4243
}));
4344
initializeHotCodeReplace(context);
4445
initializeCodeLensProvider(context);
46+
initializeThreadOperations(context);
4547
}
4648

4749
// this method is called when your extension is deactivated

src/threadOperations.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import * as vscode from "vscode";
5+
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
6+
7+
export function initializeThreadOperations(context: vscode.ExtensionContext) {
8+
context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.continueAll", async (threadId) => {
9+
await operateThread("continueAll", threadId);
10+
}));
11+
12+
context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.continueOthers", async (threadId) => {
13+
await operateThread("continueOthers", threadId);
14+
}));
15+
16+
context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.pauseAll", async (threadId) => {
17+
await operateThread("pauseAll", threadId);
18+
}));
19+
20+
context.subscriptions.push(instrumentOperationAsVsCodeCommand("java.debug.pauseOthers", async (threadId) => {
21+
await operateThread("pauseOthers", threadId);
22+
}));
23+
}
24+
25+
async function operateThread(request: string, threadId: any): Promise<void> {
26+
const debugSession: vscode.DebugSession = vscode.debug.activeDebugSession;
27+
if (!debugSession) {
28+
return;
29+
}
30+
31+
if (debugSession.configuration.noDebug) {
32+
return;
33+
}
34+
35+
await debugSession.customRequest(request, { threadId });
36+
}

0 commit comments

Comments
 (0)