Skip to content

Commit 766ee98

Browse files
authored
Merge pull request #322 from tlaplus/tlaps-proof-state-v2
Adapt to changes in the lsp server.
2 parents 56daa35 + 829a87a commit 766ee98

36 files changed

+521
-254
lines changed

esbuild.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ const webviewConfig = {
5050
}
5151
};
5252

53+
/** @type BuildOptions */
54+
const webviewCurrentProofStepConfig = {
55+
...baseConfig,
56+
target: 'es2020',
57+
format: 'esm',
58+
tsconfig: 'tsconfig.webview.json',
59+
entryPoints: ['./src/webview/current-proof-step/main.tsx'],
60+
outfile: './out/current-proof-step.js',
61+
loader: {
62+
'.ttf': 'copy', // use the file loader to handle .ttf files
63+
}
64+
};
65+
5366
const watchPlugin = (name) => [{
5467
name: 'watch-plugin',
5568
setup(build) {
@@ -66,11 +79,16 @@ const watchPlugin = (name) => [{
6679
(await context({...extensionConfig, plugins: watchPlugin('extensionConfig')})).watch();
6780
(await context({...extensionBrowserConfig, plugins: watchPlugin('extensionBrowserConfig')})).watch();
6881
(await context({...webviewConfig, plugins: watchPlugin('webviewConfig')})).watch();
82+
(await context({
83+
...webviewCurrentProofStepConfig,
84+
plugins: watchPlugin('webviewCurrentProofStepConfig')
85+
})).watch();
6986
} else {
7087
// Build extension
7188
await build(extensionConfig);
7289
await build(extensionBrowserConfig);
7390
await build(webviewConfig);
91+
await build(webviewCurrentProofStepConfig);
7492
console.log('build complete');
7593
}
7694
} catch (err) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@
486486
"views": {
487487
"tlaplus": [
488488
{
489-
"id": "tlaplus.tlaps-current-proof-obligation",
490-
"name": "Current Proof Obligation",
489+
"id": "tlaplus.current-proof-step",
490+
"name": "Current Proof Step",
491491
"type": "webview"
492492
}
493493
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Icons for the TLAPS proof steps:
2+
- These icons are downloaded from <https://fonts.google.com/icons>.
3+
- The files with the suffix `-color` are manually edited to add the fill color.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

resources/images/tlaps-proof-state-failed.svg

Lines changed: 0 additions & 42 deletions
This file was deleted.

resources/images/tlaps-proof-state-missing.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/images/tlaps-proof-state-omitted.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/images/tlaps-proof-state-pending.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/images/tlaps-proof-state-progress.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

resources/images/tlaps-proof-state-proved.svg

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/common.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,24 @@ export async function exists(filePath: string): Promise<boolean> {
175175
fs.exists(filePath, (ex) => resolve(ex));
176176
});
177177
}
178+
179+
// This calls only the latest of the supplied functions per specified period.
180+
// Used to avoid overloading the environment with too frequent events.
181+
export class DelayedFn {
182+
private latest : (() => void) | null = null;
183+
constructor(private period: number) {}
184+
185+
public do(f : () => void) {
186+
const wasScheduled = !!this.latest;
187+
this.latest = f;
188+
if (!wasScheduled) {
189+
setTimeout(() => {
190+
const f = this.latest;
191+
this.latest = null;
192+
if (f) {
193+
f();
194+
}
195+
}, this.period);
196+
}
197+
}
198+
}

src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { TlaDeclarationsProvider, TlaDefinitionsProvider } from './declarations/
2727
import { TlaDocumentInfos } from './model/documentInfo';
2828
import { syncTlcStatisticsSetting, listenTlcStatConfigurationChanges } from './commands/tlcStatisticsCfg';
2929
import { TlapsClient } from './tlaps';
30-
import { TlapsProofObligationView } from './webview/tlapsCurrentProofObligationView';
30+
import { CurrentProofStepWebviewViewProvider } from './panels/currentProofStepWebviewViewProvider';
3131

3232
const TLAPLUS_FILE_SELECTOR: vscode.DocumentSelector = { scheme: 'file', language: LANG_TLAPLUS };
3333
const TLAPLUS_CFG_FILE_SELECTOR: vscode.DocumentSelector = { scheme: 'file', language: LANG_TLAPLUS_CFG };
@@ -44,7 +44,7 @@ let tlapsClient: TlapsClient | undefined;
4444
* Extension entry point.
4545
*/
4646
export function activate(context: vscode.ExtensionContext): void {
47-
const tlapsProofObligationView = new TlapsProofObligationView();
47+
const currentProofStepWebviewViewProvider = new CurrentProofStepWebviewViewProvider(context.extensionUri);
4848
diagnostic = vscode.languages.createDiagnosticCollection(LANG_TLAPLUS);
4949
context.subscriptions.push(
5050
vscode.commands.registerCommand(
@@ -92,7 +92,7 @@ export function activate(context: vscode.ExtensionContext): void {
9292
vscode.languages.registerCodeActionsProvider(
9393
TLAPLUS_FILE_SELECTOR,
9494
new TlaCodeActionProvider(),
95-
{ providedCodeActionKinds: [ vscode.CodeActionKind.Source ] }),
95+
{ providedCodeActionKinds: [vscode.CodeActionKind.Source] }),
9696
vscode.debug.registerDebugAdapterDescriptorFactory(
9797
LANG_TLAPLUS,
9898
new TLADebugAdapterServerDescriptorFactory()),
@@ -165,11 +165,13 @@ export function activate(context: vscode.ExtensionContext): void {
165165
}
166166
),
167167
vscode.window.registerWebviewViewProvider(
168-
TlapsProofObligationView.viewType,
169-
tlapsProofObligationView,
168+
CurrentProofStepWebviewViewProvider.viewType,
169+
currentProofStepWebviewViewProvider,
170170
)
171171
);
172-
tlapsClient = new TlapsClient(context, tlapsProofObligationView);
172+
tlapsClient = new TlapsClient(context, details => {
173+
currentProofStepWebviewViewProvider.showProofStepDetails(details);
174+
});
173175
syncTlcStatisticsSetting()
174176
.catch((err) => console.error(err))
175177
.then(() => listenTlcStatConfigurationChanges(context.subscriptions));

src/model/tlaps.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Location } from 'vscode-languageclient/node';
1+
import { Location, Range } from 'vscode-languageclient/node';
2+
3+
export interface CountByStepStatus {
4+
proved: number;
5+
failed: number;
6+
omitted: number;
7+
missing: number;
8+
pending: number;
9+
progress: number;
10+
}
211

312
export interface TlapsProofObligationResult {
413
prover: string;
@@ -9,7 +18,17 @@ export interface TlapsProofObligationResult {
918
}
1019

1120
export interface TlapsProofObligationState {
12-
location: Location;
13-
obligation: string;
21+
role: string;
22+
range: Range;
23+
status: string;
24+
normalized: string;
1425
results: TlapsProofObligationResult[];
1526
}
27+
28+
export interface TlapsProofStepDetails {
29+
kind: string;
30+
status: string;
31+
location: Location;
32+
obligations: TlapsProofObligationState[];
33+
sub_count: CountByStepStatus;
34+
}

0 commit comments

Comments
 (0)