Skip to content

Commit b345ea8

Browse files
authored
Merge pull request #208 from intersystems-community/import-folder
Import folder only, without compilation from files explorer
2 parents c69c25b + 28f4dcd commit b345ea8

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"onCommand:vscode-objectscript.explorer.openClass",
5959
"onCommand:vscode-objectscript.explorer.openRoutine",
6060
"onCommand:vscode-objectscript.compileFolder",
61+
"onCommand:vscode-objectscript.importFolder",
6162
"onLanguage:objectscript",
6263
"onLanguage:objectscript-class",
6364
"onLanguage:objectscript-macros",
@@ -262,7 +263,12 @@
262263
"explorer/context": [
263264
{
264265
"command": "vscode-objectscript.compileFolder",
265-
"when": "vscode-objectscript.connectActive",
266+
"when": "vscode-objectscript.connectActive && resourceScheme == file",
267+
"group": "objectscript@1"
268+
},
269+
{
270+
"command": "vscode-objectscript.importFolder",
271+
"when": "vscode-objectscript.connectActive && resourceScheme == file",
266272
"group": "objectscript@1"
267273
},
268274
{
@@ -478,6 +484,11 @@
478484
"command": "vscode-objectscript.compileFolder",
479485
"title": "Import and Compile"
480486
},
487+
{
488+
"category": "ObjectScript",
489+
"command": "vscode-objectscript.importFolder",
490+
"title": "Import without Compilation"
491+
},
481492
{
482493
"category": "ObjectScript",
483494
"command": "vscode-objectscript.serverCommands.sourceControl",

src/commands/compile.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export async function namespaceCompile(askFLags = false): Promise<any> {
242242
);
243243
}
244244

245-
function importFiles(files) {
245+
function importFiles(files, noCompile = false) {
246246
return Promise.all<CurrentFile>(
247247
files.map((file) =>
248248
vscode.workspace
@@ -255,13 +255,13 @@ function importFiles(files) {
255255
})
256256
)
257257
)
258-
).then(compile);
258+
).then(noCompile ? Promise.resolve : compile);
259259
}
260260

261-
export async function importFolder(uri: vscode.Uri): Promise<any> {
261+
export async function importFolder(uri: vscode.Uri, noCompile = false): Promise<any> {
262262
const folder = uri.fsPath;
263263
if (fs.lstatSync(folder).isFile()) {
264-
return importFiles([folder]);
264+
return importFiles([folder], noCompile);
265265
}
266266
glob(
267267
"*.{cls,inc,mac,int}",
@@ -270,7 +270,11 @@ export async function importFolder(uri: vscode.Uri): Promise<any> {
270270
matchBase: true,
271271
nocase: true,
272272
},
273-
(error, files) => importFiles(files.map((name) => path.join(folder, name)))
273+
(_error, files) =>
274+
importFiles(
275+
files.map((name) => path.join(folder, name)),
276+
noCompile
277+
)
274278
);
275279
}
276280

src/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,12 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
440440
vscode.commands.registerCommand("vscode-objectscript.compileWithFlags", () => importAndCompile(true)),
441441
vscode.commands.registerCommand("vscode-objectscript.compileAll", () => namespaceCompile(false)),
442442
vscode.commands.registerCommand("vscode-objectscript.compileAllWithFlags", () => namespaceCompile(true)),
443-
vscode.commands.registerCommand("vscode-objectscript.compileFolder", importFileOrFolder),
443+
vscode.commands.registerCommand("vscode-objectscript.compileFolder", (_file, files) =>
444+
Promise.all(files.map((file) => importFileOrFolder(file, false)))
445+
),
446+
vscode.commands.registerCommand("vscode-objectscript.importFolder", (_file, files) =>
447+
Promise.all(files.map((file) => importFileOrFolder(file, true)))
448+
),
444449
vscode.commands.registerCommand("vscode-objectscript.export", exportAll),
445450
vscode.commands.registerCommand("vscode-objectscript.debug", (program: string, askArgs: boolean) => {
446451
const startDebugging = (args) => {

0 commit comments

Comments
 (0)