From 66a5fa85ef78632ce6fa9e06e5740a95d9ec6d96 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Wed, 3 Sep 2025 17:10:57 -0400 Subject: [PATCH 1/2] Update web application and abstract document caches when connection changes --- src/extension.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 8e2d279a..76832605 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -769,22 +769,18 @@ async function updateWebAndAbstractDocsCaches(wsFolders: readonly vscode.Workspa return Promise.allSettled( connections.map(async (connection) => { if (!cspApps.has(connection.key)) { - cspApps.set( - connection.key, - await connection.api - .getCSPApps() - .then((data) => data.result.content ?? []) - .catch(() => []) - ); + const apps = await connection.api + .getCSPApps() + .then((data) => data?.result?.content) + .catch(() => undefined); + if (apps) cspApps.set(connection.key, apps); } if (!otherDocExts.has(connection.key)) { - otherDocExts.set( - connection.key, - await connection.api - .actionQuery("SELECT Extention FROM %Library.RoutineMgr_DocumentTypes()", []) - .then((data) => data.result?.content?.map((e) => e.Extention) ?? []) - .catch(() => []) - ); + const exts = await connection.api + .actionQuery("SELECT Extention FROM %Library.RoutineMgr_DocumentTypes()", []) + .then((data) => data.result?.content?.map((e) => e.Extention)) + .catch(() => undefined); + if (exts) otherDocExts.set(connection.key, exts); } }) ); @@ -1598,6 +1594,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { // This unavoidably switches to the File Explorer view, so only do it if isfs folders were found vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer"); } + updateWebAndAbstractDocsCaches(vscode.workspace.workspaceFolders); } if (affectsConfiguration("objectscript.commentToken")) { // Update the language configuration for "objectscript" and "objectscript-macros" From 3a46c0ef9b7b59d821ab565c9f5bfdc84a146adb Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 4 Sep 2025 07:08:59 -0400 Subject: [PATCH 2/2] Always use connection string as key to avoid using ouytdated values if config changes --- src/explorer/nodes.ts | 7 ++----- src/extension.ts | 3 ++- src/utils/index.ts | 13 ++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/explorer/nodes.ts b/src/explorer/nodes.ts index 347e784d..297c4000 100644 --- a/src/explorer/nodes.ts +++ b/src/explorer/nodes.ts @@ -183,11 +183,8 @@ export class RootNode extends NodeBase { api.setNamespace(this.namespace); if (category == "CSP" && path == "") { // Use the results from the getCSPApps() API - const cspAppsKey = ( - api.config.serverName && api.config.serverName != "" - ? `${api.config.serverName}:${api.config.ns}` - : `${api.config.host}:${api.config.port}${api.config.pathPrefix}:${api.config.ns}` - ).toLowerCase(); + const cspAppsKey = + `${api.config.host}:${api.config.port}${api.config.pathPrefix}:[${api.config.ns}]`.toLowerCase(); let nsCspApps: string[] | undefined = cspApps.get(cspAppsKey); if (nsCspApps == undefined) { nsCspApps = await api.getCSPApps().then((data) => data.result.content || []); diff --git a/src/extension.ts b/src/extension.ts index 76832605..b9158115 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -761,7 +761,8 @@ async function updateWebAndAbstractDocsCaches(wsFolders: readonly vscode.Workspa for (const wsFolder of wsFolders) { const api = new AtelierAPI(wsFolder.uri); if (!api.active) continue; - const key = `${api.serverId}:${api.config.ns}`.toLowerCase(); + const { host, port, pathPrefix, ns } = api.config; + const key = `${host}:${port}${pathPrefix}[${ns}]`.toLowerCase(); if (keys.has(key)) continue; keys.add(key); connections.push({ key, api }); diff --git a/src/utils/index.ts b/src/utils/index.ts index 16acb9a4..0634a7bf 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -23,14 +23,14 @@ export const outputChannel = vscode.window.createOutputChannel("ObjectScript", o /** * A map of all CSP web apps in a server-namespace. - * The key is either `serverName:ns`, or `host:port/pathPrefix:ns`, lowercase. + * The key is `host:port/pathPrefix[ns]`, lowercase. * The value is an array of CSP apps as returned by GET %25SYS/cspapps. */ export const cspApps: Map = new Map(); /** * A map of all Studio Abstract Document extensions in a server-namespace. - * The key is either `serverName:ns`, or `host:port/pathPrefix:ns`, lowercase. + * The key is `host:port/pathPrefix[ns]`, lowercase. * The value is lowercase array of file extensions, without the dot. */ export const otherDocExts: Map = new Map(); @@ -146,7 +146,8 @@ export function cspAppsForUri(uri: vscode.Uri): string[] { /** Get a list of all CSP web apps in the server-namespace that `api` is connected to. */ export function cspAppsForApi(api: AtelierAPI): string[] { - return cspApps.get(`${api.serverId}:${api.config.ns}`.toLowerCase()) ?? []; + const { host, port, pathPrefix, ns } = api.config; + return cspApps.get(`${host}:${port}${pathPrefix}[${ns}]`.toLowerCase()) ?? []; } /** @@ -154,7 +155,8 @@ export function cspAppsForApi(api: AtelierAPI): string[] { */ function otherDocExtsForUri(uri: vscode.Uri): string[] { const api = new AtelierAPI(uri); - return otherDocExts.get(`${api.serverId}:${api.config.ns}`.toLowerCase()) ?? []; + const { host, port, pathPrefix, ns } = api.config; + return otherDocExts.get(`${host}:${port}${pathPrefix}[${ns}]`.toLowerCase()) ?? []; } /** Determine the server name of a non-`isfs` non-ObjectScript file (any file that's not CLS,MAC,INT,INC). */ @@ -642,7 +644,8 @@ export async function addWsServerRootFolderData(wsFolders: readonly vscode.Works if (value.redirectDotvscode) { // We must redirect .vscode Uris for this folder, so see // if the web app to do so is configured on the server - const key = `${api.serverId}:%SYS`.toLowerCase(); + const { host, port, pathPrefix, ns } = api.config; + const key = `${host}:${port}${pathPrefix}[${ns}]`.toLowerCase(); let webApps = cspApps.get(key); if (!webApps) { webApps = await api