Skip to content

Commit 634cb3a

Browse files
committed
compile items from Server Explorer view, resolve #69
1 parent 4b48de1 commit 634cb3a

File tree

8 files changed

+52
-3
lines changed

8 files changed

+52
-3
lines changed

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
"command": "vscode-objectscript.explorer.delete",
116116
"when": "false"
117117
},
118+
{
119+
"command": "vscode-objectscript.explorer.compile",
120+
"when": "false"
121+
},
118122
{
119123
"command": "vscode-objectscript.explorer.refresh",
120124
"when": "vscode-objectscript.connectActive"
@@ -148,6 +152,10 @@
148152
"command": "vscode-objectscript.explorer.delete",
149153
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
150154
},
155+
{
156+
"command": "vscode-objectscript.explorer.compile",
157+
"when": "view == ObjectScriptExplorer && viewItem =~ /^dataNode:/"
158+
},
151159
{
152160
"command": "vscode-objectscript.explorer.otherNamespace",
153161
"when": "view == ObjectScriptExplorer && viewItem =~ /^serverNode((?!:extra:).)*$/",
@@ -351,6 +359,11 @@
351359
"title": "Delete",
352360
"category": "ObjectScript"
353361
},
362+
{
363+
"command": "vscode-objectscript.explorer.compile",
364+
"title": "Compile",
365+
"category": "ObjectScript"
366+
},
354367
{
355368
"command": "vscode-objectscript.explorer.refresh",
356369
"title": "Refresh Explorer",

src/commands/compile.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { AtelierAPI } from "../api";
66
import { config, documentContentProvider, FILESYSTEM_SCHEMA, fileSystemProvider } from "../extension";
77
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
88
import { currentFile, CurrentFile, outputChannel } from "../utils";
9+
import { RootNode } from "../explorer/models/rootNode";
10+
import { PackageNode } from "../explorer/models/packageNode";
11+
import { ClassNode } from "../explorer/models/classesNode";
12+
import { RoutineNode } from "../explorer/models/routineNode";
913

1014
async function compileFlags(): Promise<string> {
1115
const defaultFlags = config().compileFlags;
@@ -169,3 +173,22 @@ export async function importFolder(uri: vscode.Uri): Promise<any> {
169173
(error, files) => importFiles(files.map(name => path.join(folder, name)))
170174
);
171175
}
176+
177+
export async function compileExplorerItem(node: RootNode | PackageNode | ClassNode | RoutineNode): Promise<any> {
178+
const { workspaceFolder, namespace } = node;
179+
const flags = config().compileFlags;
180+
const api = new AtelierAPI(workspaceFolder);
181+
api.setNamespace(namespace);
182+
let docs = [node.fullName];
183+
if (node instanceof PackageNode) {
184+
switch (node.category) {
185+
case "RTN":
186+
docs = [node.fullName + ".*.mac"];
187+
break;
188+
case "CLS":
189+
docs = [node.fullName + ".*.cls"];
190+
break;
191+
}
192+
}
193+
return api.actionCompile(docs, flags);
194+
}

src/commands/serverActions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export async function serverActions(): Promise<void> {
3131
}
3232
)
3333
.then(action => {
34+
if (!action) {
35+
return;
36+
}
3437
switch (action.id) {
3538
case "toggleConnection": {
3639
return vscode.workspace.getConfiguration().update("objectscript.conn.active", !conn.active);

src/debug/dbgp.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ export class DbgpConnection extends EventEmitter {
102102
},
103103
},
104104
});
105-
console.log(xml);
106105
const document = parser.parseFromString(xml, "application/xml");
107106
this.emit("message", document);
108107
// reset buffer

src/debug/xdebugConnection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ export class Connection extends DbgpConnection {
938938
const data = iconv.encode(commandString, ENCODING);
939939
this._pendingCommands.set(transactionId, command);
940940
this._pendingExecuteCommand = command.isExecuteCommand;
941-
console.log(data.toString());
942941
await this.write(data);
943942
}
944943

src/explorer/models/rootNode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export class RootNode extends NodeBase {
1616
this._category = category;
1717
}
1818

19+
public get category(): string {
20+
return this._category;
21+
}
22+
1923
public getTreeItem(): vscode.TreeItem {
2024
return {
2125
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ export const OBJECTSCRIPTXML_FILE_SCHEMA = "objectscriptxml";
99
export const FILESYSTEM_SCHEMA = "isfs";
1010
export const schemas = [OBJECTSCRIPT_FILE_SCHEMA, OBJECTSCRIPTXML_FILE_SCHEMA, FILESYSTEM_SCHEMA];
1111

12-
import { importAndCompile, importFolder as importFileOrFolder, namespaceCompile } from "./commands/compile";
12+
import {
13+
importAndCompile,
14+
importFolder as importFileOrFolder,
15+
namespaceCompile,
16+
compileExplorerItem,
17+
} from "./commands/compile";
1318
import { deleteItem } from "./commands/delete";
1419
import { exportAll, exportExplorerItem } from "./commands/export";
1520
import { serverActions } from "./commands/serverActions";
@@ -260,6 +265,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
260265
vscode.commands.registerCommand("vscode-objectscript.explorer.openRoutine", vscode.window.showTextDocument),
261266
vscode.commands.registerCommand("vscode-objectscript.explorer.export", exportExplorerItem),
262267
vscode.commands.registerCommand("vscode-objectscript.explorer.delete", deleteItem),
268+
vscode.commands.registerCommand("vscode-objectscript.explorer.compile", compileExplorerItem),
263269
vscode.commands.registerCommand("vscode-objectscript.explorer.showGenerated", (workspaceNode: WorkspaceNode) => {
264270
workspaceState.update(`ExplorerGenerated:${workspaceNode.uniqueId}`, true);
265271
return explorerProvider.refresh();

src/providers/Formatter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class Formatter {
4444
/** functions */
4545
resultValue = resultValue.replace(/\^?\$(Z+\w|\w)/i, v => v.toUpperCase());
4646
resultValue = resultValue.replace(/\$isobject/i, "$IsObject");
47+
resultValue = resultValue.replace(/\$classmethod/i, "$ClassMethod");
48+
resultValue = resultValue.replace(/\$classname/i, "$ClassName");
4749
break;
4850
}
4951
default: {

0 commit comments

Comments
 (0)