@@ -135,18 +135,8 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
135135 await updateDebugSettings ( ) ;
136136 }
137137
138- /**
139- * If no launch.json exists in the current workspace folder
140- * delegate to provideDebugConfigurations api to generate the initial launch.json configurations
141- */
142- if ( this . isEmptyConfig ( config ) && folder ) {
143- // Follow the feature request https://github.com/Microsoft/vscode/issues/54213#issuecomment-420965778,
144- // in order to generate launch.json, the resolveDebugConfiguration api must return null explicitly.
145- return null ;
146- }
147-
148- // If it's the single file case that no workspace folder is opened, generate debug config in memory
149- if ( this . isEmptyConfig ( config ) && ! folder ) {
138+ // If no debug configuration is provided, then generate one in memory.
139+ if ( this . isEmptyConfig ( config ) ) {
150140 config . type = "java" ;
151141 config . name = "Java Debug" ;
152142 config . request = "launch" ;
@@ -293,13 +283,13 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
293283 return mainEntries [ 0 ] ;
294284 } else if ( mainEntries . length > 1 ) {
295285 return this . showMainClassQuickPick ( this . formatMainClassOptions ( mainEntries ) ,
296- `Multiple main classes found in the file ' ${ path . basename ( currentFile ) } ', please select one first .` ) ;
286+ `Please select a main class you want to run .` ) ;
297287 }
298288 }
299289
300290 const hintMessage = currentFile ?
301- `No main class found in the file '${ path . basename ( currentFile ) } ', please select main class<project name> again .` :
302- "Please select main class<project name> ." ;
291+ `The file '${ path . basename ( currentFile ) } ' is not executable , please select a main class you want to run .` :
292+ "Please select a main class you want to run ." ;
303293 return this . promptMainClass ( folder , hintMessage ) ;
304294 }
305295
@@ -389,8 +379,9 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
389379 private async promptMainClass ( folder : vscode . Uri | undefined , hintMessage ?: string ) : Promise < lsPlugin . IMainClassOption | undefined > {
390380 const res = await lsPlugin . resolveMainClass ( folder ) ;
391381 if ( res . length === 0 ) {
382+ const workspaceFolder = folder ? vscode . workspace . getWorkspaceFolder ( folder ) : undefined ;
392383 throw new utility . UserError ( {
393- message : " Cannot find a class with the main method." ,
384+ message : ` Cannot find a class with the main method${ workspaceFolder ? " in the folder '" + workspaceFolder . name + "'" : "" } .` ,
394385 type : Type . USAGEERROR ,
395386 anchor : anchor . CANNOT_FIND_MAIN_CLASS ,
396387 } ) ;
0 commit comments