@@ -26,6 +26,7 @@ import { JavaTerminalLinkProvder } from "./terminalLinkProvider";
2626import { initializeThreadOperations } from "./threadOperations" ;
2727import * as utility from "./utility" ;
2828import { registerVariableMenuCommands } from "./variableMenu" ;
29+ import { promisify } from "util" ;
2930
3031export async function activate ( context : vscode . ExtensionContext ) : Promise < any > {
3132 await initializeFromJsonFile ( context . asAbsolutePath ( "./package.json" ) , {
@@ -75,6 +76,7 @@ function initializeExtension(_operationId: string, context: vscode.ExtensionCont
7576 initializeHotCodeReplace ( context ) ;
7677 initializeCodeLensProvider ( context ) ;
7778 initializeThreadOperations ( context ) ;
79+ subscribeToJavaExtensionEvents ( ) ;
7880
7981 context . subscriptions . push ( vscode . languages . registerInlineValuesProvider ( "java" , new JavaInlineValuesProvider ( ) ) ) ;
8082 return {
@@ -87,6 +89,35 @@ export async function deactivate() {
8789 await disposeTelemetryWrapper ( ) ;
8890}
8991
92+ const delay = promisify ( setTimeout ) ;
93+ async function subscribeToJavaExtensionEvents ( ) : Promise < void > {
94+ const javaExt = vscode . extensions . getExtension ( "redhat.java" ) ;
95+ if ( ! javaExt ) {
96+ return ;
97+ }
98+
99+ // wait javaExt to activate
100+ const timeout = 30 * 60 * 1000 ; // wait 30 min at most
101+ let count = 0 ;
102+ while ( ! javaExt . isActive && count < timeout ) {
103+ await delay ( 1000 ) ;
104+ count += 1000 ;
105+ }
106+
107+ if ( javaExt . isActive ) {
108+ javaExt . exports ?. onDidSourceInvalidate ?.( ( event : any ) => {
109+ if ( event ?. affectedRootPaths ?. length ) {
110+ const activeDebugSession = vscode . debug . activeDebugSession ;
111+ if ( activeDebugSession ?. type === "java" ) {
112+ activeDebugSession . customRequest ( "refreshFrames" , {
113+ affectedRootPaths : event . affectedRootPaths ,
114+ } ) ;
115+ }
116+ }
117+ } ) ;
118+ }
119+ }
120+
90121function registerDebugEventListener ( context : vscode . ExtensionContext ) {
91122 const measureKeys = [ "duration" ] ;
92123 context . subscriptions . push ( vscode . debug . onDidTerminateDebugSession ( ( e ) => {
0 commit comments