@@ -24,6 +24,7 @@ import {
24
24
} from "../utils" ;
25
25
import { PackageNode } from "../explorer/models/packageNode" ;
26
26
import { NodeBase } from "../explorer/models/nodeBase" ;
27
+ import { RootNode } from "../explorer/models/rootNode" ;
27
28
28
29
async function compileFlags ( ) : Promise < string > {
29
30
const defaultFlags = config ( ) . compileFlags ;
@@ -180,7 +181,7 @@ function updateOthers(others: string[], baseUri: vscode.Uri) {
180
181
dotParts . length <= partsToConvert
181
182
? uri . path
182
183
: dotParts . slice ( 0 , partsToConvert ) . join ( "/" ) + "." + dotParts . slice ( partsToConvert ) . join ( "." ) ;
183
- console . log ( `updateOthers: uri.path=${ uri . path } baseUri.path=${ baseUri . path } correctPath=${ correctPath } ` ) ;
184
+ // console.log(`updateOthers: uri.path=${uri.path} baseUri.path=${baseUri.path} correctPath=${correctPath}`);
184
185
fileSystemProvider . fireFileChanged ( uri . with ( { path : correctPath } ) ) ;
185
186
} else {
186
187
documentContentProvider . update ( uri ) ;
@@ -222,26 +223,27 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
222
223
return vscode . window
223
224
. withProgress (
224
225
{
225
- cancellable : false ,
226
+ cancellable : true ,
226
227
location : vscode . ProgressLocation . Notification ,
227
228
title : `Compiling: ${ docs . length === 1 ? docs . map ( ( el ) => el . name ) . join ( ", " ) : docs . length + " files" } ` ,
228
229
} ,
229
- ( ) =>
230
+ ( progress , token : vscode . CancellationToken ) =>
230
231
api
231
- . actionCompile (
232
+ . asyncCompile (
232
233
docs . map ( ( el ) => el . name ) ,
234
+ token ,
233
235
flags
234
236
)
235
237
. then ( ( data ) => {
236
238
const info = docs . length > 1 ? "" : `${ docs [ 0 ] . name } : ` ;
237
239
if ( data . status && data . status . errors && data . status . errors . length ) {
238
240
throw new Error ( `${ info } Compile error` ) ;
239
241
} else if ( ! config ( "suppressCompileMessages" ) ) {
240
- vscode . window . showInformationMessage ( `${ info } Compilation succeeded` , "Hide " ) ;
242
+ vscode . window . showInformationMessage ( `${ info } Compilation succeeded. ` , "Dismiss " ) ;
241
243
}
242
244
return docs ;
243
245
} )
244
- . catch ( ( error : Error ) => {
246
+ . catch ( ( ) => {
245
247
if ( ! config ( "suppressCompileErrorMessages" ) ) {
246
248
vscode . window
247
249
. showErrorMessage (
@@ -255,7 +257,7 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
255
257
}
256
258
} ) ;
257
259
}
258
- // Even when compile failed we should still fetch server changes
260
+ // Always fetch server changes, even when compile failed or got cancelled
259
261
return docs ;
260
262
} )
261
263
)
@@ -344,7 +346,7 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
344
346
throw new Error ( `No Active Connection` ) ;
345
347
}
346
348
const confirm = await vscode . window . showWarningMessage (
347
- `Compiling all files in namespace ' ${ api . ns } ' might be expensive. Are you sure you want to proceed?` ,
349
+ `Compiling all files in namespace ${ api . ns } might be expensive. Are you sure you want to proceed?` ,
348
350
"Cancel" ,
349
351
"Confirm"
350
352
) ;
@@ -360,21 +362,40 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
360
362
}
361
363
vscode . window . withProgress (
362
364
{
363
- cancellable : false ,
365
+ cancellable : true ,
364
366
location : vscode . ProgressLocation . Notification ,
365
- title : `Compiling Namespace: ${ api . ns } ` ,
367
+ title : `Compiling namespace ${ api . ns } ` ,
366
368
} ,
367
- async ( ) => {
368
- const data = await api . actionCompile ( fileTypes , flags ) ;
369
- if ( data . status && data . status . errors && data . status . errors . length ) {
370
- // console.error(data.status.summary);
371
- throw new Error ( `Compiling Namespace: ${ api . ns } Error` ) ;
372
- } else {
373
- vscode . window . showInformationMessage ( `Compiling Namespace: ${ api . ns } Success` ) ;
374
- }
375
- const file = currentFile ( ) ;
376
- return loadChanges ( [ file ] ) ;
377
- }
369
+ ( progress , token : vscode . CancellationToken ) =>
370
+ api
371
+ . asyncCompile ( fileTypes , token , flags )
372
+ . then ( ( data ) => {
373
+ if ( data . status && data . status . errors && data . status . errors . length ) {
374
+ throw new Error ( `Compiling Namespace: ${ api . ns } Error` ) ;
375
+ } else if ( ! config ( "suppressCompileMessages" ) ) {
376
+ vscode . window . showInformationMessage ( `Compiling namespace ${ api . ns } succeeded.` , "Dismiss" ) ;
377
+ }
378
+ } )
379
+ . catch ( ( ) => {
380
+ if ( ! config ( "suppressCompileErrorMessages" ) ) {
381
+ vscode . window
382
+ . showErrorMessage (
383
+ `Compiling namespace ${ api . ns } failed. Check 'ObjectScript' output channel for details.` ,
384
+ "Show" ,
385
+ "Dismiss"
386
+ )
387
+ . then ( ( action ) => {
388
+ if ( action === "Show" ) {
389
+ outputChannel . show ( true ) ;
390
+ }
391
+ } ) ;
392
+ }
393
+ } )
394
+ . then ( ( ) => {
395
+ // Always fetch server changes, even when compile failed or got cancelled
396
+ const file = currentFile ( ) ;
397
+ return loadChanges ( [ file ] ) ;
398
+ } )
378
399
) ;
379
400
}
380
401
@@ -442,9 +463,43 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
442
463
docs . push ( node . fullName + ".*.cls" ) ;
443
464
break ;
444
465
}
466
+ } else if ( node instanceof RootNode && node . contextValue === "dataNode:cspApplication" ) {
467
+ docs . push ( node . fullName + "/*" ) ;
445
468
} else {
446
469
docs . push ( node . fullName ) ;
447
470
}
448
471
}
449
- return api . actionCompile ( docs , flags ) ;
472
+ return vscode . window . withProgress (
473
+ {
474
+ cancellable : true ,
475
+ location : vscode . ProgressLocation . Notification ,
476
+ title : `Compiling ${ nodes . length === 1 ? nodes [ 0 ] . fullName : nodes . length + " nodes" } ` ,
477
+ } ,
478
+ ( progress , token : vscode . CancellationToken ) =>
479
+ api
480
+ . asyncCompile ( docs , token , flags )
481
+ . then ( ( data ) => {
482
+ const info = nodes . length > 1 ? "" : `${ nodes [ 0 ] . fullName } : ` ;
483
+ if ( data . status && data . status . errors && data . status . errors . length ) {
484
+ throw new Error ( `${ info } Compile error` ) ;
485
+ } else if ( ! config ( "suppressCompileMessages" ) ) {
486
+ vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
487
+ }
488
+ } )
489
+ . catch ( ( ) => {
490
+ if ( ! config ( "suppressCompileErrorMessages" ) ) {
491
+ vscode . window
492
+ . showErrorMessage (
493
+ `Compilation failed. Check 'ObjectScript' output channel for details.` ,
494
+ "Show" ,
495
+ "Dismiss"
496
+ )
497
+ . then ( ( action ) => {
498
+ if ( action === "Show" ) {
499
+ outputChannel . show ( true ) ;
500
+ }
501
+ } ) ;
502
+ }
503
+ } )
504
+ ) ;
450
505
}
0 commit comments