@@ -26,6 +26,7 @@ import { JavaTerminalLinkProvder } from "./terminalLinkProvider";
26
26
import { initializeThreadOperations } from "./threadOperations" ;
27
27
import * as utility from "./utility" ;
28
28
import { registerVariableMenuCommands } from "./variableMenu" ;
29
+ import { promisify } from "util" ;
29
30
30
31
export async function activate ( context : vscode . ExtensionContext ) : Promise < any > {
31
32
await initializeFromJsonFile ( context . asAbsolutePath ( "./package.json" ) , {
@@ -75,6 +76,7 @@ function initializeExtension(_operationId: string, context: vscode.ExtensionCont
75
76
initializeHotCodeReplace ( context ) ;
76
77
initializeCodeLensProvider ( context ) ;
77
78
initializeThreadOperations ( context ) ;
79
+ subscribeToJavaExtensionEvents ( ) ;
78
80
79
81
context . subscriptions . push ( vscode . languages . registerInlineValuesProvider ( "java" , new JavaInlineValuesProvider ( ) ) ) ;
80
82
return {
@@ -87,6 +89,35 @@ export async function deactivate() {
87
89
await disposeTelemetryWrapper ( ) ;
88
90
}
89
91
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
+
90
121
function registerDebugEventListener ( context : vscode . ExtensionContext ) {
91
122
const measureKeys = [ "duration" ] ;
92
123
context . subscriptions . push ( vscode . debug . onDidTerminateDebugSession ( ( e ) => {
0 commit comments