Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/src/types/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export type StateRefinementError = BaseDiagnostic & {
category: 'error';
type: 'state-refinement-error';
translationTable: TranslationTable;
expected: string;
found: string;
expected: ValDerivationNode;
found: ValDerivationNode;
customMessage: string;
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/webview/views/context/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { escapeHtml } from "../../utils";
import { renderToggleSection, renderHighlightButton, renderDiagnosticRevealButton } from "../sections";

export function renderContextVariables(variables: LJVariable[], isExpanded: boolean, errorAtCursor?: RefinementMismatchError): string {
const expected = errorAtCursor ? errorAtCursor.type == "refinement-error" ? errorAtCursor.expected.value : errorAtCursor.expected : undefined;
const expected = errorAtCursor ? errorAtCursor.expected.value : undefined;
return /*html*/`
<div class="context-section">
${renderToggleSection('Variables', 'context-vars', isExpanded)}
Expand Down
7 changes: 4 additions & 3 deletions client/src/webview/views/diagnostics/derivation-nodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LJError, RefinementError } from "../../../types/diagnostics";
import type { LJError, RefinementMismatchError } from "../../../types/diagnostics";
import type { DerivationNode, ValDerivationNode } from "../../../types/derivation-nodes";
import { renderHighlightedExpression, renderHighlightedInlineExpression } from "../../highlighting";
import { escapeHtml } from "../../utils";
Expand All @@ -19,7 +19,7 @@ function renderToken(token: string): string {
}

function renderJsonTree(
error: RefinementError,
error: RefinementMismatchError,
node: DerivationNode | undefined,
errorId: string,
path: string,
Expand Down Expand Up @@ -123,10 +123,11 @@ export function handleDerivationResetClick(target?: any): boolean {
}

export function renderDerivationNode(
error: RefinementError,
error: RefinementMismatchError,
node: ValDerivationNode,
scope: "expected" | "found"
): string {
if (!node || typeof node !== "object" || !("value" in node)) return renderHighlightedExpression(String(node)); // primitive value without derivation
if (!node.origin) return renderHighlightedExpression(String(node.value)); // no derivation available

const errorId = hashError(error, scope);
Expand Down
4 changes: 2 additions & 2 deletions client/src/webview/views/diagnostics/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const errorContentRenderers: Partial<Record<LJError['type'], (error: LJError) =>
${e.counterexample ? renderExpressionSection('Counterexample', e.counterexample) : ''}
`,
'state-refinement-error': (e: StateRefinementError) => /*html*/`
${renderExpressionSection('Expected', e.expected)}
${renderExpressionSection('Found', e.found)}
${renderCustomSection('Expected', renderDerivationNode(e, e.expected, 'expected'))}
${renderCustomSection('Found', renderDerivationNode(e, e.found, 'found'))}
`,
'invalid-refinement-error': (e: InvalidRefinementError) => /*html*/`
${renderExpressionSection('Refinement', e.refinement)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import dtos.diagnostics.SourcePositionDTO;
import dtos.diagnostics.TranslationTableDTO;
import liquidjava.diagnostics.errors.StateRefinementError;
import liquidjava.rj_language.opt.derivation_node.ValDerivationNode;

/**
* DTO for serializing StateRefinementError instances to JSON
*/
public record StateRefinementErrorDTO(String category, String type, String title, String message, String file, SourcePositionDTO position,
TranslationTableDTO translationTable, String expected, String found, String customMessage) {
TranslationTableDTO translationTable, ValDerivationNode expected, ValDerivationNode found, String customMessage) {

public static StateRefinementErrorDTO from(StateRefinementError error) {
return new StateRefinementErrorDTO("error", "state-refinement-error", error.getTitle(), error.getMessage(), error.getFile(),
Expand Down