Skip to content

Commit 401b2d8

Browse files
committed
Restore "compile with flags" commands
1 parent 58beaa7 commit 401b2d8

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@
318318
{
319319
"command": "vscode-objectscript.connectFolderToServerNamespace",
320320
"when": "!vscode-objectscript.connectActive && vscode-objectscript.explorerRootCount == 0 && workspaceFolderCount != 0"
321+
},
322+
{
323+
"command": "vscode-objectscript.compileWithFlags",
324+
"when": "!(resourceScheme =~ /^isfs(-readonly)?$/) && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
325+
},
326+
{
327+
"command": "vscode-objectscript.compileOnlyWithFlags",
328+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive && !activeEditorIsDirty"
321329
}
322330
],
323331
"view/title": [
@@ -1112,8 +1120,18 @@
11121120
{
11131121
"category": "ObjectScript",
11141122
"command": "vscode-objectscript.showAllClassMembers",
1115-
"title": "Show All Class Members",
1123+
"title": "Show All Class Members...",
11161124
"icon": "$(symbol-class)"
1125+
},
1126+
{
1127+
"category": "ObjectScript",
1128+
"command": "vscode-objectscript.compileWithFlags",
1129+
"title": "Import and Compile Current File with Specified Flags..."
1130+
},
1131+
{
1132+
"category": "ObjectScript",
1133+
"command": "vscode-objectscript.compileOnlyWithFlags",
1134+
"title": "Compile Current File with Specified Flags..."
11171135
}
11181136
],
11191137
"keybindings": [

src/commands/compile.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,17 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
250250
);
251251
}
252252

253-
export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[]): Promise<any> {
253+
export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[], askFlags = false): Promise<any> {
254254
docs = docs.filter(notNull);
255255
if (!docs.length) return;
256256
const wsFolder = vscode.workspace.getWorkspaceFolder(docs[0].uri);
257-
const flags = vscode.workspace.getConfiguration("objectscript", wsFolder || docs[0].uri).get<string>("compileFlags");
257+
const defaultFlags = vscode.workspace
258+
.getConfiguration("objectscript", wsFolder || docs[0].uri)
259+
.get<string>("compileFlags");
260+
const flags = askFlags
261+
? await vscode.window.showInputBox({ title: "Enter compilation flags and qualifiers", value: defaultFlags })
262+
: defaultFlags;
263+
if (flags == undefined) return; // User clicked out of input box
258264
const api = new AtelierAPI(docs[0].uri);
259265
const docNames = docs.map((d) => d.name);
260266
// Determine the line ending to use for other documents affected
@@ -305,7 +311,7 @@ export async function compile(docs: (CurrentTextFile | CurrentBinaryFile)[]): Pr
305311
.then(loadChanges);
306312
}
307313

308-
export async function importAndCompile(document?: vscode.TextDocument): Promise<any> {
314+
export async function importAndCompile(document?: vscode.TextDocument, askFlags = false): Promise<any> {
309315
const file = currentFile(document);
310316
if (!file || filesystemSchemas.includes(file.uri.scheme) || !new AtelierAPI(file.uri).active) {
311317
// Not for server-side URIs or folders with inactive server connections
@@ -315,14 +321,14 @@ export async function importAndCompile(document?: vscode.TextDocument): Promise<
315321
return (
316322
importFile(file)
317323
.then(() => {
318-
if (isCompilable(file.name)) compile([file]);
324+
if (isCompilable(file.name)) compile([file], askFlags);
319325
})
320326
// importFile handles any server errors
321327
.catch(() => {})
322328
);
323329
}
324330

325-
export async function compileOnly(document?: vscode.TextDocument): Promise<any> {
331+
export async function compileOnly(document?: vscode.TextDocument, askFlags = false): Promise<any> {
326332
document =
327333
document ||
328334
(vscode.window.activeTextEditor && vscode.window.activeTextEditor.document
@@ -338,7 +344,7 @@ export async function compileOnly(document?: vscode.TextDocument): Promise<any>
338344
return;
339345
}
340346

341-
if (isCompilable(file.name)) compile([file]);
347+
if (isCompilable(file.name)) compile([file], askFlags);
342348
}
343349

344350
// Compiles all files types in the namespace

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11241124
sendCommandTelemetryEvent("compile");
11251125
importAndCompile();
11261126
}),
1127+
vscode.commands.registerCommand("vscode-objectscript.compileWithFlags", () => {
1128+
sendCommandTelemetryEvent("compileWithFlags");
1129+
importAndCompile(undefined, true);
1130+
}),
11271131
vscode.commands.registerCommand("vscode-objectscript.compileAll", () => {
11281132
sendCommandTelemetryEvent("compileAll");
11291133
namespaceCompile();
@@ -1376,6 +1380,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
13761380
sendCommandTelemetryEvent("compileOnly");
13771381
compileOnly();
13781382
}),
1383+
vscode.commands.registerCommand("vscode-objectscript.compileOnlyWithFlags", () => {
1384+
sendCommandTelemetryEvent("compileOnlyWithFlags");
1385+
compileOnly(undefined, true);
1386+
}),
13791387
vscode.languages.registerDocumentLinkProvider({ language: outputLangId }, new DocumentLinkProvider()),
13801388
vscode.commands.registerCommand("vscode-objectscript.editOthers", () => {
13811389
sendCommandTelemetryEvent("editOthers");

0 commit comments

Comments
 (0)