Skip to content

Commit eee6456

Browse files
Merge pull request #829 from gjsjohnmurray/pre-sync-1.4.1
Merge 1.4.1 release changes into prerelease branch
2 parents 632912b + ad9c55a commit eee6456

File tree

13 files changed

+472
-135
lines changed

13 files changed

+472
-135
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log
22

3+
## [1.4.1] 14-Jan-2022
4+
- Fixes
5+
- Version 1.4.0 is failing to activate (#827)
6+
7+
## [1.4.0] 14-Jan-2022
8+
- Enhancements
9+
- Make `Ctrl / Cmd+T` lookup (Open Symbol by Name) check all servers connected to a multi-root workspace (#815)
10+
- Improve exporting (#818)
11+
- Improve client-side DFI workflow (#808)
12+
- Improve behavior when no Source Control class is enabled (#171)
13+
- Fixes
14+
- Displace incorrectly-published pre-release version.
15+
- Point to correct line when debugging through code with multi-line method arguments (#804)
16+
- Show menu options from correct namespace for `Studio Actions` in ObjectScript Explorer (#812)
17+
- Fix `Attempted Edit` Studio Action handling (#781)
18+
- Properly return options for the Server Command menu for isfs-readonly files (#811)
19+
- Remove `vscode-objectscript-output` language from selector (#805)
20+
321
## [1.2.2] 07-Dec-2021
422
- Fixes
523
- Exporting not working with new version 1.2.1 (#799)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This is a pre-release which improves security as follows:
3030
- Export of existing server sources into a working folder:
3131
- open Command Palette (<kbd>F1</kbd> or <kbd>⌘</kbd>/<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>)
3232
- start typing 'ObjectScript'
33-
- choose `ObjectScript: Export Sources`
33+
- choose `ObjectScript: Export Code from Server`
3434
- press <kbd>Enter</kbd>
3535
- Save and compile a class:
3636
- press <kbd>⌘</kbd>/<kbd>Ctrl</kbd>+<kbd>F7</kbd>
@@ -62,8 +62,8 @@ To unlock these features (optional):
6262

6363
1. Download and install a beta version from GitHub. This is necessary because Marketplace does not allow publication of extensions that use proposed APIs.
6464
- Go to https://github.com/intersystems-community/vscode-objectscript/releases
65-
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `1.2.2`, look for `1.2.3-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
66-
- Download the VSIX file (for example `vscode-objectscript-1.2.3-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.
65+
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `1.4.1`, look for `1.4.2-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
66+
- Download the VSIX file (for example `vscode-objectscript-1.4.2-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.
6767

6868
2. From [Command Palette](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) choose `Preferences: Configure Runtime Arguments`.
6969
3. In the argv.json file that opens, add this line (required for both Stable and Insiders versions of VS Code):

docs/SettingsReference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The extensions in the InterSystems ObjectScript Extension Pack provide many sett
4545
| `"objectscript.export.atelier"` | Export source code as Atelier did it, with packages as subfolders. | `boolean` | `true` | |
4646
| `"objectscript.export.category"` | Category of source code to export: `CLS` = classes; `RTN` = routines; `CSP` = csp files; `OTH` = other. Default is `*` = all. | `string` or `object` | `"*"` | |
4747
| `"objectscript.export.dontExportIfNoChanges"` | Do not rewrite the local file if the content is identical to what came from the server. | `boolean` | `false` | |
48-
| `"objectscript.export.filter"` | SQL filter to limit what to export. | `string` | `""` | |
48+
| `"objectscript.export.filter"` | SQL filter to limit what to export. | `string` | `""` | The filter is applied to document names using the [LIKE predicate](https://irisdocs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_like) (i.e. `Name LIKE '%filter%'`). |
4949
| `"objectscript.export.folder"` | Folder for exported source code within workspace. | `string` | `"src"` | |
5050
| `"objectscript.export.generated"` | Export generated source code files, such as INTs generated from classes. | `boolean` | `false` | |
5151
| `"objectscript.export.map"` | Map file names before export, with regexp pattern as a key and replacement as a value. | `object` | `{}` | For example, `{ \"%(.*)\": \"_$1\" }` to make % classes or routines use underscore prefix instead. |

package-lock.json

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

package.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-objectscript",
33
"displayName": "InterSystems ObjectScript",
44
"description": "InterSystems ObjectScript language support for Visual Studio Code",
5-
"version": "1.3.2022011401",
5+
"version": "1.5.2022011402",
66
"icon": "images/logo.png",
77
"aiKey": "9cd75d51-697c-406c-a929-2bcf46e97c64",
88
"categories": [
@@ -232,6 +232,10 @@
232232
{
233233
"command": "vscode-objectscript.showClassDocumentationPreview",
234234
"when": "editorLangId == objectscript-class"
235+
},
236+
{
237+
"command": "vscode-objectscript.exportCurrentFile",
238+
"when": "resourceScheme == objectscript && vscode-objectscript.connectActive"
235239
}
236240
],
237241
"view/title": [
@@ -332,6 +336,11 @@
332336
"command": "vscode-objectscript.compileOnly",
333337
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
334338
"group": "objectscript@7"
339+
},
340+
{
341+
"command": "vscode-objectscript.exportCurrentFile",
342+
"when": "resourceScheme == objectscript && vscode-objectscript.connectActive",
343+
"group": "objectscript@8"
335344
}
336345
],
337346
"editor/title": [
@@ -439,6 +448,7 @@
439448
},
440449
{
441450
"id": "vscode-objectscript-output",
451+
"aliases": [],
442452
"mimetypes": [
443453
"text/x-code-output"
444454
]
@@ -495,7 +505,7 @@
495505
{
496506
"category": "ObjectScript",
497507
"command": "vscode-objectscript.export",
498-
"title": "Export Sources",
508+
"title": "Export Code from Server",
499509
"enablement": "!isWeb"
500510
},
501511
{
@@ -693,6 +703,12 @@
693703
"title": "Show Class Documentation Preview",
694704
"enablement": "!isWeb",
695705
"icon": "$(open-preview)"
706+
},
707+
{
708+
"category": "ObjectScript",
709+
"command": "vscode-objectscript.exportCurrentFile",
710+
"title": "Export Current File from Server",
711+
"enablement": "!isWeb"
696712
}
697713
],
698714
"keybindings": [
@@ -893,7 +909,7 @@
893909
"type": "boolean"
894910
},
895911
"filter": {
896-
"description": "SQL filter to limit what to export.",
912+
"markdownDescription": "SQL filter to limit what to export. The filter is applied to document names using the [LIKE predicate](https://irisdocs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_like) (i.e. `Name LIKE '%filter%'`).",
897913
"type": "string"
898914
},
899915
"category": {

src/commands/export.ts

Lines changed: 108 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@ import fs = require("fs");
22
import path = require("path");
33
import * as vscode from "vscode";
44
import { AtelierAPI } from "../api";
5-
import { config, explorerProvider } from "../extension";
6-
import { mkdirSyncRecursive, notNull, outputChannel, uriOfWorkspaceFolder } from "../utils";
5+
import { config, explorerProvider, OBJECTSCRIPT_FILE_SCHEMA, schemas } from "../extension";
6+
import { currentFile, mkdirSyncRecursive, notNull, outputChannel, uriOfWorkspaceFolder } from "../utils";
77
import { NodeBase } from "../explorer/models/nodeBase";
88

9-
const filesFilter = (file: any) => {
10-
if (file.cat === "CSP" || file.name.startsWith("%") || file.name.startsWith("INFORMATION.")) {
11-
return false;
12-
}
13-
return true;
14-
};
15-
169
export const getCategory = (fileName: string, addCategory: any | boolean): string => {
1710
const fileExt = fileName.split(".").pop().toLowerCase();
1811
if (typeof addCategory === "object") {
@@ -30,6 +23,7 @@ export const getCategory = (fileName: string, addCategory: any | boolean): strin
3023
case "int":
3124
case "inc":
3225
case "mac":
26+
case "dfi":
3327
return fileExt;
3428
default:
3529
return "oth";
@@ -51,17 +45,26 @@ export const getFileName = (
5145
const cat = addCategory ? getCategory(name, addCategory) : null;
5246
return [folder, cat, ...nameArr].filter(notNull).join(path.sep);
5347
} else {
54-
// This is a class, routine or include file
55-
if (map) {
56-
for (const pattern of Object.keys(map)) {
57-
if (new RegExp(`^${pattern}$`).test(name)) {
58-
name = name.replace(new RegExp(`^${pattern}$`), map[pattern]);
59-
break;
48+
let fileNameArray: string[];
49+
let fileExt: string;
50+
if (/\.dfi$/i.test(name)) {
51+
// This is a DFI file
52+
fileNameArray = name.split("-");
53+
fileNameArray.push(fileNameArray.pop().slice(0, -4));
54+
fileExt = "dfi";
55+
} else {
56+
// This is a class, routine or include file
57+
if (map) {
58+
for (const pattern of Object.keys(map)) {
59+
if (new RegExp(`^${pattern}$`).test(name)) {
60+
name = name.replace(new RegExp(`^${pattern}$`), map[pattern]);
61+
break;
62+
}
6063
}
6164
}
65+
fileNameArray = name.split(".");
66+
fileExt = fileNameArray.pop().toLowerCase();
6267
}
63-
const fileNameArray: string[] = name.split(".");
64-
const fileExt = fileNameArray.pop().toLowerCase();
6568
const cat = addCategory ? getCategory(name, addCategory) : null;
6669
if (split) {
6770
const fileName = [folder, cat, ...fileNameArray].filter(notNull).join(path.sep);
@@ -216,27 +219,86 @@ export async function exportList(files: string[], workspaceFolder: string, names
216219
);
217220
}
218221

219-
export async function exportAll(workspaceFolder?: string): Promise<any> {
220-
if (!workspaceFolder) {
221-
const list = vscode.workspace.workspaceFolders
222-
.filter((folder) => config("conn", folder.name).active)
223-
.map((el) => el.name);
224-
if (list.length > 1) {
225-
return vscode.window.showQuickPick(list).then((folder) => (folder ? exportAll : null));
226-
} else {
227-
workspaceFolder = list.pop();
222+
export async function exportAll(): Promise<any> {
223+
let workspaceFolder: string;
224+
const workspaceList = vscode.workspace.workspaceFolders
225+
.filter((folder) => !schemas.includes(folder.uri.scheme) && config("conn", folder.name).active)
226+
.map((el) => el.name);
227+
if (workspaceList.length > 1) {
228+
const selection = await vscode.window.showQuickPick(workspaceList, {
229+
placeHolder: "Select the workspace folder to export files to.",
230+
});
231+
if (selection === undefined) {
232+
return;
228233
}
234+
workspaceFolder = selection;
235+
} else if (workspaceList.length === 1) {
236+
workspaceFolder = workspaceList.pop();
237+
} else {
238+
vscode.window.showInformationMessage(
239+
"There are no folders in the current workspace that code can be exported to.",
240+
"Dismiss"
241+
);
242+
return;
229243
}
230244
if (!config("conn", workspaceFolder).active) {
231245
return;
232246
}
233247
const api = new AtelierAPI(workspaceFolder);
234248
outputChannel.show(true);
235-
const { category, generated, filter, ns } = config("export", workspaceFolder);
236-
const files = (data) => data.result.content.filter(filesFilter).map((file) => file.name);
237-
return api.getDocNames({ category, generated, filter }).then((data) => {
238-
return exportList(files(data), workspaceFolder, ns);
239-
});
249+
const { category, generated, filter } = config("export", workspaceFolder);
250+
// Replicate the behavior of getDocNames() but use StudioOpenDialog for better performance
251+
let filterStr = "";
252+
switch (category) {
253+
case "CLS":
254+
filterStr = "Type = 4";
255+
break;
256+
case "CSP":
257+
filterStr = "Type %INLIST $LISTFROMSTRING('5,6')";
258+
break;
259+
case "OTH":
260+
filterStr = "Type NOT %INLIST $LISTFROMSTRING('0,1,2,3,4,5,6,11,12')";
261+
break;
262+
case "RTN":
263+
filterStr = "Type %INLIST $LISTFROMSTRING('0,1,2,3,11,12')";
264+
break;
265+
}
266+
if (filter !== "") {
267+
if (filterStr !== "") {
268+
filterStr += " AND ";
269+
}
270+
filterStr += `Name LIKE '%${filter}%'`;
271+
}
272+
return api
273+
.actionQuery("SELECT Name FROM %Library.RoutineMgr_StudioOpenDialog(?,?,?,?,?,?,?,?)", [
274+
"*",
275+
"1",
276+
"1",
277+
api.config.ns.toLowerCase() === "%sys" ? "1" : "0",
278+
"1",
279+
"0",
280+
generated ? "1" : "0",
281+
filterStr,
282+
])
283+
.then(async (data) => {
284+
let files: vscode.QuickPickItem[] = data.result.content.map((file) => {
285+
return { label: file.Name, picked: true };
286+
});
287+
files = await vscode.window.showQuickPick(files, {
288+
canPickMany: true,
289+
ignoreFocusOut: true,
290+
placeHolder: "Uncheck a file to exclude it. Press 'Escape' to cancel export.",
291+
title: "Files to Export",
292+
});
293+
if (files === undefined) {
294+
return;
295+
}
296+
return exportList(
297+
files.map((file) => file.label),
298+
workspaceFolder,
299+
api.config.ns
300+
);
301+
});
240302
}
241303

242304
export async function exportExplorerItems(nodes: NodeBase[]): Promise<any> {
@@ -264,3 +326,18 @@ Would you like to continue?`,
264326
return exportList(items.flat(), workspaceFolder, namespace).then(() => explorerProvider.refresh());
265327
});
266328
}
329+
330+
export async function exportCurrentFile(): Promise<any> {
331+
const openEditor = vscode.window.activeTextEditor;
332+
if (openEditor === undefined) {
333+
// Need an open document to export
334+
return;
335+
}
336+
const openDoc = openEditor.document;
337+
if (openDoc.uri.scheme !== OBJECTSCRIPT_FILE_SCHEMA) {
338+
// Only export files opened from the explorer
339+
return;
340+
}
341+
const api = new AtelierAPI(openDoc.uri);
342+
return exportList([currentFile(openDoc).name], api.configName, api.config.ns);
343+
}

0 commit comments

Comments
 (0)