Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/candidate-0.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonSmith committed Jan 17, 2018
2 parents a5a8dbe + 66410d1 commit 035b584
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out
node_modules
.vscode-test
*.vsix
*.vsix
*.log
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,33 @@ This extension adds rich language support for the ECL language to VS Code, inclu
The following Visual Studio Code settings are available for the ECL extension. These can be set in user preferences (`cmd+,`) or workspace settings (`.vscode/settings.json`):

```javascript
// Run 'eclcc -fsytnax' on save.
"ecl.syntaxCheckOnSave": true,
// Syntax check args.
"ecl.syntaxArgs": ["-syntax"],

// External folders used by IMPORT
"ecl.includeFolders": [],
// Run 'eclcc -syntax' on save.
"ecl.syntaxCheckOnSave": true

// Run 'eclcc -syntax' on load.
"ecl.syntaxCheckOnLoad": true

// External folders used by IMPORT
"ecl.includeFolders": []

// Override eclcc auto detection
"ecl.eclccPath": "",
"ecl.eclccPath": ""

// Add '-legacy' arguement to eclcc.
"ecl.legacyMode": false,
"ecl.legacyMode": false

// Open workunits in external browser.
"ecl.WUOpenExternal": false

// Automatically open WU in browser on creation.
"ecl.WUAutoOpen": false

// Debug logging.
"ecl.debugLogging": false

```

#### Launch Settings
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ecl",
"version": "0.0.23",
"version": "0.0.25",
"publisher": "GordonSmith",
"description": "ECL (Enterprise Control Language) support for Visual Studio Code",
"author": {
Expand Down Expand Up @@ -331,10 +331,25 @@
"type": "object",
"title": "ECL configuration",
"properties": {
"ecl.syntaxArgs": {
"type": "array",
"items": {
"type": "string"
},
"default": [
"-syntax"
],
"description": "eclcc syntax check arguments."
},
"ecl.syntaxCheckOnSave": {
"type": "boolean",
"default": true,
"description": "Run 'eclcc -fsytnax' on save."
"description": "Run 'eclcc -syntax' on save."
},
"ecl.syntaxCheckOnLoad": {
"type": "boolean",
"default": true,
"description": "Run 'eclcc -syntax' on load."
},
"ecl.includeFolders": {
"type": "array",
Expand Down Expand Up @@ -390,6 +405,11 @@
},
"default": [],
"description": "HPCC Servers"
},
"ecl.debugLogging": {
"type": "boolean",
"default": false,
"description": "Debug level logging (requires restart)"
}
}
}
Expand Down
28 changes: 20 additions & 8 deletions src/eclCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { scopedLogger } from "@hpcc-js/util";
import * as fs from "fs";
import * as path from "path";
import * as vscode from "vscode";
import { eclDiagnosticCollection } from "./eclDiagnostic";
import { eclDiagnostic } from "./eclDiagnostic";

const logger = scopedLogger("debugger/ECLDEbugSession.ts");

Expand Down Expand Up @@ -37,17 +37,20 @@ export function check(fileUri: vscode.Uri, eclConfig: vscode.WorkspaceConfigurat
if (!clientTools) {
throw new Error();
} else if (!!eclConfig["syntaxCheckOnSave"]) {
logger.debug(`syntaxCheck: ${fileUri.fsPath}`);
return clientTools.syntaxCheck(fileUri.fsPath).then(errors => {
logger.debug(`syntaxCheck-promise: ${fileUri.fsPath}`);
return clientTools.syntaxCheck(fileUri.fsPath, eclConfig.get<string[]>("syntaxArgs")).then(errors => {
if (errors[1].length) {
logger.warning(`syntaxCheck: ${errors[1].toString()}`);
logger.warning(`syntaxCheck-warning: ${fileUri.fsPath} ${errors[1].toString()}`);
}
logger.debug(`syntaxCheck-resolve: ${fileUri.fsPath} ${errors[0].length} total.`);
return errors[0];
}).catch(e => {
logger.debug(`syntaxCheck-reject: ${fileUri.fsPath} ${e.msg}`);
vscode.window.showInformationMessage(`Syntax check exception: ${fileUri.fsPath} ${e.msg}`);
return Promise.resolve([]);
});
}
logger.debug(`syntaxCheck-skipped: ${fileUri.fsPath}`);
return Promise.resolve([]);
}).catch(e => {
vscode.window.showInformationMessage('Unable to locate "eclcc" binary. Ensure ECL ClientTools is installed.');
Expand All @@ -63,9 +66,17 @@ function mapSeverityToVSCodeSeverity(sev: string) {
}
}

const checking = [new vscode.Diagnostic(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)), "...checking...")];
export function checkUri(uri: vscode.Uri, eclConfig: vscode.WorkspaceConfiguration): Promise<void> {
if (uri) {
const wsf = vscode.workspace.getWorkspaceFolder(uri);
if (wsf) {
vscode.window.setStatusBarMessage(`Syntax Check: ${path.relative(wsf.uri.fsPath, uri.fsPath)}`);
}
}
eclDiagnostic.set(uri, checking);
return check(uri, eclConfig).then((errors) => {
eclDiagnosticCollection.delete(uri);
eclDiagnostic.set(uri, []);

const diagnosticMap: Map<string, vscode.Diagnostic[]> = new Map();

Expand All @@ -81,10 +92,13 @@ export function checkUri(uri: vscode.Uri, eclConfig: vscode.WorkspaceConfigurati
diagnosticMap.set(canonicalFile, diagnostics);
});
diagnosticMap.forEach((diags, file) => {
eclDiagnosticCollection.set(vscode.Uri.parse(file), diags);
eclDiagnostic.set(vscode.Uri.parse(file), diags);
});
vscode.window.setStatusBarMessage("");
}).catch((err) => {
eclDiagnostic.set(uri, []);
vscode.window.showInformationMessage("Error: " + err);
vscode.window.setStatusBarMessage("");
});
}

