Skip to content

Commit b5a29ec

Browse files
isc-kluklu
andauthored
Support deleting folders (#1705)
Fix #1638 and improve maintainability --------- Co-authored-by: klu <kc.lu@intersystems.com>
1 parent 478ab22 commit b5a29ec

File tree

8 files changed

+119
-152
lines changed

8 files changed

+119
-152
lines changed

.vscode/launch.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22
{
33
"version": "0.2.0",
44
"configurations": [
5-
{
6-
"name": "Launch Extension Alone",
7-
"type": "extensionHost",
8-
"request": "launch",
9-
"runtimeExecutable": "${execPath}",
10-
"args": [
11-
"--disable-extensions",
12-
"--extensionDevelopmentPath=${workspaceRoot}"
13-
],
14-
"stopOnEntry": false,
15-
"sourceMaps": true,
16-
"outFiles": [
17-
"${workspaceRoot}/dist/**/*.js"
18-
],
19-
"preLaunchTask": "npm: webpack"
20-
},
215
{
226
"name": "Launch Extension",
237
"type": "extensionHost",

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The extensions in the [official extension pack](https://docs.intersystems.com/co
1515
1. [Node.js](https://nodejs.org/) 22
1616
1. Windows, macOS, or Linux
1717
1. [Visual Studio Code](https://code.visualstudio.com/)
18+
1. [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) (Optional)
1819

1920
### Setup
2021

@@ -44,8 +45,6 @@ Then, open the debug panel by clicking the `Run and Debug` icon on the Activity
4445
option from the top menu, and click start. A new window will launch with the title
4546
`[Extension Development Host]`. Do your testing here.
4647

47-
If you want to disable all other extensions when testing in the Extension Development Host, choose the `Launch Extension Alone` option instead.
48-
4948
### Pull requests
5049

5150
Work should be done on a unique branch -- not the master branch. Pull requests require the approval of two PMC members, as described in the [Governance document](GOVERNANCE.md). PMC review is often high level, so in addition to that, you should request a review by someone familiar with the technical details of your particular pull request.

src/commands/compile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
} from "../utils";
3737
import { StudioActions } from "./studio";
3838
import { NodeBase, PackageNode, RootNode } from "../explorer/nodes";
39-
import { getUrisForDocument, updateIndexForDocument } from "../utils/documentIndex";
39+
import { getUrisForDocument, updateIndex } from "../utils/documentIndex";
4040

4141
async function compileFlags(): Promise<string> {
4242
const defaultFlags = config().compileFlags;
@@ -245,9 +245,9 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
245245
// Re-throw the error
246246
throw e;
247247
});
248-
if (isClassOrRtn(file.uri)) {
248+
if (isClassOrRtn(file.uri.path)) {
249249
// Update the document index
250-
updateIndexForDocument(file.uri, undefined, undefined, content);
250+
updateIndex(file.uri, content);
251251
}
252252
} else if (filesystemSchemas.includes(file.uri.scheme)) {
253253
fileSystemProvider.fireFileChanged(file.uri);
@@ -659,7 +659,7 @@ export async function importLocalFilesToServerSideFolder(wsFolderUri: vscode.Uri
659659
return;
660660
}
661661
// Filter out non-ISC files
662-
uris = uris.filter(isClassOrRtn);
662+
uris = uris.filter((uri) => isClassOrRtn(uri.path));
663663
if (uris.length == 0) {
664664
vscode.window.showErrorMessage("No classes or routines were selected.", "Dismiss");
665665
return;

src/commands/export.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getWsFolder,
99
handleError,
1010
isClassOrRtn,
11+
isImportableLocalFile,
1112
lastUsedLocalUri,
1213
notNull,
1314
outputChannel,
@@ -20,7 +21,7 @@ import {
2021
} from "../utils";
2122
import { pickDocuments } from "../utils/documentPicker";
2223
import { NodeBase } from "../explorer/nodes";
23-
import { updateIndexForDocument } from "../utils/documentIndex";
24+
import { updateIndex } from "../utils/documentIndex";
2425

2526
export function getCategory(fileName: string, addCategory: any | boolean): string {
2627
const fileExt = fileName.split(".").pop().toLowerCase();
@@ -112,9 +113,9 @@ async function exportFile(wsFolderUri: vscode.Uri, namespace: string, name: stri
112113
// Re-throw the error
113114
throw e;
114115
});
115-
if (isClassOrRtn(fileUri)) {
116+
if (isClassOrRtn(fileUri.path) || isImportableLocalFile(fileUri)) {
116117
// Update the document index
117-
updateIndexForDocument(fileUri, undefined, undefined, content);
118+
updateIndex(fileUri, content);
118119
}
119120
const ws = workspaceFolderOfUri(fileUri);
120121
const mtime = Number(new Date(data.result.ts + "Z"));

src/commands/unitTest.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
notIsfs,
99
displayableUri,
1010
stripClassMemberNameQuotes,
11-
uriIsParentOf,
11+
uriIsAncestorOf,
1212
} from "../utils";
1313
import { fileSpecFromURI, isfsConfig } from "../utils/FileProviderUtil";
1414
import { AtelierAPI } from "../api";
@@ -62,9 +62,8 @@ const textDecoder = new TextDecoder();
6262
/** Find the root `TestItem` for `uri` */
6363
function rootItemForItem(testController: vscode.TestController, uri: vscode.Uri): vscode.TestItem | undefined {
6464
let rootItem: vscode.TestItem;
65-
const uriString = uri.toString();
6665
for (const [, i] of testController.items) {
67-
if (uriIsParentOf(i.uri, uri) || uriString == i.uri.toString()) {
66+
if (uriIsAncestorOf(i.uri, uri)) {
6867
rootItem = i;
6968
break;
7069
}
@@ -422,10 +421,9 @@ async function runHandler(
422421

423422
// Add the initial items to the queue to process
424423
const queue: vscode.TestItem[] = [];
425-
const rootUriString = root.uri.toString();
426424
if (request.include?.length) {
427425
request.include.forEach((i) => {
428-
if (uriIsParentOf(root.uri, i.uri) || i.uri.toString() == rootUriString) {
426+
if (uriIsAncestorOf(root.uri, i.uri)) {
429427
queue.push(i);
430428
}
431429
});
@@ -1082,7 +1080,7 @@ export function setUpTestController(context: vscode.ExtensionContext): vscode.Di
10821080
// Update root items if needed
10831081
e.removed.forEach((wf) => {
10841082
testController.items.forEach((i) => {
1085-
if (uriIsParentOf(wf.uri, i.uri)) {
1083+
if (uriIsAncestorOf(wf.uri, i.uri)) {
10861084
// Remove this TestItem
10871085
classesForRoot.delete(i);
10881086
testController.items.delete(i.id);

src/extension.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import {
9595
otherDocExts,
9696
getWsServerConnection,
9797
isClassOrRtn,
98+
isImportableLocalFile,
9899
addWsServerRootFolderData,
99100
getWsFolder,
100101
exportedUris,
@@ -143,7 +144,7 @@ import {
143144
indexWorkspaceFolder,
144145
removeIndexOfWorkspaceFolder,
145146
storeTouchedByVSCode,
146-
updateIndexForDocument,
147+
updateIndex,
147148
} from "./utils/documentIndex";
148149
import { WorkspaceNode, NodeBase } from "./explorer/nodes";
149150
import { showPlanWebview } from "./commands/showPlanPanel";
@@ -1090,11 +1091,13 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10901091
checkChangedOnServer(currentFile(event.document));
10911092
}
10921093
if (
1093-
[clsLangId, macLangId, intLangId, incLangId].includes(event.document.languageId) &&
1094-
notIsfs(event.document.uri)
1094+
notIsfs(event.document.uri) &&
1095+
([clsLangId, macLangId, intLangId, incLangId].includes(event.document.languageId) ||
1096+
isClassOrRtn(event.document.uri.path) ||
1097+
isImportableLocalFile(event.document.uri))
10951098
) {
10961099
// Update the local workspace folder index to incorporate this change
1097-
updateIndexForDocument(event.document.uri);
1100+
updateIndex(event.document.uri);
10981101
}
10991102
}),
11001103
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
@@ -1426,7 +1429,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
14261429
e.files
14271430
// Attempt to fill in stub content for classes and routines that
14281431
// are not server-side files and were not created due to an export
1429-
.filter((f) => notIsfs(f) && isClassOrRtn(f) && !exportedUris.has(f.toString()))
1432+
.filter((f) => notIsfs(f) && isClassOrRtn(f.path) && !exportedUris.has(f.toString()))
14301433
.forEach(async (uri) => {
14311434
// Need to wait in case file was created using "Save As..."
14321435
// because in that case the file gets created without

0 commit comments

Comments
 (0)