Unverified Commit 3135e394 authored by Nadim Kobeissi's avatar Nadim Kobeissi 💾
Browse files

Pretty print model

parent a09ac821
......@@ -7,4 +7,7 @@ dependencies:
clean:
@$(RM) -rf out
.PHONY: dependencies clean .vscode node_modules out src syntax
publish:
@vsce publish
.PHONY: dependencies clean publish .vscode node_modules out src syntax
......@@ -53,6 +53,10 @@
{
"command": "verifpal.path",
"title": "Verifpal: Show Path to Verifpal"
},
{
"command": "verifpal.format",
"title": "Verifpal: Format Model"
}
],
"configuration": {
......
......@@ -42,6 +42,7 @@ type PrincipalState struct {
*/
export default class VerifpalLib {
static execVerifpal(fileContents, args) {
return new Promise((resolve, reject) => {
let verifpalOutput = "";
......@@ -61,7 +62,9 @@ export default class VerifpalLib {
resolve(result);
}
});
verifpalProc.stdin.write(fileContents);
verifpalProc.stdin.write(
`${fileContents}${String.fromCharCode(0x04)}`
);
verifpalProc.stdin.end();
});
}
......@@ -250,5 +253,9 @@ export default class VerifpalLib {
return VerifpalLib.execVerifpal(fileContents, ['internal-json', 'prettyValue']);
}
static getPrettyPrint(fileContents: string) {
return VerifpalLib.execVerifpal(fileContents, ['internal-json', 'prettyPrint']);
}
static getCoverage(fileContents: string, fileName: string): any {}
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import {
'use strict';
import * as vscode from 'vscode';
import VerifpalLib from './VerifpalLib';
import { format } from 'url';
export function activate(context: vscode.ExtensionContext) {
if (!configGetEnabled()) {
......@@ -17,21 +19,32 @@ export function activate(context: vscode.ExtensionContext) {
}
context.subscriptions.push(
vscode.languages.registerHoverProvider([
{
language: 'verifpal',
scheme: 'file',
pattern: '**/*vp*'
}
], new HoverProvider())
vscode.languages.registerHoverProvider([{
language: 'verifpal',
scheme: 'file',
pattern: '**/*vp*'
}], new HoverProvider())
);
context.subscriptions.push(
vscode.commands.registerTextEditorCommand('verifpal.format', (editor, edit) => {
let fileContents = editor.document.getText();
let fullRange = new vscode.Range(0, 0, editor.document.lineCount, 0);
return VerifpalLib.getPrettyPrint(fileContents).then((result: string) => {
vscode.window.activeTextEditor!.edit((editBuilder) => {
console.log(result)
editBuilder.replace(fullRange, result);
});
});
})
);
const coverage = new CoverageProvider(context.subscriptions);
const refreshCoverage = () => {
coverage.toggleDecorations();
coverage.refreshCoverage();
//coverage.refreshCoverage();
};
const showVerifpalPath = () => {
vscode.window.showInformationMessage(`Verifpal path set to '${configDeterminePath()}'`);
}
......@@ -40,4 +53,4 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('verifpal.path', showVerifpalPath);
}
export function deactivate() {}
\ No newline at end of file
export function deactivate() { }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment