From 3dafb13bb2622e2e5f5d79600808605b4d33a9b5 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Mon, 24 Jul 2023 11:07:21 +0800 Subject: [PATCH 1/2] Subscribe to Java extension's SourceInvalidatedEvent and refresh the stack frames if they used the affected source --- src/extension.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 9fb1f38a..390f1fba 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -26,6 +26,7 @@ import { JavaTerminalLinkProvder } from "./terminalLinkProvider"; import { initializeThreadOperations } from "./threadOperations"; import * as utility from "./utility"; import { registerVariableMenuCommands } from "./variableMenu"; +import { promisify } from "util"; export async function activate(context: vscode.ExtensionContext): Promise { await initializeFromJsonFile(context.asAbsolutePath("./package.json"), { @@ -75,6 +76,7 @@ function initializeExtension(_operationId: string, context: vscode.ExtensionCont initializeHotCodeReplace(context); initializeCodeLensProvider(context); initializeThreadOperations(context); + subscribeToJavaExtensionEvents(); context.subscriptions.push(vscode.languages.registerInlineValuesProvider("java", new JavaInlineValuesProvider())); return { @@ -87,6 +89,35 @@ export async function deactivate() { await disposeTelemetryWrapper(); } +const delay = promisify(setTimeout); +async function subscribeToJavaExtensionEvents(): Promise { + const javaExt = vscode.extensions.getExtension("redhat.java"); + if (!javaExt) { + return; + } + + // wait javaExt to activate + const timeout = 30 * 60 * 1000; // wait 30 min at most + let count = 0; + while(!javaExt.isActive && count < timeout) { + await delay(1000); + count += 1000; + } + + if (javaExt.isActive) { + javaExt.exports?.onDidSourceInvalidate?.((event: any) => { + if (event?.affectedRootPaths?.length) { + const activeDebugSession = vscode.debug.activeDebugSession; + if (activeDebugSession?.type === "java") { + activeDebugSession.customRequest("refreshFrames", { + affectedRootPaths: event.affectedRootPaths, + }); + } + } + }); + } +} + function registerDebugEventListener(context: vscode.ExtensionContext) { const measureKeys = ["duration"]; context.subscriptions.push(vscode.debug.onDidTerminateDebugSession((e) => { From 5b2209be3c7189e7f323ec97bb4392032aa5850a Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Mon, 24 Jul 2023 11:11:50 +0800 Subject: [PATCH 2/2] fix tslint --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 390f1fba..03813183 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -99,7 +99,7 @@ async function subscribeToJavaExtensionEvents(): Promise { // wait javaExt to activate const timeout = 30 * 60 * 1000; // wait 30 min at most let count = 0; - while(!javaExt.isActive && count < timeout) { + while (!javaExt.isActive && count < timeout) { await delay(1000); count += 1000; }