Skip to content

Commit

Permalink
feat: Insert Record Definition
Browse files Browse the repository at this point in the history
Add command to lookup and insert a logical files record definition.

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Sep 18, 2020
1 parent dd124b7 commit 166a07a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 9 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ This extension adds rich language support for [HPCC Systems](https://hpccsystems
## Installation

* Install Visual Studio Code.
* In VS-Code, open the command palette (`ctrl/cmd + shift + p`) and select `Install Extension`. Enter `ecl` to filter the available extensions and choose `ECL Language by HPCC Systems`.
* In VS-Code, open the command palette (`ctrl/cmd+shift+p`) and select `Install Extension`. Enter `ecl` to filter the available extensions and choose `ECL Language by HPCC Systems`.
* Locate and install the appropriate ECL Client Tools from [hpccsystems.com](https://hpccsystems.com/download/archive)

## ECL

### ECL Commands

The following ECL specific commands are available. Note: These commands will **not** be active until an ECL file has been opened (as this triggers the extension to load). To activate a command either use its associated hotkey or press `ctrl/cmd + shift + p` and type `ECL` this will present a filtered list of the ECL specific commands:
The following ECL specific commands are available. Note: These commands will **not** be active until an ECL file has been opened (as this triggers the extension to load). To activate a command either use its associated hotkey or press `ctrl/cmd+shift+p` and type `ECL` this will present a filtered list of the ECL specific commands:

#### Global:

| Command | Shortcut | Description |
|---------------------------|:--------:|------------------------------------------------------------------|
| Syntax Check All Files | shift + F7 | Save All + check syntax of all files. |
| Syntax Clear | ctrl + F7 | Clear all previously reported ECL Syntax Check results |
| Syntax Check All Files | shift+F7 | Save All + check syntax of all files. |
| Syntax Clear | ctrl+F7 | Clear all previously reported ECL Syntax Check results |
| Language Reference Website | | Opens the ECL language reference website in external browser |
| Terminal | | Opens ECL Client Tools Terminal Session |

Expand All @@ -51,7 +51,8 @@ The following ECL specific commands are available. Note: These commands will *
|![Submit](resources/light-png/play.png) Submit | F5 | Submit ECL |
|![Compile](resources/light-png/file-binary.png) Compile | | Compile ECL |
| Syntax Check | F7 | Save and check syntax of current file |
| Language Reference Lookup | shift + F1 | For the currently selected text, search the online ECL language reference |
| Language Reference Lookup | shift+F1 | For the currently selected text, search the online ECL language reference |
| Insert Record Definition | ctrl+I R | Fetches record definition for given logical file |

#### Within the Workunit Tree:

Expand All @@ -74,7 +75,7 @@ The following ECL specific commands are available. Note: These commands will *

#### ECL Settings

The following Visual Studio Code settings are available for the ECL extension. These can be set in user preferences (`ctrl/cmd + ,`) or directly in your current workspace (`.vscode/settings.json`):
The following Visual Studio Code settings are available for the ECL extension. These can be set in user preferences (`ctrl/cmd+,`) or directly in your current workspace (`.vscode/settings.json`):

```javascript

Expand Down Expand Up @@ -102,6 +103,9 @@ The following Visual Studio Code settings are available for the ECL extension.
// Debug level logging (requires restart).
"ecl.debugLogging": false

// Automatically open Workunits on creation.
"ecl.WUAutoOpen": false

```

#### ECL Launch Settings
Expand Down Expand Up @@ -158,7 +162,7 @@ _KEL is an optional language that can generate ECL._

### KEL Commands

The following KEL specific commands are available. Note: These commands will **not** be active until a KEL file has been opened (as this triggers the extension to load). To activate a command either use its associated hotkey or press `ctrl/cmd + shift + p` and type `KEL` this will present a filtered list of the KEL specific commands:
The following KEL specific commands are available. Note: These commands will **not** be active until a KEL file has been opened (as this triggers the extension to load). To activate a command either use its associated hotkey or press `ctrl/cmd+shift+p` and type `KEL` this will present a filtered list of the KEL specific commands:

#### Within the KEL Code Editor:

Expand All @@ -172,7 +176,7 @@ _Click on KEL Client Tools Version_

#### KEL Settings

The following Visual Studio Code settings are available for the KEL extension. These can be set in user preferences (`ctrl/cmd + ,`) or directly in your current workspace (`.vscode/settings.json`):
The following Visual Studio Code settings are available for the KEL extension. These can be set in user preferences (`ctrl/cmd+,`) or directly in your current workspace (`.vscode/settings.json`):

```javascript
// Java runtime arguments (e.g. -Xmx12G).
Expand Down
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@
"title": "Terminal",
"description": "Opens ECL Client Tools Terminal Session."
},
{
"command": "ecl.insertRecordDef",
"category": "ECL",
"title": "Insert Record Definition",
"description": "Insert logical file record defintition."
},
{
"command": "hpccPlatform.refresh",
"title": "Refresh",
Expand Down Expand Up @@ -403,6 +409,11 @@
"command": "ecl.checkSyntax",
"group": "navigation@920"
},
{
"when": "resourceLangId == ecl && resourceExtname == .ecl",
"command": "ecl.insertRecordDef",
"group": "navigation@930"
},
{
"when": "resourceLangId == kel && resourceExtname == .kel",
"command": "kel.checkSyntax",
Expand Down Expand Up @@ -535,6 +546,12 @@
"key": "ctrl+f7",
"mac": "ctrl+f7"
},
{
"command": "ecl.insertRecordDef",
"key": "ctrl+i r",
"mac": "ctrl+i r",
"when": "editorTextFocus && editorLangId == ecl"
},
{
"command": "kel.checkSyntax",
"key": "f7",
Expand Down
20 changes: 20 additions & 0 deletions src/ecl/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class ECLCommands {
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.openECLWatch", this.openECLWatch));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.selectCTVersion", selectCTVersion));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.openECLWatchExternal", this.openECLWatchExternal));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.insertRecordDef", this.insertRecordDef));
}

static attach(ctx: vscode.ExtensionContext): ECLCommands {
Expand Down Expand Up @@ -79,4 +80,23 @@ export class ECLCommands {
vscode.env.openExternal(vscode.Uri.parse(source.url));
}
}

async insertRecordDef() {
if (vscode.window.activeTextEditor && sessionManager.session) {
const editor = vscode.window.activeTextEditor;
const position = editor.selection.active;
const lf = await vscode.window.showInputBox({
prompt: "Logical File"
}) || "";
if (lf) {
sessionManager.session.fetchRecordDef(lf).then(ecl => {
editor.edit(editBuilder => {
editBuilder.insert(position, ecl);
});
}).catch(e => {
vscode.window.showErrorMessage(e.message);
});
}
}
}
}
9 changes: 8 additions & 1 deletion src/hpccplatform/launchConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from "vscode";
import { locateClientTools, AccountService, Activity, Workunit, WUQuery, WUUpdate, Topology, TargetCluster, EclccErrors, IOptions } from "@hpcc-js/comms";
import { locateClientTools, AccountService, Activity, Workunit, WUQuery, WUUpdate, Topology, TargetCluster, EclccErrors, IOptions, LogicalFile } from "@hpcc-js/comms";
import { scopedLogger } from "@hpcc-js/util";
import { LaunchConfigState, LaunchMode, LaunchRequestArguments } from "../debugger/launchRequestArguments";
import { eclConfigurationProvider } from "./configProvider";
Expand Down Expand Up @@ -337,6 +337,13 @@ export class LaunchConfig {
});
}

fetchRecordDef(lf: string) {
return this.checkCredentials().then(credentials => {
const file = LogicalFile.attach(this.opts(credentials), "", lf);
return file.fetchInfo().then(info => info.Ecl);
});
}

async submit(filePath: string, targetCluster: string, mode: LaunchMode) {
// const args = await this.localResolveDebugConfiguration(filePath);
// logger.debug("launchRequest: " + JSON.stringify(args));
Expand Down
4 changes: 4 additions & 0 deletions src/hpccplatform/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class Session {
compile(fsPath: string) {
return this._launchConfig.submit(fsPath, this.targetCluster, "compile");
}

fetchRecordDef(lf: string) {
return this._launchConfig.fetchRecordDef(lf);
}
}

class SessionManager {
Expand Down

0 comments on commit 166a07a

Please sign in to comment.