Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
await initializeFromJsonFile(context.asAbsolutePath("./package.json"), {
Expand Down Expand Up @@ -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 {
Expand All @@ -87,6 +89,35 @@ export async function deactivate() {
await disposeTelemetryWrapper();
}

const delay = promisify(setTimeout);
async function subscribeToJavaExtensionEvents(): Promise<void> {
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) => {
Expand Down