Refine failure scenario. (#244)

This commit is contained in:
Yaohai Zheng 2018-03-06 10:12:39 +08:00 committed by GitHub
parent 820642f7bb
commit ef4de79c17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 8 deletions

View File

@ -5,7 +5,11 @@ import * as vscode from "vscode";
const suppressedReasons: Set<string> = new Set();
const NOT_SHOW_AGAIN: string = "Not show again";
const YES_BUTTON: string = "Yes";
const NO_BUTTON: string = "No";
const NEVER_BUTTON: string = "Not show again";
const JAVA_LANGID: string = "java";
@ -34,19 +38,23 @@ export function initializeHotCodeReplace(context: vscode.ExtensionContext) {
}
if (customEvent.body.changeType === HcrChangeType.BUILD_COMPLETE) {
return vscode.window.withProgress({location: vscode.ProgressLocation.Window}, (progress) => {
progress.report({message: "Applying code changes..."});
return vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (progress) => {
progress.report({ message: "Applying code changes..." });
return customEvent.session.customRequest("redefineClasses");
});
}
if (customEvent.body.changeType === HcrChangeType.ERROR || customEvent.body.changeType === HcrChangeType.WARNING) {
if (!suppressedReasons.has(customEvent.body.message)) {
vscode.window.showInformationMessage(`Hot code replace failed - ${customEvent.body.message}`, NOT_SHOW_AGAIN).then((res) => {
if (res === NOT_SHOW_AGAIN) {
suppressedReasons.add(customEvent.body.message);
}
});
vscode.window.showInformationMessage(
`Hot code replace failed - ${customEvent.body.message}. Would you like to restart the debug session?`,
YES_BUTTON, NO_BUTTON, NEVER_BUTTON).then((res) => {
if (res === NEVER_BUTTON) {
suppressedReasons.add(customEvent.body.message);
} else if (res === YES_BUTTON) {
vscode.commands.executeCommand("workbench.action.debug.restart");
}
});
}
}
}));