Skip to content

Commit

Permalink
Merge pull request #348 from GordonSmith/GH-341-HELP_URL
Browse files Browse the repository at this point in the history
feat: Point ECL help to new website
  • Loading branch information
GordonSmith authored Jun 16, 2023
2 parents 7ecbfca + 99c173a commit ae5f745
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"${workspaceRoot}\\ecl-sample"
],
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
"${workspaceFolder}/dist/**/*.js"
]
},
{
Expand All @@ -50,7 +50,7 @@
"${workspaceRoot}\\ecl-sample"
],
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
"${workspaceFolder}/dist/**/*.js"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This extension adds rich language support for [HPCC Systems](https://hpccsystems
### v2.23.x
* Added `ecl.submitNoArchive` command, submits raw content of editor to server without creating an archive first.
* Added `ecl.pingInterval` setting, allows user to change or disable the "server alive" ping.
* Updated shift+F1 help to use new HPCC Systems website and include the Standard Library.

### v2.19.x
* Added `ecl.saveOnSyntaxCheck` and `ecl.saveOnSubmit` option to ECL Settings (defaulting to off to match ECL IDE behaviour).
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@
"title": "%Language Reference Website%",
"description": "%Opens the ECL language reference website in external browser%"
},
{
"command": "ecl.showStandardLibraryReference",
"category": "ECL",
"title": "%Standard Library Website%",
"description": "%Opens the ECL Standard Library website in external browser%"
},
{
"command": "ecl.searchTerm",
"category": "ECL",
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"Java runtime arguments (e.g. -Xmx12G)": "Java runtime arguments (e.g. -Xmx12G)",
"Language Reference Lookup": "Language Reference Lookup",
"Language Reference Website": "Language Reference Website",
"Standard Library Website": "Standard Library Website",
"Launch ECL Watch": "Launch ECL Watch",
"Max result limit for workunit results": "Max result limit for workunit results",
"My workunits": "My workunits",
Expand All @@ -58,6 +59,7 @@
"Opens ECL Watch Page": "Opens ECL Watch Page",
"Opens ECL Watch Page in an external browser": "Opens ECL Watch Page in an external browser",
"Opens the ECL language reference website in external browser": "Opens the ECL language reference website in external browser",
"Opens the ECL Standard Library website in external browser": "Opens the ECL Standard Library website in external browser",
"Override KEL auto detection": "Override KEL auto detection",
"Override eclcc auto detection": "Override eclcc auto detection",
"Pin launch configuration": "Pin launch configuration",
Expand Down
68 changes: 41 additions & 27 deletions src/ecl/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@ export class ECLCommands {

private constructor(ctx: vscode.ExtensionContext) {
this._ctx = ctx;
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntax", this.checkSyntax));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntaxAll", this.checkSyntaxAll));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntaxClear", this.checkSyntaxClear));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.submit", this.submit));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.submitNoArchive", this.submitNoArchive));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.compile", this.compile));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.showLanguageReference", this.showLanguageReference));
ctx.subscriptions.push(vscode.commands.registerTextEditorCommand("ecl.searchTerm", editor => this.searchTerm(editor)));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.showWUDetails", this.showWUDetails));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntax", this.checkSyntax, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntaxAll", this.checkSyntaxAll, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.checkSyntaxClear", this.checkSyntaxClear, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.submit", this.submit, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.submitNoArchive", this.submitNoArchive, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.compile", this.compile, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.showLanguageReference", this.showLanguageReference, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.showStandardLibraryReference", this.showStandardLibraryReference, this));
ctx.subscriptions.push(vscode.commands.registerTextEditorCommand("ecl.searchTerm", this.searchTerm, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.showWUDetails", this.showWUDetails, this));
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));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.sign", this.sign));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.verify", this.verify));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.importModFile", this.importModFile));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.copyAsEclID", this.copyAsEclID));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.openECLWatchExternal", this.openECLWatchExternal, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.insertRecordDef", this.insertRecordDef, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.sign", this.sign, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.verify", this.verify, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.importModFile", this.importModFile, this));
ctx.subscriptions.push(vscode.commands.registerCommand("ecl.copyAsEclID", this.copyAsEclID, this));
}

static attach(ctx: vscode.ExtensionContext): ECLCommands {
Expand Down Expand Up @@ -86,30 +87,43 @@ export class ECLCommands {
}
}

private ECLR_EN_US = "https://hpccsystems.com/wp-content/uploads/_documents/ECLR_EN_US";
showLanguageReference() {
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse("https://hpccsystems.com/wp-content/uploads/2022/_documents/ECLR_EN_US/index.html"));
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(`${this.ECLR_EN_US}/index.html`));
}

protected _html;
private SLR_EN_US = "https://hpccsystems.com/wp-content/uploads/_documents/SLR_EN_US";
showStandardLibraryReference() {
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(`${this.SLR_EN_US}/index.html`));
}

async parseIndex(url: string): Promise<[string, string, string, string][]> {
return fetch(`${url}/index.html`)
.then(response => response.text())
.then(html => [...html.matchAll(/<a\s+href="([^"]+)">([^<]+)<\/a>/g)])
.then(matches => matches.map(row => {
const cleaned = row[2].split("\n").map(str => str.trim()).join(" ");
return [row[0], row[1], cleaned, url];
}));
}

protected _html: Promise<[string, string, string, string][]>;
searchTerm(editor: vscode.TextEditor) {
if (vscode.window.activeTextEditor) {
const range = vscode.window.activeTextEditor.document.getWordRangeAtPosition(editor.selection.active);
const searchTerm = editor.document.getText(range);
if (!this._html) {
this._html = fetch("https://hpccsystems.com/wp-content/uploads/2022/_documents/ECLR_EN_US/index.html")
.then(response => response.text())
.then(html => [...html.matchAll(/<a href="(.*)">([\s\S]*?)<\/a>/g)])
.then(matches => matches.map(row => {
const cleaned = row[2].split("\n").map(str => str.trim()).join(" ");
return [row[0], row[1], cleaned];
}))
;
const langRef = this.parseIndex(this.ECLR_EN_US);
const stdLib = this.parseIndex(this.SLR_EN_US);
this._html = Promise.all([langRef, stdLib]).then(([langRef, stdLib]) => {
return langRef.concat(stdLib);
});
}
this._html.then(async (links: [string, string, string][]) => {
this._html.then(async (links: [string, string, string, string][]) => {
const matches = links.filter(row => row[2].toLowerCase().indexOf(searchTerm.toLowerCase()) >= 0);
const picked = await vscode.window.showQuickPick(matches.map(row => ({ label: row[2], row })), { canPickMany: false });
if (picked) {
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(`https://hpccsystems.com/wp-content/uploads/2022/_documents/ECLR_EN_US/${picked.row[1]}`));
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(`${picked.row[3]}/${picked.row[1]}`));
}
});
}
Expand Down

0 comments on commit ae5f745

Please sign in to comment.