@@ -38,18 +38,16 @@ module.exports = class AntTreeDataProvider {
3838 path . join ( context . extensionPath , 'dist' , 'resources' , 'icons' , 'light' , 'dependency.svg' )
3939 )
4040
41- this . targetRunner = null
4241 this . targets = null
4342 this . project = null
4443 this . buildFilenames = 'build.xml'
4544 this . buildFileDirectories = '.'
4645 this . eventListeners = [ ]
4746
48- var workspaceFolders = vscode . workspace . workspaceFolders
49- if ( workspaceFolders ) {
50- this . rootPath = workspaceFolders [ 0 ] . uri . fsPath
51- // this.watchBuildXml(workspaceFolders)
52- this . BuildFileParser = new BuildFileParser ( workspaceFolders [ 0 ] . uri . fsPath )
47+ this . workspaceFolders = vscode . workspace . workspaceFolders
48+ this . workspaceFolderNumber = 0
49+ if ( this . workspaceFolders ) {
50+ this . setWorkspaceFolder ( )
5351 }
5452
5553 // event for notify of change of data
@@ -66,17 +64,25 @@ module.exports = class AntTreeDataProvider {
6664 this . getConfigOptions ( )
6765 }
6866
67+ setWorkspaceFolder ( ) {
68+ this . rootPath = this . workspaceFolders [ this . workspaceFolderNumber ] . uri . fsPath
69+ // this.watchBuildXml(workspaceFolders)
70+ this . BuildFileParser = new BuildFileParser ( this . workspaceFolders [ this . workspaceFolderNumber ] . uri . fsPath )
71+
72+ vscode . commands . executeCommand ( 'vscode-ant.setRunnerWorkspaceFolder' , this . workspaceFolders [ this . workspaceFolderNumber ] )
73+ vscode . commands . executeCommand ( 'vscode-ant.setAutoWorkspaceFolder' , this . workspaceFolders [ this . workspaceFolderNumber ] )
74+ }
75+
6976 onDidChangeConfiguration ( ) {
7077 this . getConfigOptions ( )
7178 this . refresh ( )
7279 }
7380
7481 onDidChangeWorkspaceFolders ( ) {
75- var workspaceFolders = vscode . workspace . workspaceFolders
76-
77- if ( workspaceFolders ) {
78- this . rootPath = workspaceFolders [ 0 ] . uri . fsPath
79- this . BuildFileParser = new BuildFileParser ( workspaceFolders [ 0 ] . uri . fsPath )
82+ this . workspaceFolders = vscode . workspace . workspaceFolders
83+ this . workspaceFolderNumber = 0
84+ if ( this . workspaceFolders ) {
85+ this . setWorkspaceFolder ( )
8086 }
8187
8288 this . refresh ( )
@@ -268,7 +274,14 @@ module.exports = class AntTreeDataProvider {
268274 try {
269275 var buildFilename = await this . BuildFileParser . findBuildFile ( this . buildFileDirectories . split ( ',' ) , this . buildFilenames . split ( ',' ) )
270276 } catch ( error ) {
271- messageHelper . showInformationMessage ( 'Workspace has no build.xml files.' )
277+ if ( this . workspaceFolderNumber < ( this . workspaceFolders . length - 1 ) ) {
278+ this . workspaceFolderNumber ++
279+ this . setWorkspaceFolder ( )
280+ this . refresh ( )
281+ } else {
282+ messageHelper . showInformationMessage ( 'Workspace has no build.xml files.' )
283+ }
284+
272285 return resolve ( [ ] )
273286 }
274287
@@ -378,12 +391,12 @@ module.exports = class AntTreeDataProvider {
378391 }
379392
380393 runSelectedAntTarget ( ) {
381- if ( selectedAntTarget && this . targetRunner ) {
394+ if ( selectedAntTarget ) {
382395 var target = selectedAntTarget . name
383396 if ( target . indexOf ( ' ' ) >= 0 ) {
384397 target = '"' + target + '"'
385398 }
386- this . targetRunner . runAntTarget ( { name : target , sourceFile : selectedAntTarget . sourceFile } )
399+ vscode . commands . executeCommand ( 'vscode-ant.runAntTarget' , { name : target , sourceFile : selectedAntTarget . sourceFile } )
387400 }
388401 }
389402
0 commit comments