Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/explorer/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || []);
Expand Down
28 changes: 13 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,30 +761,27 @@ 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 });
}
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);
}
})
);
Expand Down Expand Up @@ -1598,6 +1595,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
// 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"
Expand Down
13 changes: 8 additions & 5 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string[]> = 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<string, string[]> = new Map();
Expand Down Expand Up @@ -146,15 +146,17 @@ 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()) ?? [];
}

/**
* Get a list of Studio Abstract Document extensions in the server-namespace that `uri` is connected to.
*/
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). */
Expand Down Expand Up @@ -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
Expand Down