Skip to content

Commit 052baa4

Browse files
authored
Add VC Simplification Support (#95)
1 parent 70aa203 commit 052baa4

18 files changed

Lines changed: 278 additions & 240 deletions

client/src/types/derivation-nodes.ts

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

client/src/types/diagnostics.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { ValDerivationNode } from './derivation-nodes';
21
import type { Range } from './context';
2+
import type { VCSimplificationResult } from './vc-implications';
33

44
// Type definitions used for LiquidJava diagnostics
55

@@ -58,8 +58,8 @@ export type RefinementError = BaseDiagnostic & {
5858
category: 'error';
5959
type: 'refinement-error';
6060
translationTable: TranslationTable;
61-
expected: ValDerivationNode;
62-
found: ValDerivationNode;
61+
expected: string;
62+
found: VCSimplificationResult;
6363
customMessage: string;
6464
counterexample: string;
6565
}
@@ -75,8 +75,8 @@ export type StateRefinementError = BaseDiagnostic & {
7575
category: 'error';
7676
type: 'state-refinement-error';
7777
translationTable: TranslationTable;
78-
expected: ValDerivationNode;
79-
found: ValDerivationNode;
78+
expected: string;
79+
found: VCSimplificationResult;
8080
customMessage: string;
8181
}
8282

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type VCImplication = {
2+
name: string | null;
3+
type: string | null;
4+
predicate: string;
5+
next: VCImplication | null;
6+
}
7+
8+
export type VCSimplificationResult = {
9+
implication: VCImplication;
10+
origin: VCSimplificationResult | null;
11+
}

client/src/webview/script.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { handleDerivableNodeClick, handleDerivationResetClick } from "./views/diagnostics/derivation-nodes";
1+
import { handleVCImplicationStepClick } from "./views/diagnostics/vc-implications";
22
import { renderLoading } from "./views/loading";
33
import { renderStopped } from "./views/stopped";
44
import { renderStateMachineView } from "./views/fsm/fsm";
@@ -131,21 +131,11 @@ export function getScript(vscode: VSCodeApi, document: Document, window: Window)
131131
return;
132132
}
133133

