Skip to content

Commit 2f7922c

Browse files
committed
Added ability to compile all classes in the current namespace
1 parent d77e742 commit 2f7922c

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class AtelierAPI {
1111
private _namespace: string;
1212
private _cache;
1313

14-
private get ns(): string {
14+
public get ns(): string {
1515
return this._namespace || this._config.ns;
1616
}
1717

commands/compile.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function importFile(file: CurrentFile, flags: string): Promise<any> {
2424
},
2525
true
2626
)
27-
.then(data => compile(file, flags))
27+
.then(() => compile(file, flags))
2828
.catch((error: Error) => {
2929
outputChannel.appendLine(error.message);
3030
outputChannel.show(true);
@@ -73,9 +73,42 @@ export async function importAndCompile(askFLags = false): Promise<any> {
7373
if (!config('conn').active) {
7474
return;
7575
}
76+
7677
const defaultFlags = config().compileFlags;
7778
const flags = askFLags ? await compileFlags() : defaultFlags;
7879
return importFile(file, flags).catch(error => {
7980
console.error(error);
8081
});
8182
}
83+
84+
// Compiles all files types in the namespace
85+
export async function namespaceCompile(askFLags = false): Promise<any> {
86+
const api = new AtelierAPI();
87+
const fileTypes = ["*.CLS", "*.MAC", "*.INC", "*.BAS"]
88+
if (!config('conn').active) {
89+
throw new Error(`No Active Connection`);
90+
}
91+
const defaultFlags = config().compileFlags;
92+
const flags = askFLags ? await compileFlags() : defaultFlags;
93+
if (flags === undefined) {
94+
// User cancelled
95+
return;
96+
}
97+
vscode.window.withProgress({
98+
location: vscode.ProgressLocation.Notification,
99+
title: `Compiling Namespace: ${api.ns}`,
100+
cancellable: false
101+
}, async () => {
102+
const data = await api
103+
.actionCompile(fileTypes, flags);
104+
if (data.status && data.status.errors && data.status.errors.length) {
105+
console.error(data.status.summary);
106+
throw new Error(`Compiling Namespace: ${api.ns} Error`);
107+
}
108+
else {
109+
vscode.window.showInformationMessage(`Compiling Namespace: ${api.ns} Success`);
110+
}
111+
const file = currentFile();
112+
return loadChanges(file);
113+
});
114+
}

extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const OBJECTSCRIPT_FILE_SCHEMA = 'objectscript';
44
export const OBJECTSCRIPTXML_FILE_SCHEMA = 'objectscriptxml';
55

66
import { viewOthers } from './commands/viewOthers';
7-
import { importAndCompile } from './commands/compile';
7+
import { importAndCompile, namespaceCompile } from './commands/compile';
88
import { exportAll, exportExplorerItem } from './commands/export';
99
import { xml2doc } from './commands/xml2doc';
1010
import { subclass } from './commands/subclass';
@@ -138,6 +138,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
138138
vscode.commands.registerCommand('vscode-objectscript.compile', () => importAndCompile(false)),
139139
vscode.commands.registerCommand('vscode-objectscript.touchBar.compile', () => importAndCompile(false)),
140140
vscode.commands.registerCommand('vscode-objectscript.compileWithFlags', () => importAndCompile(true)),
141+
vscode.commands.registerCommand('vscode-objectscript.compileAll', () => namespaceCompile(false)),
142+
vscode.commands.registerCommand('vscode-objectscript.compileAllWithFlags', () => namespaceCompile(true)),
141143
vscode.commands.registerCommand('vscode-objectscript.export', exportAll),
142144
vscode.commands.registerCommand('vscode-objectscript.viewOthers', viewOthers),
143145
vscode.commands.registerCommand('vscode-objectscript.subclass', subclass),

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
"command": "vscode-objectscript.compileWithFlags",
7575
"when": "vscode-objectscript.connectActive"
7676
},
77+
{
78+
"command": "vscode-objectscript.compileAll",
79+
"when": "vscode-objectscript.connectActive"
80+
},
81+
{
82+
"command": "vscode-objectscript.compileAllWithFlags",
83+
"when": "vscode-objectscript.connectActive"
84+
},
7785
{
7886
"command": "vscode-objectscript.viewOthers",
7987
"when": "vscode-objectscript.connectActive"
@@ -269,6 +277,16 @@
269277
"command": "vscode-objectscript.compileWithFlags",
270278
"title": "Import and compile current file with specified flags"
271279
},
280+
{
281+
"category": "ObjectScript",
282+
"command": "vscode-objectscript.compileAll",
283+
"title": "Compile all namespace files"
284+
},
285+
{
286+
"category": "ObjectScript",
287+
"command": "vscode-objectscript.compileAllWithFlags",
288+
"title": "Compile all namespace files with specified flags"
289+
},
272290
{
273291
"command": "vscode-objectscript.explorer.showSystem",
274292
"title": "Show system objects",
@@ -324,6 +342,12 @@
324342
"mac": "Cmd+F7",
325343
"when": "editorLangId =~ /^objectscript/"
326344
},
345+
{
346+
"command": "vscode-objectscript.compileAll",
347+
"key": "Ctrl+Shift+F7",
348+
"mac": "Cmd+Shift+F7",
349+
"when": "editorLangId =~ /^objectscript/"
350+
},
327351
{
328352
"command": "vscode-objectscript.viewOthers",
329353
"key": "Ctrl+Shift+V",

0 commit comments

Comments
 (0)