@@ -14,6 +14,7 @@ import { DocumentContentProvider } from "../providers/DocumentContentProvider";
1414import {
1515 base64EncodeContent ,
1616 classNameRegex ,
17+ compileErrorMsg ,
1718 cspAppsForUri ,
1819 CurrentBinaryFile ,
1920 currentFile ,
@@ -291,12 +292,7 @@ export async function compile(docs: CurrentFile[], flags?: string): Promise<any>
291292 return docs ;
292293 } )
293294 . 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 ) ;
300296 // Always fetch server changes, even when compile failed or got cancelled
301297 return docs ;
302298 } )
@@ -483,9 +479,9 @@ export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<
483479}
484480
485481export 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 ) ;
489485 api . setNamespace ( namespace ) ;
490486 const docs = [ ] ;
491487 for ( const node of nodes ) {
@@ -512,23 +508,16 @@ export async function compileExplorerItems(nodes: NodeBase[]): Promise<any> {
512508 } ,
513509 ( progress , token : vscode . CancellationToken ) =>
514510 api
515- . asyncCompile ( docs , token , flags )
511+ . asyncCompile ( docs , token , conf . get < string > ( "compileFlags" ) )
516512 . then ( ( data ) => {
517513 const info = nodes . length > 1 ? "" : `${ nodes [ 0 ] . fullName } : ` ;
518514 if ( data . status && data . status . errors && data . status . errors . length ) {
519515 throw new Error ( `${ info } Compile error` ) ;
520- } else if ( ! config ( "suppressCompileMessages" ) ) {
516+ } else if ( ! conf . get ( "suppressCompileMessages" ) ) {
521517 vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
522518 }
523519 } )
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 ) )
532521 ) ;
533522}
534523
@@ -585,6 +574,8 @@ async function importFileFromContent(
585574
586575/** Prompt the user to compile documents after importing them */
587576async 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 ) ;
588579 // Prompt the user for compilation
589580 if ( imported . length ) {
590581 return vscode . window
@@ -606,23 +597,16 @@ async function promptForCompile(imported: string[], api: AtelierAPI, refresh: bo
606597 } ,
607598 ( progress , token : vscode . CancellationToken ) =>
608599 api
609- . asyncCompile ( imported , token , config ( "compileFlags" ) )
600+ . asyncCompile ( imported , token , conf . get < string > ( "compileFlags" ) )
610601 . then ( ( data ) => {
611602 const info = imported . length > 1 ? "" : `${ imported [ 0 ] } : ` ;
612603 if ( data . status && data . status . errors && data . status . errors . length ) {
613604 throw new Error ( `${ info } Compile error` ) ;
614- } else if ( ! config ( "suppressCompileMessages" ) ) {
605+ } else if ( ! conf . get ( "suppressCompileMessages" ) ) {
615606 vscode . window . showInformationMessage ( `${ info } Compilation succeeded.` , "Dismiss" ) ;
616607 }
617608 } )
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 ) )
626610 . finally ( ( ) => {
627611 if ( refresh ) {
628612 // Refresh the files explorer to show the new files
0 commit comments