Skip to content

Commit 565069c

Browse files
authored
Allow objectscript.multilineMethodArgs to be set per workspace folder (#1534)
1 parent 3ebf56c commit 565069c

File tree

6 files changed

+23
-17
lines changed

6 files changed

+23
-17
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,7 @@
14881488
"objectscript.multilineMethodArgs": {
14891489
"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.",
14901490
"type": "boolean",
1491+
"scope": "resource",
14911492
"default": false
14921493
},
14931494
"objectscript.openClassContracted": {

src/api/index.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -601,20 +601,25 @@ export class AtelierAPI {
601601
}
602602

603603
// api v1+
604-
public getDoc(name: string, format?: string, mtime?: number): Promise<Atelier.Response<Atelier.Document>> {
605-
let params = {};
606-
if (!format && config("multilineMethodArgs", this.configName) && this.config.apiVersion >= 4) {
607-
format = "udl-multiline";
608-
}
609-
if (format) {
610-
params = {
611-
format,
612-
};
613-
}
604+
public getDoc(name: string, scope: vscode.Uri | string, mtime?: number): Promise<Atelier.Response<Atelier.Document>> {
605+
let params, headers;
614606
name = this.transformNameIfCsp(name);
615-
const headers = {};
607+
if (
608+
this.config.apiVersion >= 4 &&
609+
vscode.workspace
610+
.getConfiguration(
611+
"objectscript",
612+
typeof scope == "string"
613+
? // If scope is a string, then it's a workspace folder name
614+
vscode.workspace.workspaceFolders?.find((f) => f.name.toLowerCase() == scope.toLowerCase())
615+
: scope
616+
)
617+
.get("multilineMethodArgs")
618+
) {
619+
params = { format: "udl-multiline" };
620+
}
616621
if (mtime && mtime > 0) {
617-
headers["IF-NONE-MATCH"] = new Date(mtime).toISOString().replace(/T|Z/g, " ").trim();
622+
headers = { "IF-NONE-MATCH": new Date(mtime).toISOString().replace(/T|Z/g, " ").trim() };
618623
}
619624
return this.request(1, "GET", `${this.ns}/doc/${name}`, null, params, headers);
620625
}

src/commands/compile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export async function checkChangedOnServer(file: CurrentTextFile | CurrentBinary
6464
const mtime =
6565
workspaceState.get(`${file.uniqueId}:mtime`, null) ||
6666
(await api
67-
.getDoc(file.name)
67+
.getDoc(file.name, file.uri)
6868
.then((data) => data.result)
6969
.then(async ({ ts, content }) => {
7070
const serverTime = Number(new Date(ts + "Z"));
@@ -225,7 +225,7 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
225225
const mtime = Number(new Date(doc.ts + "Z"));
226226
workspaceState.update(`${file.uniqueId}:mtime`, mtime > 0 ? mtime : undefined);
227227
if (notIsfs(file.uri)) {
228-
const content = await api.getDoc(file.name).then((data) => data.result.content);
228+
const content = await api.getDoc(file.name, file.uri).then((data) => data.result.content);
229229
exportedUris.add(file.uri.toString()); // Set optimistically
230230
await vscode.workspace.fs
231231
.writeFile(file.uri, Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n")))

src/commands/export.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async function exportFile(wsFolderUri: vscode.Uri, namespace: string, name: stri
9999
outputChannel.appendLine(`Export '${name}' to '${fileUri.toString(true)}' - ${status}`);
100100

101101
try {
102-
const data = await api.getDoc(name);
102+
const data = await api.getDoc(name, wsFolderUri);
103103
if (!data || !data.result) {
104104
throw new Error("Received malformed JSON object from server fetching document");
105105
}

src/providers/DocumentContentProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
249249
const { csp, ns } = isfsConfig(uri);
250250
const fileName = csp ? uri.path.slice(1) : uri.path.split("/").slice(1).join(".");
251251
if (ns) api.setNamespace(ns);
252-
const data = await api.getDoc(fileName);
252+
const data = await api.getDoc(fileName, api.configName);
253253
if (Buffer.isBuffer(data.result.content)) {
254254
return "\nThis is a binary file.\n\nTo access its contents, export it to the local file system.";
255255
} else {

src/providers/FileSystemProvider/FileSystemProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
939939
const fileName = isfsDocumentName(uri, csp);
940940
const api = new AtelierAPI(uri);
941941
return api
942-
.getDoc(fileName, undefined, cachedFile?.mtime)
942+
.getDoc(fileName, uri, cachedFile?.mtime)
943943
.then((data) => data.result)
944944
.then(
945945
({ ts, content }) =>

0 commit comments

Comments
 (0)