134-
// derivation expansion click
135-
const derivableNode = target.closest?.('.derivable-node');
136-
if (derivableNode) {
134+
// VC implication simplification step buttons
135+
const vcImplicationStepButton = target.closest?.('.vc-step-btn');
136+
if (vcImplicationStepButton) {
137137
e.stopPropagation();
138-
if (handleDerivableNodeClick(derivableNode)) {
139-
updateView();
140-
}
141-
return;
142-
}
143-
144-
// derivation reset button
145-
const derivationResetButton = target.closest?.('.derivation-reset-btn');
146-
if (derivationResetButton) {
147-
e.stopPropagation();
148-
if (handleDerivationResetClick(derivationResetButton)) {
138+
if (handleVCImplicationStepClick(vcImplicationStepButton)) {
149139
updateView();
150140
}
151141
return;

client/src/webview/styles.ts

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -271,18 +271,6 @@ export function getStyles(): string {
271271
.link:hover {
272272
text-decoration: underline;
273273
}
274-
.node-var {
275-
color: var(--lj-token-identifier);
276-
}
277-
.node-value {
278-
color: var(--vscode-editor-foreground);
279-
}
280-
.node-number {
281-
color: var(--lj-token-number);
282-
}
283-
.node-boolean {
284-
color: var(--lj-token-boolean);
285-
}
286274
.lj-expression,
287275
.lj-expression-code {
288276
font-family: var(--vscode-editor-font-family);
@@ -334,19 +322,59 @@ export function getStyles(): string {
334322
.clickable:hover {
335323
font-weight: bold;
336324
}
337-
.derivation-container {
325+
.vc-container {
338326
display: flex;
339327
justify-content: space-between;
340-
align-items: center;
328+
align-items: flex-start;
341329
gap: 1rem;
330+
margin: 0.5rem 0;
342331
}
343-
.reset-btn {
332+
.vc-chain {
333+
flex: 1;
334+
display: flex;
335+
flex-direction: column;
336+
gap: 0.25rem;
337+
min-width: 0;
338+
}
339+
.vc-line {
340+
display: flex;
341+
align-items: flex-start;
342+
gap: 0.5rem;
343+
min-width: 0;
344+
}
345+
.vc-line-content {
346+
flex: 0 1 auto;
347+
min-width: 0;
348+
overflow-wrap: anywhere;
349+
}
350+
.vc-node {
351+
display: inline;
352+
padding: 0;
353+
border: none;
354+
background: none;
355+
color: var(--vscode-editor-foreground);
356+
font: inherit;
357+
text-align: left;
358+
}
359+
.vc-node:hover {
360+
background: none;
361+
}
362+
.vc-binder {
363+
color: var(--vscode-descriptionForeground);
364+
}
365+
.vc-step-controls {
366+
display: inline-flex;
367+
align-items: center;
368+
gap: 0.125rem;
369+
flex-shrink: 0;
370+
}
371+
.vc-step-btn {
344372
margin: 0;
345373
display: inline-flex;
346374
align-items: center;
347375
justify-content: center;
348-
width: 1.75rem;
349-
height: 1.75rem;
376+
width: 1.5rem;
377+
height: 1.25rem;
350378
padding: 0;
351379
background-color: transparent;
352380
color: var(--vscode-button-foreground);
@@ -357,12 +385,17 @@ export function getStyles(): string {
357385
flex-shrink: 0;
358386
opacity: 0.7;
359387
}
360-
.reset-btn:hover {
388+
.vc-step-btn .codicon {
389+
font-size: 1.5rem;
390+
}
391+
.vc-step-btn:hover {
361392
font-weight: bold;
362393
background-color: transparent;
394+
opacity: 1;
363395
}
364-
.reset-btn:disabled {
365-
opacity: 0.5;
396+
.vc-step-btn:disabled {
397+
cursor: default;
398+
opacity: 0.35;
366399
}
367400
button {
368401
padding: 0.2rem 0.6rem;

client/src/webview/views/context/variables.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { escapeHtml, getSimpleName } from "../../utils";
55
import { renderToggleSection, renderHighlightButton, renderDiagnosticRevealButton } from "../sections";
66

77
export function renderContextVariables(variables: LJVariable[], isExpanded: boolean, errorAtCursor?: RefinementMismatchError): string {
8-
const expected = errorAtCursor ? errorAtCursor.expected.value : undefined;
98
const relevantNames = new Set(Object.keys(errorAtCursor?.translationTable || {}));
109
return /*html*/`
1110
<div class="context-section">
@@ -33,7 +32,7 @@ export function renderContextVariables(variables: LJVariable[], isExpanded: bool
3332
<td><code>${renderHighlightedInlineExpression(variable.refinement)}</code></td>
3433
</tr>
3534
`}).join('')}
36-
${errorAtCursor ? renderFailingRefinement(errorAtCursor, expected!) : ''}
35+
${errorAtCursor ? renderFailingRefinement(errorAtCursor) : ''}
3736
</tbody>
3837
</table>
3938
`: '<p>No variables declared at the cursor position</p>'}
@@ -42,11 +41,11 @@ export function renderContextVariables(variables: LJVariable[], isExpanded: bool
4241
`;
4342
}
4443

45-
function renderFailingRefinement(errorAtCursor: RefinementMismatchError, expected: string): string {
44+
function renderFailingRefinement(errorAtCursor: RefinementMismatchError): string {
4645
return /*html*/`
4746
<tr>
4847
<td class="failing-refinement tooltip" colspan="2" data-tooltip="${escapeHtml(errorAtCursor.title)}">
49-
${renderDiagnosticRevealButton(errorAtCursor.position!, '⊢ ' + expected)}
48+
${renderDiagnosticRevealButton(errorAtCursor.position!, '⊢ ' + errorAtCursor.expected)}
5049
</td>
5150
</tr>
5251
`;

client/src/webview/views/diagnostics/derivation-nodes.ts

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

0 commit comments

Comments
 (0)