@@ -14,6 +14,7 @@ import { DocumentContentProvider } from "../providers/DocumentContentProvider";
14
14
import {
15
15
base64EncodeContent ,
16
16
classNameRegex ,
17
+ compileErrorMsg ,
17
18
cspAppsForUri ,
18
19
CurrentBinaryFile ,
19
20
currentFile ,
@@ -291,12 +292,7 @@ export async function compile(docs: CurrentFile[], flags?: string): Promise<any>
291
292
return docs ;
292
293
} )
293
294
. catch ( ( ) => {
294
- if ( ! conf . get ( "suppressCompileErrorMessages" ) ) {
295
- vscode . window . showErrorMessage (
296
- "Compilation failed. Check the 'ObjectScript' Output channel for details." ,
297
- "Dismiss"
298
- ) ;
299
- }
295
+ compileErrorMsg ( conf ) ;
300
296
// Always fetch server changes, even when compile failed or got cancelled
301
297
return docs ;
302
298
} )
@@ -483,9 +479,9 @@ export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<
483
479
}
484
480
485
481
export async function compileExplorerItems ( nodes : NodeBase [ ] ) : Promise < any > {
486
- const { workspaceFolder , namespace } = nodes [ 0 ] ;
487
- const flags = config ( ) . compileFlags ;
488
- const api = new AtelierAPI ( workspaceFolder ) ;
482
+ const { workspaceFolderUri , namespace } = nodes [ 0 ] ;
483
+ const conf = vscode . workspace . getConfiguration ( "objectscript" , workspaceFolderUri ) ;
484
+ const api = new AtelierAPI ( workspaceFolderUri ) ;
489
485
api . setNamespace ( namespace ) ;
490
486
const docs = [ ] ;
491
487
for ( const node of nodes ) {
@@ -512,23 +508,16 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
512
508
} ,
513
509
( progress , token : vscode . CancellationToken ) =>
514
510
api
515
- . asyncCompile ( docs , token , flags )
511
+ . asyncCompile ( docs , token , conf . get < string > ( "compileFlags" ) )
516
512
. then ( ( data ) => {
517
513
const info = nodes . length > 1 ? "" : `${ nodes [ 0 ] . fullName } : ` ;
518
514
if ( data . status && data . status . errors && data . status . errors . length ) {
519
515
throw new Error ( `${ info } Compile error` ) ;
520
- } else if ( ! config ( "suppressCompileMessages" ) ) {
516
+ } else if ( ! conf . get ( "suppressCompileMessages" ) ) {
521
517
vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
522
518
}
523
519
} )
524
- . catch ( ( ) => {
525
- if ( ! config ( "suppressCompileErrorMessages" ) ) {
526
- vscode . window . showErrorMessage (
527
- "Compilation failed. Check the 'ObjectScript' Output channel for details." ,
528
- "Dismiss"
529
- ) ;
530
- }
531
- } )
520
+ . catch ( ( ) => compileErrorMsg ( conf ) )
532
521
) ;
533
522
}
534
523
@@ -585,6 +574,8 @@ async function importFileFromContent(
585
574
586
575
/** Prompt the user to compile documents after importing them */
587
576
async function promptForCompile ( imported : string [ ] , api : AtelierAPI , refresh : boolean ) : Promise < void > {
577
+ // This cast is safe because the only two callers intialize api with a workspace folder URI
578
+ const conf = vscode . workspace . getConfiguration ( "objectscript" , < vscode . Uri > api . wsOrFile ) ;
588
579
// Prompt the user for compilation
589
580
if ( imported . length ) {
590
581
return vscode . window
@@ -606,23 +597,16 @@ async function promptForCompile(imported: string[], api: AtelierAPI, refresh: bo
606
597
} ,
607
598
( progress , token : vscode . CancellationToken ) =>
608
599
api
609
- . asyncCompile ( imported , token , config ( "compileFlags" ) )
600
+ . asyncCompile ( imported , token , conf . get < string > ( "compileFlags" ) )
610
601
. then ( ( data ) => {
611
602
const info = imported . length > 1 ? "" : `${ imported [ 0 ] } : ` ;
612
603
if ( data . status && data . status . errors && data . status . errors . length ) {
613
604
throw new Error ( `${ info } Compile error` ) ;
614
- } else if ( ! config ( "suppressCompileMessages" ) ) {
605
+ } else if ( ! conf . get ( "suppressCompileMessages" ) ) {
615
606
vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
616
607
}
617
608
} )
618
- . catch ( ( ) => {
619
- if ( ! config ( "suppressCompileErrorMessages" ) ) {
620
- vscode . window . showErrorMessage (
621
- "Compilation failed. Check the 'ObjectScript' Output channel for details." ,
622
- "Dismiss"
623
- ) ;
624
- }
625
- } )
609
+ . catch ( ( ) => compileErrorMsg ( conf ) )
626
610
. finally ( ( ) => {
627
611
if ( refresh ) {
628
612
// Refresh the files explorer to show the new files
0 commit comments