From 0f7c9714caad96253c7dacea31c1cb9fc17c9d1f Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Mon, 14 Apr 2025 17:24:01 -0400 Subject: [PATCH] Allow `objectscript.multilineMethodArgs` to be set per workspace folder --- package.json | 1 + src/api/index.ts | 29 +++++++++++-------- src/commands/compile.ts | 4 +-- src/commands/export.ts | 2 +- src/providers/DocumentContentProvider.ts | 2 +- .../FileSystemProvider/FileSystemProvider.ts | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 5dc3c49f..4d8b5294 100644 --- a/package.json +++ b/package.json @@ -1488,6 +1488,7 @@ "objectscript.multilineMethodArgs": { "markdownDescription": "List method arguments on multiple lines, if the server supports it. **NOTE:** Only supported on IRIS 2019.1.2, 2020.1.1+, 2021.1.0+ and subsequent versions! On all other versions, this setting will have no effect.", "type": "boolean", + "scope": "resource", "default": false }, "objectscript.openClassContracted": { diff --git a/src/api/index.ts b/src/api/index.ts index 16543c87..20752c6a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -601,20 +601,25 @@ export class AtelierAPI { } // api v1+ - public getDoc(name: string, format?: string, mtime?: number): Promise> { - let params = {}; - if (!format && config("multilineMethodArgs", this.configName) && this.config.apiVersion >= 4) { - format = "udl-multiline"; - } - if (format) { - params = { - format, - }; - } + public getDoc(name: string, scope: vscode.Uri | string, mtime?: number): Promise> { + let params, headers; name = this.transformNameIfCsp(name); - const headers = {}; + if ( + this.config.apiVersion >= 4 && + vscode.workspace + .getConfiguration( + "objectscript", + typeof scope == "string" + ? // If scope is a string, then it's a workspace folder name + vscode.workspace.workspaceFolders?.find((f) => f.name.toLowerCase() == scope.toLowerCase()) + : scope + ) + .get("multilineMethodArgs") + ) { + params = { format: "udl-multiline" }; + } if (mtime && mtime > 0) { - headers["IF-NONE-MATCH"] = new Date(mtime).toISOString().replace(/T|Z/g, " ").trim(); + headers = { "IF-NONE-MATCH": new Date(mtime).toISOString().replace(/T|Z/g, " ").trim() }; } return this.request(1, "GET", `${this.ns}/doc/${name}`, null, params, headers); } diff --git a/src/commands/compile.ts b/src/commands/compile.ts index cd4dae61..2c1cdc71 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -64,7 +64,7 @@ export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinary const mtime = workspaceState.get(`${file.uniqueId}:mtime`, null) || (await api - .getDoc(file.name) + .getDoc(file.name, file.uri) .then((data) => data.result) .then(async ({ ts, content }) => { const serverTime = Number(new Date(ts + "Z")); @@ -225,7 +225,7 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[] const mtime = Number(new Date(doc.ts + "Z")); workspaceState.update(`${file.uniqueId}:mtime`, mtime > 0 ? mtime : undefined); if (notIsfs(file.uri)) { - const content = await api.getDoc(file.name).then((data) => data.result.content); + const content = await api.getDoc(file.name, file.uri).then((data) => data.result.content); exportedUris.add(file.uri.toString()); // Set optimistically await vscode.workspace.fs .writeFile(file.uri, Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n"))) diff --git a/src/commands/export.ts b/src/commands/export.ts index 4534109d..5ecc4544 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -99,7 +99,7 @@ async function exportFile(wsFolderUri: vscode.Uri, namespace: string, name: stri outputChannel.appendLine(`Export '${name}' to '${fileUri.toString(true)}' - ${status}`); try { - const data = await api.getDoc(name); + const data = await api.getDoc(name, wsFolderUri); if (!data || !data.result) { throw new Error("Received malformed JSON object from server fetching document"); } diff --git a/src/providers/DocumentContentProvider.ts b/src/providers/DocumentContentProvider.ts index c88a6216..c9eae4a4 100644 --- a/src/providers/DocumentContentProvider.ts +++ b/src/providers/DocumentContentProvider.ts @@ -249,7 +249,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid const { csp, ns } = isfsConfig(uri); const fileName = csp ? uri.path.slice(1) : uri.path.split("/").slice(1).join("."); if (ns) api.setNamespace(ns); - const data = await api.getDoc(fileName); + const data = await api.getDoc(fileName, api.configName); if (Buffer.isBuffer(data.result.content)) { return "\nThis is a binary file.\n\nTo access its contents, export it to the local file system."; } else { diff --git a/src/providers/FileSystemProvider/FileSystemProvider.ts b/src/providers/FileSystemProvider/FileSystemProvider.ts index f4ef26c6..acef2e1e 100644 --- a/src/providers/FileSystemProvider/FileSystemProvider.ts +++ b/src/providers/FileSystemProvider/FileSystemProvider.ts @@ -939,7 +939,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider { const fileName = isfsDocumentName(uri, csp); const api = new AtelierAPI(uri); return api - .getDoc(fileName, undefined, cachedFile?.mtime) + .getDoc(fileName, uri, cachedFile?.mtime) .then((data) => data.result) .then( ({ ts, content }) =>