Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 17 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as commands from "./commands";
import { JavaDebugConfigurationProvider } from "./configurationProvider";
import { HCR_EVENT, JAVA_LANGID, USER_NOTIFICATION_EVENT } from "./constants";
import { initializeCodeLensProvider, startDebugging } from "./debugCodeLensProvider";
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace } from "./hotCodeReplace";
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace, NO_BUTTON, YES_BUTTON } from "./hotCodeReplace";
import { IMainMethod, resolveMainMethod } from "./languageServerPlugin";
import { logger, Type } from "./logger";
import * as utility from "./utility";
Expand Down Expand Up @@ -126,6 +126,22 @@ function specifyProgramArguments(context: vscode.ExtensionContext): Thenable<str
}

async function applyHCR() {
const debugSession: vscode.DebugSession = vscode.debug.activeDebugSession;
if (!debugSession) {
return;
}

if (debugSession.configuration.noDebug) {
vscode.window.showWarningMessage("Run mode doesn't support Hot Code Replace feature, would you like to restart the program?",
YES_BUTTON, NO_BUTTON).then((res) => {
if (res === YES_BUTTON) {
vscode.commands.executeCommand("workbench.action.debug.restart");
}
});

return;
}

const autobuildConfig: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.autobuild");
if (!autobuildConfig.enabled) {
const ans = await vscode.window.showWarningMessage(
Expand All @@ -142,11 +158,6 @@ async function applyHCR() {
}
}

const debugSession: vscode.DebugSession = vscode.debug.activeDebugSession;
if (!debugSession) {
return;
}

return vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, async (progress) => {
progress.report({ message: "Applying code changes..." });

Expand Down
4 changes: 2 additions & 2 deletions src/hotCodeReplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import * as utility from "./utility";

const suppressedReasons: Set<string> = new Set();

const YES_BUTTON: string = "Yes";
export const YES_BUTTON: string = "Yes";

const NO_BUTTON: string = "No";
export const NO_BUTTON: string = "No";

const NEVER_BUTTON: string = "Do not show again";

Expand Down