@@ -24,6 +24,7 @@ import {
2424} from "../utils" ;
2525import { PackageNode } from "../explorer/models/packageNode" ;
2626import { NodeBase } from "../explorer/models/nodeBase" ;
27+ import { RootNode } from "../explorer/models/rootNode" ;
2728
2829async function compileFlags ( ) : Promise < string > {
2930 const defaultFlags = config ( ) . compileFlags ;
@@ -180,7 +181,7 @@ function updateOthers(others: string[], baseUri: vscode.Uri) {
180181 dotParts . length <= partsToConvert
181182 ? uri . path
182183 : 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}`);
184185 fileSystemProvider . fireFileChanged ( uri . with ( { path : correctPath } ) ) ;
185186 } else {
186187 documentContentProvider . update ( uri ) ;
@@ -222,26 +223,27 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
222223 return vscode . window
223224 . withProgress (
224225 {
225- cancellable : false ,
226+ cancellable : true ,
226227 location : vscode . ProgressLocation . Notification ,
227228 title : `Compiling: ${ docs . length === 1 ? docs . map ( ( el ) => el . name ) . join ( ", " ) : docs . length + " files" } ` ,
228229 } ,
229- ( ) =>
230+ ( progress , token : vscode . CancellationToken ) =>
230231 api
231- . actionCompile (
232+ . asyncCompile (
232233 docs . map ( ( el ) => el . name ) ,
234+ token ,
233235 flags
234236 )
235237 . then ( ( data ) => {
236238 const info = docs . length > 1 ? "" : `${ docs [ 0 ] . name } : ` ;
237239 if ( data . status && data . status . errors && data . status . errors . length ) {
238240 throw new Error ( `${ info } Compile error` ) ;
239241 } else if ( ! config ( "suppressCompileMessages" ) ) {
240- vscode . window . showInformationMessage ( `${ info } Compilation succeeded` , "Hide " ) ;
242+ vscode . window . showInformationMessage ( `${ info } Compilation succeeded. ` , "Dismiss " ) ;
241243 }
242244 return docs ;
243245 } )
244- . catch ( ( error : Error ) => {
246+ . catch ( ( ) => {
245247 if ( ! config ( "suppressCompileErrorMessages" ) ) {
246248 vscode . window
247249 . showErrorMessage (
@@ -255,7 +257,7 @@ async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
255257 }
256258 } ) ;
257259 }
258- // Even when compile failed we should still fetch server changes
260+ // Always fetch server changes, even when compile failed or got cancelled
259261 return docs ;
260262 } )
261263 )
@@ -344,7 +346,7 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
344346 throw new Error ( `No Active Connection` ) ;
345347 }
346348 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?` ,
348350 "Cancel" ,
349351 "Confirm"
350352 ) ;
@@ -360,21 +362,40 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
360362 }
361363 vscode . window . withProgress (
362364 {
363- cancellable : false ,
365+ cancellable : true ,
364366 location : vscode . ProgressLocation . Notification ,
365- title : `Compiling Namespace: ${ api . ns } ` ,
367+ title : `Compiling namespace ${ api . ns } ` ,
366368 } ,
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+ } )
378399 ) ;
379400}
380401
@@ -442,9 +463,43 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
442463 docs . push ( node . fullName + ".*.cls" ) ;
443464 break ;
444465 }
466+ } else if ( node instanceof RootNode && node . contextValue === "dataNode:cspApplication" ) {
467+ docs . push ( node . fullName + "/*" ) ;
445468 } else {
446469 docs . push ( node . fullName ) ;
447470 }
448471 }
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+ ) ;
450505}
0 commit comments