only do rebuild for single file (#176)

Signed-off-by: xuzho <xuzho@microsoft.com>
This commit is contained in:
Xuan Zhou 2017-11-28 18:23:23 +08:00 committed by GitHub
parent 4bbf1ef372
commit 676af6d425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -34,7 +34,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
return vscode.window.withProgress({location: vscode.ProgressLocation.Window}, (p) => {
return new Promise((resolve, reject) => {
p.report({message: "Auto generating configuration..."});
resolveMainClass(folder.uri).then((res: any[]) => {
resolveMainClass(folder ? folder.uri : undefined).then((res: any[]) => {
let cache;
cache = {};
const launchConfigs = res.map((item) => {
@ -86,20 +86,22 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
await updateDebugSettings();
}
try {
const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE);
console.log(buildResult);
} catch (err) {
vscode.window.showErrorMessage("Build failed, please fix build error first.");
return config;
}
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
// check whether it is opened as a folder
if (folder !== undefined) {
// for opened with folder, return directly.
return config;
}
// only rebuild for single file case before the build error issue is resolved.
try {
const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE, false);
console.log(buildResult);
} catch (err) {
const ans = await vscode.window.showErrorMessage("Build failed, do you want to continue?", "Proceed", "Abort");
if (ans !== "Proceed") {
return undefined;
}
}
// Generate config in memory for single file
config.type = "java";
config.name = "Java Debug";
@ -111,7 +113,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
if (config.request === "launch") {
if (!config.mainClass) {
const res = <any[]>(await resolveMainClass(folder.uri));
const res = <any[]>(await resolveMainClass(folder ? folder.uri : undefined));
if (res.length === 0) {
vscode.window.showErrorMessage(
"Cannot resolve main class automatically, please specify the mainClass " +
@ -223,7 +225,10 @@ function resolveClasspath(mainClass, projectName) {
}
function resolveMainClass(workspaceUri: vscode.Uri) {
if (workspaceUri) {
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINCLASS, workspaceUri.toString());
}
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINCLASS);
}
async function updateDebugSettings() {