Skip to content

Commit

Permalink
Merge pull request #322 from tlaplus/tlaps-proof-state-v2
Browse files Browse the repository at this point in the history
Adapt to changes in the lsp server.
  • Loading branch information
kape1395 authored Jan 31, 2024
2 parents 56daa35 + 829a87a commit 766ee98
Show file tree
Hide file tree
Showing 36 changed files with 521 additions and 254 deletions.
18 changes: 18 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ const webviewConfig = {
}
};

/** @type BuildOptions */
const webviewCurrentProofStepConfig = {
...baseConfig,
target: 'es2020',
format: 'esm',
tsconfig: 'tsconfig.webview.json',
entryPoints: ['./src/webview/current-proof-step/main.tsx'],
outfile: './out/current-proof-step.js',
loader: {
'.ttf': 'copy', // use the file loader to handle .ttf files
}
};

const watchPlugin = (name) => [{
name: 'watch-plugin',
setup(build) {
Expand All @@ -66,11 +79,16 @@ const watchPlugin = (name) => [{
(await context({...extensionConfig, plugins: watchPlugin('extensionConfig')})).watch();
(await context({...extensionBrowserConfig, plugins: watchPlugin('extensionBrowserConfig')})).watch();
(await context({...webviewConfig, plugins: watchPlugin('webviewConfig')})).watch();
(await context({
...webviewCurrentProofStepConfig,
plugins: watchPlugin('webviewCurrentProofStepConfig')
})).watch();
} else {
// Build extension
await build(extensionConfig);
await build(extensionBrowserConfig);
await build(webviewConfig);
await build(webviewCurrentProofStepConfig);
console.log('build complete');
}
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@
"views": {
"tlaplus": [
{
"id": "tlaplus.tlaps-current-proof-obligation",
"name": "Current Proof Obligation",
"id": "tlaplus.current-proof-step",
"name": "Current Proof Step",
"type": "webview"
}
]
Expand Down
3 changes: 3 additions & 0 deletions resources/images/icons-material/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Icons for the TLAPS proof steps:
- These icons are downloaded from <https://fonts.google.com/icons>.
- The files with the suffix `-color` are manually edited to add the fill color.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 0 additions & 42 deletions resources/images/tlaps-proof-state-failed.svg

This file was deleted.

9 changes: 0 additions & 9 deletions resources/images/tlaps-proof-state-missing.svg

This file was deleted.

9 changes: 0 additions & 9 deletions resources/images/tlaps-proof-state-omitted.svg

This file was deleted.

9 changes: 0 additions & 9 deletions resources/images/tlaps-proof-state-pending.svg

This file was deleted.

9 changes: 0 additions & 9 deletions resources/images/tlaps-proof-state-progress.svg

This file was deleted.

41 changes: 0 additions & 41 deletions resources/images/tlaps-proof-state-proved.svg

This file was deleted.

21 changes: 21 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,24 @@ export async function exists(filePath: string): Promise<boolean> {
fs.exists(filePath, (ex) => resolve(ex));
});
}

// This calls only the latest of the supplied functions per specified period.
// Used to avoid overloading the environment with too frequent events.
export class DelayedFn {
private latest : (() => void) | null = null;
constructor(private period: number) {}

public do(f : () => void) {
const wasScheduled = !!this.latest;
this.latest = f;
if (!wasScheduled) {
setTimeout(() => {
const f = this.latest;
this.latest = null;
if (f) {
f();
}
}, this.period);
}
}
}
14 changes: 8 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { TlaDeclarationsProvider, TlaDefinitionsProvider } from './declarations/
import { TlaDocumentInfos } from './model/documentInfo';
import { syncTlcStatisticsSetting, listenTlcStatConfigurationChanges } from './commands/tlcStatisticsCfg';
import { TlapsClient } from './tlaps';
import { TlapsProofObligationView } from './webview/tlapsCurrentProofObligationView';
import { CurrentProofStepWebviewViewProvider } from './panels/currentProofStepWebviewViewProvider';

const TLAPLUS_FILE_SELECTOR: vscode.DocumentSelector = { scheme: 'file', language: LANG_TLAPLUS };
const TLAPLUS_CFG_FILE_SELECTOR: vscode.DocumentSelector = { scheme: 'file', language: LANG_TLAPLUS_CFG };
Expand All @@ -44,7 +44,7 @@ let tlapsClient: TlapsClient | undefined;
* Extension entry point.
*/
export function activate(context: vscode.ExtensionContext): void {
const tlapsProofObligationView = new TlapsProofObligationView();
const currentProofStepWebviewViewProvider = new CurrentProofStepWebviewViewProvider(context.extensionUri);
diagnostic = vscode.languages.createDiagnosticCollection(LANG_TLAPLUS);
context.subscriptions.push(
vscode.commands.registerCommand(
Expand Down Expand Up @@ -92,7 +92,7 @@ export function activate(context: vscode.ExtensionContext): void {
vscode.languages.registerCodeActionsProvider(
TLAPLUS_FILE_SELECTOR,
new TlaCodeActionProvider(),
{ providedCodeActionKinds: [ vscode.CodeActionKind.Source ] }),
{ providedCodeActionKinds: [vscode.CodeActionKind.Source] }),
vscode.debug.registerDebugAdapterDescriptorFactory(
LANG_TLAPLUS,
new TLADebugAdapterServerDescriptorFactory()),
Expand Down Expand Up @@ -165,11 +165,13 @@ export function activate(context: vscode.ExtensionContext): void {
}
),
vscode.window.registerWebviewViewProvider(
TlapsProofObligationView.viewType,
tlapsProofObligationView,
CurrentProofStepWebviewViewProvider.viewType,
currentProofStepWebviewViewProvider,
)
);
tlapsClient = new TlapsClient(context, tlapsProofObligationView);
tlapsClient = new TlapsClient(context, details => {
currentProofStepWebviewViewProvider.showProofStepDetails(details);
});
syncTlcStatisticsSetting()
.catch((err) => console.error(err))
.then(() => listenTlcStatConfigurationChanges(context.subscriptions));
Expand Down
25 changes: 22 additions & 3 deletions src/model/tlaps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Location } from 'vscode-languageclient/node';
import { Location, Range } from 'vscode-languageclient/node';

export interface CountByStepStatus {
proved: number;
failed: number;
omitted: number;
missing: number;
pending: number;
progress: number;
}

export interface TlapsProofObligationResult {
prover: string;
Expand All @@ -9,7 +18,17 @@ export interface TlapsProofObligationResult {
}

export interface TlapsProofObligationState {
location: Location;
obligation: string;
role: string;
range: Range;
status: string;
normalized: string;
results: TlapsProofObligationResult[];
}

export interface TlapsProofStepDetails {
kind: string;
status: string;
location: Location;
obligations: TlapsProofObligationState[];
sub_count: CountByStepStatus;
}
Loading

0 comments on commit 766ee98

Please sign in to comment.