Skip to content

Commit 34297de

Browse files
authored
Remove unneeded dependencies (#1753)
1 parent 17eaba4 commit 34297de

File tree

5 files changed

+44
-87
lines changed

5 files changed

+44
-87
lines changed

package-lock.json

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

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,12 +1764,10 @@
17641764
"@vscode/extension-telemetry": "^1.5.1",
17651765
"@xmldom/xmldom": "^0.9.9",
17661766
"axios": "^1.15.0",
1767-
"core-js": "^3.41.0",
17681767
"iconv-lite": "^0.7.2",
17691768
"istextorbinary": "^7.0.0",
17701769
"minimatch": "^10.2.5",
17711770
"node-cmd": "^5.0.0",
1772-
"vscode-cache": "^0.3.0",
17731771
"ws": "^8.20.0"
17741772
},
17751773
"extensionDependencies": [

src/api/index.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import axios from "axios";
22
import * as httpsModule from "https";
33
import * as vscode from "vscode";
4-
import * as Cache from "vscode-cache";
54
import * as semver from "semver";
65
import {
76
getResolvedConnectionSpec,
@@ -21,9 +20,12 @@ const DEFAULT_SERVER_VERSION = "2016.2.0";
2120
import * as Atelier from "./atelier";
2221
import { isfsConfig } from "../utils/FileProviderUtil";
2322

24-
// Map of the authRequest promises for each username@host:port target to avoid concurrency issues
23+
// Map of the authRequest promises for each username@host:port/pathPrefix target to avoid concurrency issues
2524
const authRequestMap = new Map<string, Promise<any>>();
2625

26+
/** Map of `username@host:port/pathPrefix` to cookies */
27+
const cookiesMap = new Map<string, string[]>();
28+
2729
interface ConnectionSettings {
2830
serverName: string;
2931
active: boolean;
@@ -170,12 +172,11 @@ export class AtelierAPI {
170172
}
171173

172174
public get cookies(): string[] {
173-
const cookies = this.cache.get("cookies", []);
174-
return cookies;
175+
return cookiesMap.get(this.mapKey()) ?? [];
175176
}
176177

177-
public async clearCookies(): Promise<void> {
178-
await this.cache.put("cookies", []);
178+
public clearCookies(): void {
179+
cookiesMap.delete(this.mapKey());
179180
}
180181

181182
public xdebugUrl(): string {
@@ -191,8 +192,9 @@ export class AtelierAPI {
191192
: "";
192193
}
193194

194-
public async updateCookies(newCookies: string[]): Promise<void> {
195-
const cookies = this.cache.get("cookies", []);
195+
public updateCookies(newCookies: string[]): void {
196+
const mapKey = this.mapKey();
197+
const cookies = cookiesMap.get(mapKey) ?? [];
196198
newCookies.forEach((cookie) => {
197199
const [cookieName] = cookie.split("=");
198200
const index = cookies.findIndex((el) => el.startsWith(cookieName));
@@ -202,7 +204,17 @@ export class AtelierAPI {
202204
cookies.push(cookie);
203205
}
204206
});
205-
await this.cache.put("cookies", cookies);
207+
cookiesMap.set(mapKey, cookies);
208+
}
209+
210+
/** Return the key for getting values from connection-specific Maps for this connection */
211+
private mapKey(): string {
212+
const { host, port, username } = this.config;
213+
let pathPrefix = this._config.pathPrefix || "";
214+
if (pathPrefix.length && !pathPrefix.startsWith("/")) {
215+
pathPrefix = "/" + pathPrefix;
216+
}
217+
return `${username}@${host}:${port}${pathPrefix}`;
206218
}
207219

208220
private setConnection(workspaceFolderName: string, namespace?: string): void {
@@ -284,11 +296,6 @@ export class AtelierAPI {
284296
}
285297
}
286298

287-
private get cache(): Cache {
288-
const { host, port } = this.config;
289-
return new Cache(extensionContext, `API:${host}:${port}`);
290-
}
291-
292299
public get connInfo(): string {
293300
const { port, docker, dockerService } = this.config;
294301
return (docker ? "docker" + (dockerService ? `:${dockerService}:${port}` : "") : this.serverId) + `[${this.ns}]`;
@@ -358,9 +365,9 @@ export class AtelierAPI {
358365
path = encodeURI(`${pathPrefix}/api/atelier/${path || ""}`) + buildParams();
359366

360367
const cookies = this.cookies;
361-
const target = `${username}@${host}:${port}`;
368+
const mapKey = this.mapKey();
362369
let auth: Promise<any>;
363-
let authRequest = authRequestMap.get(target);
370+
let authRequest = authRequestMap.get(mapKey);
364371
if (cookies.length || (method === "HEAD" && !originalPath)) {
365372
auth = Promise.resolve(cookies);
366373

@@ -372,7 +379,7 @@ export class AtelierAPI {
372379
if (!authRequest) {
373380
// Recursion point
374381
authRequest = this.request(0, "HEAD", undefined, undefined, undefined, undefined, options);
375-
authRequestMap.set(target, authRequest);
382+
authRequestMap.set(mapKey, authRequest);
376383
}
377384
auth = authRequest;
378385
}
@@ -438,7 +445,7 @@ export class AtelierAPI {
438445
};
439446
}
440447
if (response.status === 401) {
441-
authRequestMap.delete(target);
448+
authRequestMap.delete(mapKey);
442449
if (this.wsOrFile && !checkingConnection) {
443450
setTimeout(() => {
444451
checkConnection(
@@ -453,7 +460,7 @@ export class AtelierAPI {
453460
await this.updateCookies(response.headers["set-cookie"] || []);
454461
if (method === "HEAD") {
455462
if (!originalPath) {
456-
authRequestMap.delete(target);
463+
authRequestMap.delete(mapKey);
457464
return this.cookies;
458465
} else if (response.status >= 400) {
459466
// The HEAD /doc request errored out
@@ -552,7 +559,7 @@ export class AtelierAPI {
552559
outputChannel.appendLine(`+- END ----------------------------------------------`);
553560
}
554561
// always discard the cached authentication promise
555-
authRequestMap.delete(target);
562+
authRequestMap.delete(mapKey);
556563

557564
// In some cases schedule an automatic retry.
558565
// ENOTFOUND occurs if, say, the VPN to the server's network goes down.

src/utils/classDefinition.ts

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as vscode from "vscode";
2-
import * as Cache from "vscode-cache";
32
import { onlyUnique } from ".";
43
import { AtelierAPI } from "../api";
5-
import { extensionContext } from "../extension";
64
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
75

86
export class ClassDefinition {
@@ -15,7 +13,6 @@ export class ClassDefinition {
1513
}
1614
private _className: string;
1715
private _classFileName: string;
18-
private _cache;
1916
private _workspaceFolder: string;
2017
private _namespace: string;
2118

@@ -27,26 +24,14 @@ export class ClassDefinition {
2724
}
2825
this._className = ClassDefinition.normalizeClassName(className, false);
2926
this._classFileName = ClassDefinition.normalizeClassName(className, true);
30-
this._cache = new Cache(extensionContext, this._classFileName);
3127
}
3228

3329
public async getDocument(): Promise<vscode.TextDocument> {
3430
return vscode.workspace.openTextDocument(this.uri);
3531
}
3632

37-
public store(kind: string, data: any): any {
38-
return this._cache.put(kind, data, 36000).then(() => data);
39-
}
40-
41-
public load(kind: string): any {
42-
return this._cache.get(kind);
43-
}
44-
4533
public async methods(scope: "any" | "class" | "instance" = "any"): Promise<any[]> {
46-
const methods = this.load("methods-" + scope) || [];
47-
if (methods.length) {
48-
return Promise.resolve(methods);
49-
}
34+
const methods = [];
5035
const filterScope = (method) => scope === "any" || method.scope === scope;
5136
const api = new AtelierAPI(this.uri);
5237
const getMethods = (content) => {
@@ -58,16 +43,13 @@ export class ClassDefinition {
5843
if (extend.length) {
5944
return api.actionIndex(extend).then((data) => getMethods(data.result.content));
6045
}
61-
return this.store("methods-" + scope, methods.filter(filterScope).filter(onlyUnique).sort());
46+
return methods.filter(filterScope).filter(onlyUnique).sort();
6247
};
6348
return api.actionIndex([this._classFileName]).then((data) => getMethods(data.result.content));
6449
}
6550

6651
public async properties(): Promise<any[]> {
67-
const properties = this.load("properties") || [];
68-
if (properties.length) {
69-
return Promise.resolve(properties);
70-
}
52+
const properties = [];
7153
const api = new AtelierAPI(this.uri);
7254
const getProperties = (content) => {
7355
const extend = [];
@@ -78,16 +60,13 @@ export class ClassDefinition {
7860
if (extend.length) {
7961
return api.actionIndex(extend).then((data) => getProperties(data.result.content));
8062
}
81-
return this.store("properties", properties.filter(onlyUnique).sort());
63+
return properties.filter(onlyUnique).sort();
8264
};
8365
return api.actionIndex([this._classFileName]).then((data) => getProperties(data.result.content));
8466
}
8567

8668
public async parameters(): Promise<any[]> {
87-
const parameters = this.load("parameters") || [];
88-
if (parameters.length) {
89-
return Promise.resolve(parameters);
90-
}
69+
const parameters = [];
9170
const api = new AtelierAPI(this.uri);
9271
const getParameters = (content) => {
9372
const extend = [];
@@ -98,40 +77,30 @@ export class ClassDefinition {
9877
if (extend.length) {
9978
return api.actionIndex(extend).then((data) => getParameters(data.result.content));
10079
}
101-
return this.store("parameters", parameters.filter(onlyUnique).sort());
80+
return parameters.filter(onlyUnique).sort();
10281
};
10382
return api.actionIndex([this._classFileName]).then((data) => getParameters(data.result.content));
10483
}
10584

10685
public async super(): Promise<string[]> {
107-
const superList = this.load("super");
108-
if (superList) {
109-
return Promise.resolve(superList);
110-
}
11186
const api = new AtelierAPI(this.uri);
11287
const sql = `SELECT PrimarySuper FROM %Dictionary.CompiledClass
11388
WHERE Name %inlist (SELECT $LISTFROMSTRING(Super, ',') FROM %Dictionary.CompiledClass WHERE Name = ?)`;
11489
return api
11590
.actionQuery(sql, [this._className])
116-
.then(
117-
(data) =>
118-
data.result.content
119-
.reduce(
120-
(list: string[], el: { PrimarySuper: string }) =>
121-
list.concat(el.PrimarySuper.split("~").filter((item) => item.length)),
122-
[]
123-
)
124-
.filter((name: string) => name !== this._className)
125-
// .filter(name => !['%Library.Base', '%Library.SystemBase'].includes(name))
91+
.then((data) =>
92+
data.result.content
93+
.reduce(
94+
(list: string[], el: { PrimarySuper: string }) =>
95+
list.concat(el.PrimarySuper.split("~").filter((item) => item.length)),
96+
[]
97+
)
98+
.filter((name: string) => name !== this._className)
12699
)
127-
.then((data) => this.store("super", data));
100+
.then((data) => data);
128101
}
129102

130103
public async includeCode(): Promise<string[]> {
131-
const includeCode = this.load("includeCode");
132-
if (includeCode) {
133-
return Promise.resolve(includeCode);
134-
}
135104
const api = new AtelierAPI(this.uri);
136105
const sql = `SELECT LIST(IncludeCode) List FROM %Dictionary.CompiledClass WHERE Name %INLIST (
137106
SELECT $LISTFROMSTRING(PrimarySuper, '~') FROM %Dictionary.CompiledClass WHERE Name = ?)`;
@@ -144,7 +113,7 @@ export class ClassDefinition {
144113
defaultIncludes
145114
)
146115
)
147-
.then((data) => this.store("includeCode", data));
116+
.then((data) => data);
148117
}
149118

150119
public async getMemberLocation(name: string): Promise<vscode.Location> {

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require("path");
44
const config = {
55
target: "node", // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
66

7-
entry: ["core-js/features/array/flat-map", "./src/extension.ts"], // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
7+
entry: "./src/extension.ts", // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
88
output: {
99
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
1010
path: path.resolve(__dirname, "dist"),

0 commit comments

Comments
 (0)