Expand Down Expand Up @@ -113,8 +127,6 @@ export async function checkWorkspace(wsf: vscode.WorkspaceFolder): Promise<void>
files.push(filePath);
});
for (const file of files) {
vscode.window.setStatusBarMessage(`Syntax Check: ${path.relative(wsf.uri.fsPath, file)}`);
await checkUri(vscode.Uri.file(file), vscode.workspace.getConfiguration("ecl", wsf.uri));
vscode.window.setStatusBarMessage("");
}
}
4 changes: 2 additions & 2 deletions src/eclCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as opn from "opn";
import * as vscode from "vscode";
import { checkTextDocument, checkWorkspace } from "./eclCheck";
import { eclDiagnosticCollection } from "./eclDiagnostic";
import { eclDiagnostic } from "./eclDiagnostic";
import { encodeLocation } from "./eclWatch";

export let eclCommands: ECLCommands;
Expand Down Expand Up @@ -42,7 +42,7 @@ export class ECLCommands {
}

syntaxCheckClear() {
eclDiagnosticCollection.clear();
eclDiagnostic.clear();
}

showLanguageReference() {
Expand Down
46 changes: 43 additions & 3 deletions src/eclDiagnostic.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
import * as vscode from "vscode";
import { checkTextDocument } from "./eclCheck";

export let eclDiagnosticCollection: vscode.DiagnosticCollection;
let eclDiagnosticCollection: vscode.DiagnosticCollection;
let _diagnosticCache: { [key: string]: vscode.Diagnostic[] | undefined } = {};

let eclDiagnostic: ECLDiagnostic;
export let eclDiagnostic: ECLDiagnostic;
export class ECLDiagnostic {
_ctx: vscode.ExtensionContext;
_activeTextEditor: vscode.Uri | undefined;

private constructor(ctx: vscode.ExtensionContext) {
this._ctx = ctx;
eclDiagnosticCollection = vscode.languages.createDiagnosticCollection("ecl");
ctx.subscriptions.push(eclDiagnosticCollection);

vscode.workspace.onDidCloseTextDocument(event => {
eclDiagnosticCollection.delete(event.uri);
this.delete(event.uri);
}, null, this._ctx.subscriptions);

vscode.window.onDidChangeActiveTextEditor((event: vscode.TextEditor) => {
if (this._activeTextEditor === event.document.uri) {
return;
}
if (this._activeTextEditor) {
delete this._activeTextEditor;
}
if (event) {
this._activeTextEditor = event.document.uri;
if (_diagnosticCache[this._activeTextEditor.toString()]) {
eclDiagnosticCollection.set(this._activeTextEditor, _diagnosticCache[this._activeTextEditor.toString()]);
} else {
const eclConfig = vscode.workspace.getConfiguration("ecl", event.document.uri);
if (eclConfig.get<boolean>("syntaxCheckOnLoad")) {
checkTextDocument(event.document, eclConfig);
}
}
}
});
}

static attach(ctx: vscode.ExtensionContext): ECLDiagnostic {
Expand All @@ -21,4 +45,20 @@ export class ECLDiagnostic {
}
return eclDiagnostic;
}

clear() {
eclDiagnosticCollection.clear();
_diagnosticCache = {};
delete this._activeTextEditor;
}

delete(uri: vscode.Uri) {
_diagnosticCache[uri.toString()] = eclDiagnosticCollection.get(uri) || [];
eclDiagnosticCollection.delete(uri);
}

set(uri: vscode.Uri, diagnostics: vscode.Diagnostic[]) {
_diagnosticCache[uri.toString()] = diagnostics;
eclDiagnosticCollection.set(uri, diagnostics);
}
}
9 changes: 0 additions & 9 deletions src/eclEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class ECLEditor {

this.visibleCheckSyntax();
this.onSaveWatcher();
this.onActiveWatcher();
ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(ECL_MODE, this._completionProvider, ".", '\"'));
ctx.subscriptions.push(vscode.languages.registerDefinitionProvider(ECL_MODE, this._definitionProvider));
}
Expand Down Expand Up @@ -51,12 +50,4 @@ export class ECLEditor {
}
}, null, this._ctx.subscriptions);
}

onActiveWatcher() {
vscode.window.onDidChangeActiveTextEditor(event => {
if (event && vscode.window.activeTextEditor) {
checkTextDocument(event.document, vscode.workspace.getConfiguration("ecl", vscode.window.activeTextEditor.document.uri));
}
});
}
}
4 changes: 3 additions & 1 deletion src/eclMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ECLTree } from "./eclTree";
import { ECLWatch } from "./eclWatch";
import { initLogger, Level } from "./util";

initLogger(Level.info);
const eclConfig = vscode.workspace.getConfiguration("ecl");

initLogger(eclConfig.get<boolean>("debugLogging") ? Level.debug : Level.info);

export function activate(ctx: vscode.ExtensionContext): void {
// ctx.subscriptions.push(vscode.languages.registerHoverProvider(ECL_MODE, new ECLHoverProvider()));
Expand Down

0 comments on commit 035b584

Please sign in to comment.