@@ -446,21 +446,6 @@ export async function checkConnection(
446446 serverVersion : info . result . content . version ,
447447 healthshare : hasHS ? "yes" : "no" ,
448448 } ) ;
449-
450- // Update CSP web app cache if required
451- const key = `${ api . serverId } :${ api . config . ns } ` . toLowerCase ( ) ;
452- if ( ! cspApps . has ( key ) ) {
453- cspApps . set ( key , await api . getCSPApps ( ) . then ( ( data ) => data . result . content || [ ] ) ) ;
454- }
455- if ( ! otherDocExts . has ( key ) ) {
456- otherDocExts . set (
457- key ,
458- await api
459- . actionQuery ( "SELECT Extention FROM %Library.RoutineMgr_DocumentTypes()" , [ ] )
460- . then ( ( data ) => data . result ?. content ?. map ( ( e ) => e . Extention ) ?? [ ] )
461- . catch ( ( ) => [ ] )
462- ) ;
463- }
464449 if ( ! api . externalServer ) {
465450 await setConnectionState ( configName , true ) ;
466451 }
@@ -756,6 +741,44 @@ function setExplorerContextKeys(): void {
756741 ) ;
757742}
758743
744+ /** Cache the lists of web apps and abstract document types for all server-namespaces in `wsFolders` */
745+ async function updateWebAndAbstractDocsCaches ( wsFolders : readonly vscode . WorkspaceFolder [ ] ) : Promise < any > {
746+ if ( ! wsFolders ?. length ) return ;
747+ const keys : Set < string > = new Set ( ) ;
748+ const connections : { key : string ; api : AtelierAPI } [ ] = [ ] ;
749+ // Filter out any duplicate connections
750+ for ( const wsFolder of wsFolders ) {
751+ const api = new AtelierAPI ( wsFolder . uri ) ;
752+ if ( ! api . active ) continue ;
753+ const key = `${ api . serverId } :${ api . config . ns } ` . toLowerCase ( ) ;
754+ if ( keys . has ( key ) ) continue ;
755+ keys . add ( key ) ;
756+ connections . push ( { key, api } ) ;
757+ }
758+ return Promise . allSettled (
759+ connections . map ( async ( connection ) => {
760+ if ( ! cspApps . has ( connection . key ) ) {
761+ cspApps . set (
762+ connection . key ,
763+ await connection . api
764+ . getCSPApps ( )
765+ . then ( ( data ) => data . result . content ?? [ ] )
766+ . catch ( ( ) => [ ] )
767+ ) ;
768+ }
769+ if ( ! otherDocExts . has ( connection . key ) ) {
770+ otherDocExts . set (
771+ connection . key ,
772+ await connection . api
773+ . actionQuery ( "SELECT Extention FROM %Library.RoutineMgr_DocumentTypes()" , [ ] )
774+ . then ( ( data ) => data . result ?. content ?. map ( ( e ) => e . Extention ) ?? [ ] )
775+ . catch ( ( ) => [ ] )
776+ ) ;
777+ }
778+ } )
779+ ) ;
780+ }
781+
759782/** The URIs of all classes that have been opened. Used when `objectscript.openClassContracted` is true */
760783let openedClasses : string [ ] ;
761784
@@ -847,9 +870,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
847870 continue ;
848871 }
849872 }
850- await Promise . allSettled (
851- vscode . workspace . workspaceFolders ?. map ( ( wsFolder ) => addWsServerRootFolderData ( wsFolder . uri ) ) || [ ]
852- ) ;
873+
874+ await updateWebAndAbstractDocsCaches ( vscode . workspace . workspaceFolders ) ;
875+ await addWsServerRootFolderData ( vscode . workspace . workspaceFolders ) ;
853876
854877 xmlContentProvider = new XmlContentProvider ( ) ;
855878
@@ -1373,22 +1396,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
13731396 } ,
13741397 supportsMultipleEditorsPerDocument : false ,
13751398 } ) ,
1376- vscode . workspace . onDidChangeWorkspaceFolders ( async ( { added } ) => {
1377- // Make sure we have a resolved connection spec for the targets of all added folders
1378- const toCheck = new Map < string , vscode . Uri > ( ) ;
1379- added . map ( ( workspaceFolder ) => {
1380- const uri = workspaceFolder . uri ;
1381- const { configName } = connectionTarget ( uri ) ;
1382- toCheck . set ( configName , uri ) ;
1383- } ) ;
1384- for await ( const oneToCheck of toCheck ) {
1385- const configName = oneToCheck [ 0 ] ;
1386- const uri = oneToCheck [ 1 ] ;
1387- const serverName = notIsfs ( uri ) ? config ( "conn" , configName ) . server : configName ;
1388- await resolveConnectionSpec ( serverName ) ;
1389- }
1390- await Promise . allSettled ( added . map ( ( wsFolder ) => addWsServerRootFolderData ( wsFolder . uri ) ) ) ;
1391- } ) ,
13921399 vscode . workspace . onDidChangeConfiguration ( async ( { affectsConfiguration } ) => {
13931400 if ( affectsConfiguration ( "objectscript.conn" ) || affectsConfiguration ( "intersystems.servers" ) ) {
13941401 if ( affectsConfiguration ( "intersystems.servers" ) ) {
@@ -1545,7 +1552,23 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
15451552 "vscode-objectscript.webSocketTerminal" ,
15461553 new WebSocketTerminalProfileProvider ( )
15471554 ) ,
1548- vscode . workspace . onDidChangeWorkspaceFolders ( ( e ) => {
1555+ vscode . workspace . onDidChangeWorkspaceFolders ( async ( e ) => {
1556+ // Make sure we have a resolved connection spec for the targets of all added folders
1557+ const toCheck = new Map < string , vscode . Uri > ( ) ;
1558+ e . added . map ( ( workspaceFolder ) => {
1559+ const uri = workspaceFolder . uri ;
1560+ const { configName } = connectionTarget ( uri ) ;
1561+ toCheck . set ( configName , uri ) ;
1562+ } ) ;
1563+ for await ( const oneToCheck of toCheck ) {
1564+ const configName = oneToCheck [ 0 ] ;
1565+ const uri = oneToCheck [ 1 ] ;
1566+ const serverName = notIsfs ( uri ) ? config ( "conn" , configName ) . server : configName ;
1567+ await resolveConnectionSpec ( serverName ) ;
1568+ }
1569+ // await this so the next step can take advantage of the caching
1570+ await updateWebAndAbstractDocsCaches ( e . added ) ;
1571+ addWsServerRootFolderData ( e . added ) ;
15491572 // Show the proposed API prompt if required
15501573 proposedApiPrompt ( proposed . length > 0 , e . added ) ;
15511574 // Warn about SystemMode
0 commit comments