Skip to content

Commit 89a0c14

Browse files
authored
Merge branch 'intersystems-community:master' into colorize-output
2 parents f4d2c09 + 962cc59 commit 89a0c14

File tree

9 files changed

+340
-189
lines changed

9 files changed

+340
-189
lines changed

package-lock.json

Lines changed: 8 additions & 91 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@
11941194
"glob": "^7.1.6",
11951195
"iconv-lite": "^0.6.0",
11961196
"mkdirp": "^1.0.4",
1197-
"node-fetch": "3.1.1",
1197+
"node-fetch-cjs": "3.1.1",
11981198
"vscode-cache": "^0.3.0",
11991199
"vscode-debugadapter": "^1.41.0",
12001200
"vscode-debugprotocol": "^1.41.0",

src/api/atelier.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface ServerInfo {
4545

4646
export interface SearchMatch {
4747
text: string;
48-
line?: number;
48+
line?: string | number;
4949
member?: string;
5050
attr?: string;
5151
attrline?: number;

src/api/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// import fetch from "node-fetch";
2-
// mod.cjs
3-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4-
// @ts-ignore
5-
const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args));
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const { default: fetch } = require("node-fetch-cjs");
3+
64
import * as httpModule from "http";
75
import * as httpsModule from "https";
86
import * as url from "url";

src/commands/compile.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ import {
1313
workspaceState,
1414
} from "../extension";
1515
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
16-
import { currentFile, CurrentFile, currentWorkspaceFolder, outputChannel, uriOfWorkspaceFolder } from "../utils";
16+
import {
17+
currentFile,
18+
CurrentFile,
19+
currentFileFromContent,
20+
currentWorkspaceFolder,
21+
outputChannel,
22+
throttleRequests,
23+
uriOfWorkspaceFolder,
24+
} from "../utils";
1725
import { PackageNode } from "../explorer/models/packageNode";
1826
import { NodeBase } from "../explorer/models/nodeBase";
1927

@@ -372,16 +380,18 @@ export async function namespaceCompile(askFlags = false): Promise<any> {
372380

373381
function importFiles(files, noCompile = false) {
374382
return Promise.all<CurrentFile>(
375-
files.map((file) =>
376-
vscode.workspace
377-
.openTextDocument(file)
378-
.then(currentFile)
379-
.then((curFile) =>
380-
importFile(curFile).then((data) => {
381-
outputChannel.appendLine("Imported file: " + curFile.fileName);
382-
return curFile;
383-
})
384-
)
383+
files.map(
384+
throttleRequests((file) =>
385+
fs.promises
386+
.readFile(file, { encoding: "utf8" })
387+
.then((content) => currentFileFromContent(file, content))
388+
.then((curFile) =>
389+
importFile(curFile).then((data) => {
390+
outputChannel.appendLine("Imported file: " + curFile.fileName);
391+
return curFile;
392+
})
393+
)
394+
)
385395
)
386396
).then(noCompile ? Promise.resolve : compile);
387397
}

src/providers/FileSystemProvider/FileSearchProvider.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as vscode from "vscode";
22
import * as url from "url";
3-
import { AtelierAPI } from "../../api";
43
import { StudioOpenDialog } from "../../queries";
54
import { studioOpenDialogFromURI } from "../../utils/FileProviderUtil";
5+
import { notNull } from "../../utils";
6+
import { DocumentContentProvider } from "../DocumentContentProvider";
67

78
export class FileSearchProvider implements vscode.FileSearchProvider {
89
/**
@@ -32,40 +33,26 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
3233
filter = "";
3334
}
3435
let counter = 0;
36+
if (token.isCancellationRequested) {
37+
return;
38+
}
3539
return studioOpenDialogFromURI(options.folder, { flat: true, filter: filter })
3640
.then((data) => {
3741
return data.result.content;
3842
})
3943
.then((data: StudioOpenDialog[]) => {
40-
const api = new AtelierAPI(options.folder);
4144
return data
4245
.map((item: StudioOpenDialog) => {
43-
// item.Type only matters here if it is 5 (CSP)
44-
if (item.Type == "5" && !csp) {
46+
if (token.isCancellationRequested) {
4547
return null;
4648
}
47-
if (item.Type !== "5") {
48-
if (item.Name.startsWith("%") && api.ns !== "%SYS") {
49-
return null;
50-
}
51-
// Convert dotted name to slashed one, treating the likes of ABC.1.int or DEF.T1.int in the same way
52-
// as the Studio dialog does.
53-
const nameParts = item.Name.split(".");
54-
const dotParts = nameParts
55-
.slice(-2)
56-
.join(".")
57-
.match(/^[A-Z]?\d*[.](mac|int|inc)$/)
58-
? 3
59-
: 2;
60-
item.Name = nameParts.slice(0, -dotParts).join("/") + "/" + nameParts.slice(-dotParts).join(".");
61-
}
6249
if (!options.maxResults || ++counter <= options.maxResults) {
63-
return vscode.Uri.parse(`${options.folder.scheme}://${options.folder.authority}/${item.Name}`, true);
50+
return DocumentContentProvider.getUri(item.Name, "", "", true, options.folder);
6451
} else {
6552
return null;
6653
}
6754
})
68-
.filter((el) => el !== null);
55+
.filter(notNull);
6956
});
7057
}
7158
}

0 commit comments

Comments
 (0)