();
- constructor(private context: vscode.ExtensionContext) {
+ constructor(
+ private context: vscode.ExtensionContext,
+ private tlapsProofObligationView: TlapsProofObligationView,
+ ) {
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
'tlaplus.tlaps.check-step',
(te, ed, args) => {
@@ -130,6 +144,12 @@ export class TlapsClient {
'tlaplus/tlaps/proofStates',
this.proofStateNotifHandler.bind(this)
));
+ this.context.subscriptions.push(this.client.onNotification(
+ 'tlaplus/tlaps/currentProofObligation',
+ (oblState: TlapsProofObligationState) => {
+ this.tlapsProofObligationView.showProofObligation(oblState);
+ }
+ ));
this.client.start();
}
diff --git a/src/webview/tlapsCurrentProofObligationView.ts b/src/webview/tlapsCurrentProofObligationView.ts
new file mode 100644
index 0000000..c2c5a74
--- /dev/null
+++ b/src/webview/tlapsCurrentProofObligationView.ts
@@ -0,0 +1,66 @@
+import * as vscode from 'vscode';
+import { TlapsProofObligationState } from '../model/tlaps';
+import { URI } from 'vscode-uri';
+
+export class TlapsProofObligationView implements vscode.WebviewViewProvider {
+ public static readonly viewType = 'tlaplus.tlaps-current-proof-obligation';
+ private view?: vscode.WebviewView;
+ private oblState: TlapsProofObligationState | null = null;
+
+ public resolveWebviewView(
+ webviewView: vscode.WebviewView,
+ _context: vscode.WebviewViewResolveContext,
+ _token: vscode.CancellationToken,
+ ) {
+ this.view = webviewView;
+ this.show();
+ }
+
+ public showProofObligation(oblState: TlapsProofObligationState | null) {
+ this.oblState = oblState;
+ this.show();
+ }
+
+ private show() {
+ if (this.view) {
+ this.view.webview.html = this.makeHtml();
+ }
+ }
+
+ private makeHtml() {
+ const header =
+ `
+
+
+
+
+ Cat Coding
+
+ `;
+ const footer =
+ `
+ `;
+ let content = 'No obligation selected.
';
+ if (this.oblState) {
+ const loc = this.oblState.location;
+ const uri = URI.parse(loc.uri);
+ content = `${uri.path.split(/\/|\\/).pop()}
`;
+ if (loc.range.start.line === loc.range.end.line) {
+ content += `Line: ${loc.range.start.line}
`;
+ } else {
+ content += `Lines: ${loc.range.start.line}-${loc.range.end.line}
`;
+ }
+ if (this.oblState.results) {
+ content += '';
+ this.oblState.results.forEach(r => {
+ content += `- ${r.prover}: ${r.status}
`;
+ });
+ content += '
';
+ } else {
+ content += 'Not checked yet.
';
+ }
+ content += `${this.oblState.obligation}
`;
+ }
+ return header + content + footer;
+ }
+}