Skip to content

Commit 299e049

Browse files
committed
Merge remote-tracking branch 'upstream/master' into reduce-traffic
2 parents f6370dc + e0ce455 commit 299e049

File tree

6 files changed

+48
-28
lines changed

6 files changed

+48
-28
lines changed

package.json

Lines changed: 1 addition & 0 deletions
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

Lines changed: 17 additions & 12 deletions
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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
} from "../utils";
3535
import { StudioActions } from "./studio";
3636
import { NodeBase, PackageNode, RootNode } from "../explorer/nodes";
37-
import { updateIndexForDocument } from "../utils/documentIndex";
37+
import { getUrisForDocument, updateIndexForDocument } from "../utils/documentIndex";
3838

3939
async function compileFlags(): Promise<string> {
4040
const defaultFlags = config().compileFlags;
@@ -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")))
@@ -249,12 +249,11 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
249249
}
250250

251251
export async function compile(docs: CurrentFile[], flags?: string): Promise<any> {
252-
const conf = vscode.workspace.getConfiguration(
253-
"objectscript",
254-
vscode.workspace.getWorkspaceFolder(docs[0].uri) || docs[0].uri
255-
);
252+
const wsFolder = vscode.workspace.getWorkspaceFolder(docs[0].uri);
253+
const conf = vscode.workspace.getConfiguration("objectscript", wsFolder || docs[0].uri);
256254
flags = flags || conf.get("compileFlags");
257255
const api = new AtelierAPI(docs[0].uri);
256+
const docNames = docs.map((d) => d.name);
258257
return vscode.window
259258
.withProgress(
260259
{
@@ -264,18 +263,31 @@ export async function compile(docs: CurrentFile[], flags?: string): Promise<any>
264263
},
265264
(progress, token: vscode.CancellationToken) =>
266265
api
267-
.asyncCompile(
268-
docs.map((el) => el.name),
269-
token,
270-
flags
271-
)
266+
.asyncCompile(docNames, token, flags)
272267
.then((data) => {
273268
const info = docs.length > 1 ? "" : `${docs[0].name}: `;
274269
if (data.status && data.status.errors && data.status.errors.length) {
275270
throw new Error(`${info}Compile error`);
276271
} else if (!conf.get("suppressCompileMessages")) {
277272
vscode.window.showInformationMessage(`${info}Compilation succeeded.`, "Dismiss");
278273
}
274+
if (wsFolder) {
275+
// Make sure that we update the content for any
276+
// other documents affected by this compilation
277+
data.result.content.forEach((f) => {
278+
if (docNames.includes(f.name)) return;
279+
getUrisForDocument(f.name, wsFolder).forEach((u) => {
280+
docs.push({
281+
name: f.name,
282+
uri: u,
283+
uniqueId: `${wsFolder.name}:${f.name}`,
284+
// These two keys aren't used by loadChanges()
285+
workspaceFolder: wsFolder.name,
286+
fileName: u.fsPath,
287+
});
288+
});
289+
});
290+
}
279291
return docs;
280292
})
281293
.catch(() => {

src/commands/export.ts

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
934934
const fileName = isfsDocumentName(uri, csp);
935935
const api = new AtelierAPI(uri);
936936
return api
937-
.getDoc(fileName, undefined, cachedFile?.mtime)
937+
.getDoc(fileName, uri, cachedFile?.mtime)
938938
.then((data) => data.result)
939939
.then(
940940
({ ts, content }) =>
@@ -955,7 +955,9 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
955955
)
956956
.catch((error) => {
957957
if (error?.statusCode == 304 && cachedFile) return cachedFile;
958-
throw vscode.FileSystemError.FileNotFound(stringifyError(error) || uri);
958+
const errArg = stringifyError(error) || uri;
959+
if (error?.statusCode == 404) throw vscode.FileSystemError.FileNotFound(errArg);
960+
throw vscode.FileSystemError.Unavailable(errArg);
959961
});
960962
}
961963

0 commit comments

Comments
 (0)