Skip to content

Commit 5f7402d

Browse files
authored
Server-side improvements (#1488)
1 parent bab8b6d commit 5f7402d

17 files changed

+644
-693
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -581,22 +581,22 @@
581581
},
582582
{
583583
"command": "vscode-objectscript.addItemsToProject",
584-
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
584+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
585585
"group": "objectscript_prj@1"
586586
},
587587
{
588588
"command": "vscode-objectscript.removeFromProject",
589-
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && !explorerResourceIsRoot && !listMultiSelection",
589+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && !(resourcePath =~ /^\\/?$/) && !listMultiSelection",
590590
"group": "objectscript_prj@2"
591591
},
592592
{
593593
"command": "vscode-objectscript.removeItemsFromProject",
594-
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
594+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
595595
"group": "objectscript_prj@2"
596596
},
597597
{
598598
"command": "vscode-objectscript.modifyProjectMetadata",
599-
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && explorerResourceIsRoot && !listMultiSelection",
599+
"when": "vscode-objectscript.connectActive && resourceScheme =~ /^isfs(-readonly)?$/ && resource =~ /project%3D/ && resourcePath =~ /^\\/?$/ && !listMultiSelection",
600600
"group": "objectscript_prj@3"
601601
},
602602
{

src/api/index.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { currentWorkspaceFolder, outputChannel, outputConsole } from "../utils";
1818
const DEFAULT_API_VERSION = 1;
1919
const DEFAULT_SERVER_VERSION = "2016.2.0";
2020
import * as Atelier from "./atelier";
21+
import { isfsConfig } from "../utils/FileProviderUtil";
2122

2223
// Map of the authRequest promises for each username@host:port target to avoid concurrency issues
2324
const authRequestMap = new Map<string, Promise<any>>();
@@ -125,9 +126,9 @@ export class AtelierAPI {
125126
workspaceFolderName = parts[0];
126127
namespace = parts[1];
127128
} else {
128-
const params = new URLSearchParams(wsOrFile.query);
129-
if (params.has("ns") && params.get("ns") != "") {
130-
namespace = params.get("ns");
129+
const { ns } = isfsConfig(wsOrFile);
130+
if (ns) {
131+
namespace = ns;
131132
}
132133
}
133134
} else {
@@ -143,10 +144,6 @@ export class AtelierAPI {
143144
this.setConnection(workspaceFolderName || currentWorkspaceFolder(), namespace);
144145
}
145146

146-
public get enabled(): boolean {
147-
return this._config.active;
148-
}
149-
150147
public setNamespace(namespace: string): void {
151148
this.namespace = namespace;
152149
}

src/commands/addServerNamespaceToWorkspace.ts

+25-36
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "../extension";
1212
import { cspAppsForUri, handleError, notIsfs } from "../utils";
1313
import { pickProject } from "./project";
14+
import { isfsConfig, IsfsUriParam } from "../utils/FileProviderUtil";
1415

1516
/**
1617
* @param message The prefix of the message to show when the server manager API can't be found.
@@ -143,9 +144,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
143144
return;
144145
}
145146
// Generate the name
146-
const params = new URLSearchParams(uri.query);
147-
const project = params.get("project");
148-
const csp = params.has("csp");
147+
const { csp, project } = isfsConfig(uri);
149148
const name = `${project ? `${project} - ${serverName}:${namespace}` : !csp ? `${serverName}:${namespace}` : ["", "/"].includes(uri.path) ? `${serverName}:${namespace} web files` : `${serverName} (${uri.path})`}${
150149
scheme == FILESYSTEM_READONLY_SCHEMA && !project ? " (read-only)" : ""
151150
}`;
@@ -188,7 +187,7 @@ export async function getServerManagerApi(): Promise<any> {
188187
/** Prompt the user to fill in the `path` and `query` of `uri`. */
189188
async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefined> {
190189
if (notIsfs(uri)) return;
191-
const params = new URLSearchParams(uri.query);
190+
const { project, csp, system, generated, mapped, filter } = isfsConfig(uri);
192191
const api = new AtelierAPI(uri);
193192

194193
// Prompt the user for the files to show
@@ -211,9 +210,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
211210
detail: "Choose an existing project, or create a new one.",
212211
},
213212
];
214-
quickPick.activeItems = [
215-
params.has("project") ? quickPick.items[2] : params.has("csp") ? quickPick.items[1] : quickPick.items[0],
216-
];
213+
quickPick.activeItems = [project ? quickPick.items[2] : csp ? quickPick.items[1] : quickPick.items[0]];
217214

218215
quickPick.onDidChangeSelection((items) => {
219216
switch (items[0].label) {
@@ -258,7 +255,7 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
258255
// Catch handler reported the error already
259256
return;
260257
} else if (cspApps.length == 0) {
261-
vscode.window.showWarningMessage(`No web applications are configured to use namespace ${api.ns}.`, "Dismiss");
258+
vscode.window.showWarningMessage(`No web applications are configured in namespace ${api.ns}.`, "Dismiss");
262259
return;
263260
}
264261
}
@@ -292,43 +289,43 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
292289
if (!newPath) {
293290
return;
294291
}
295-
newParams = "csp";
292+
newParams = IsfsUriParam.CSP;
296293
} else if (filterType == "project") {
297294
// Prompt for project
298295
const project = await pickProject(new AtelierAPI(uri));
299296
if (!project) {
300297
return;
301298
}
302-
newParams = `project=${project}`;
299+
newParams = `${IsfsUriParam.Project}=${project}`;
303300
} else {
304301
// Prompt the user for other query parameters
305302
const items = [
306303
{
307304
label: "$(filter) Filter",
308305
detail: "Comma-delimited list of search options, e.g. '*.cls,*.inc,*.mac,*.int'",
309-
picked: params.has("filter"),
310-
value: "filter",
306+
picked: filter != "",
307+
value: IsfsUriParam.Filter,
311308
},
312309
{
313310
label: "$(server-process) Show Generated",
314311
detail: "Also show files tagged as generated, e.g. by compilation.",
315-
picked: params.has("generated"),
316-
value: "generated",
312+
picked: generated,
313+
value: IsfsUriParam.Generated,
317314
},
318315
{
319316
label: "$(references) Hide Mapped",
320317
detail: `Hide files that are mapped into ${api.ns} from another code database.`,
321-
picked: params.has("mapped"),
322-
value: "mapped",
318+
picked: !mapped,
319+
value: IsfsUriParam.Mapped,
323320
},
324321
];
325322
if (api.ns != "%SYS") {
326323
// Only show system item for non-%SYS namespaces
327324
items.push({
328325
label: "$(library) Show System",
329326
detail: "Also show '%' items and INFORMATION.SCHEMA items.",
330-
picked: params.has("system"),
331-
value: "system",
327+
picked: system,
328+
value: IsfsUriParam.System,
332329
});
333330
}
334331
const otherParams = await vscode.window.showQuickPick(items, {
@@ -340,37 +337,29 @@ async function modifyWsFolderUri(uri: vscode.Uri): Promise<vscode.Uri | undefine
340337
return;
341338
}
342339
// Build the new query parameter string
343-
params.delete("csp");
344-
params.delete("project");
345-
params.delete("filter");
346-
params.delete("flat");
347-
params.delete("generated");
348-
params.delete("mapped");
349-
params.delete("system");
350-
params.delete("type");
340+
const params = new URLSearchParams();
351341
for (const otherParam of otherParams) {
352342
switch (otherParam.value) {
353-
case "filter": {
343+
case IsfsUriParam.Filter: {
354344
// Prompt for filter
355-
const filter = await vscode.window.showInputBox({
345+
const newFilter = await vscode.window.showInputBox({
356346
title: "Enter a filter string.",
357347
ignoreFocusOut: true,
358-
value: params.get("filter"),
348+
value: filter,
359349
placeHolder: "*.cls,*.inc,*.mac,*.int",
360350
prompt:
361351
"Patterns are comma-delimited and may contain both * (zero or more characters) and ? (a single character) as wildcards. To exclude items, prefix the pattern with a single quote.",
362352
});
363-
if (filter && filter.length) {
364-
params.set(otherParam.value, filter);
353+
if (newFilter && newFilter.length) {
354+
params.set(otherParam.value, newFilter);
365355
}
366356
break;
367357
}
368-
case "generated":
369-
case "system":
370-
params.set(otherParam.value, "1");
371-
break;
372-
case "mapped":
358+
case IsfsUriParam.Mapped:
373359
params.set(otherParam.value, "0");
360+
break;
361+
default: // system and generated
362+
params.set(otherParam.value, "1");
374363
}
375364
}
376365
newParams = params.toString();

0 commit comments

Comments
 (0)