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
9 changes: 4 additions & 5 deletions client/src/webview/views/diagnostics/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ export function renderErrors(errors: LJError[], expandedErrors: Set<number>): st

const errorContentRenderers: Partial<Record<LJError['type'], (error: LJError) => string>> = {
'refinement-error': (e: RefinementError) => /*html*/`
${e.customMessage ? renderSection('Message', e.customMessage) : ''}
${renderCustomSection('Expected', renderDerivationNode(e, e.expected, 'expected'))}
${renderCustomSection('Found', renderDerivationNode(e, e.found, 'found'))}
${e.counterexample ? renderSection('Counterexample', e.counterexample) : ''}
`,
'state-refinement-error': (e: StateRefinementError) => /*html*/`
${e.customMessage ? renderSection('Message', e.customMessage) : ''}
${renderSection('Expected', e.expected)}
${renderSection('Found', e.found)}
`,
Expand All @@ -58,8 +56,9 @@ const errorContentRenderers: Partial<Record<LJError['type'], (error: LJError) =>
};

export function renderError(error: LJError, errorIndex: number, isExpanded: boolean): string {
const header = renderDiagnosticHeader(error);
const content = errorContentRenderers[error.type]?.(error) ?? '';
const message = error.type === 'refinement-error' || error.type === 'state-refinement-error' ? error.customMessage : error.message;
const header = renderDiagnosticHeader(error.title, message || '');
const content = errorContentRenderers[error.type]?.(error) || '';
const location = renderLocation(error);
const extra = renderExtra(error, errorIndex, isExpanded);
return /*html*/`${header}${content}${location}${extra}`;
Expand All @@ -77,4 +76,4 @@ function renderExtra(error: LJError, errorIndex: number, isExpanded: boolean): s
extra += renderTranslationTable((error as any).translationTable as TranslationTable);
}
return extra ? isExpanded ? /*html*/`${button}<div class="extra-content">${extra}</div>` : button : "";
}
}
2 changes: 1 addition & 1 deletion client/src/webview/views/diagnostics/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const warningContentRenderers: Partial<Record<LJWarning['type'], (warning: LJWar
};

export function renderWarning(warning: LJWarning): string {
const header = renderDiagnosticHeader(warning);
const header = renderDiagnosticHeader(warning.title, warning.message);
const content = warningContentRenderers[warning.type]?.(warning) ?? '';
const location = renderLocation(warning);
return /*html*/`${header}${content}${location}`;
Expand Down
4 changes: 2 additions & 2 deletions client/src/webview/views/sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const renderToggleSection = (title: string, targetId: string, isExpanded:
</button>
`;

export const renderDiagnosticHeader = (diagnostic: LJDiagnostic): string => /*html*/
`<h3>${diagnostic.title}</h3><div class="diagnostic-header"><p>${diagnostic.message}</p></div>`;
export const renderDiagnosticHeader = (title: string, message: string): string => /*html*/
`<h3>${title}</h3><div class="diagnostic-header"><p>${message}</p></div>`;

export const renderLocation = (diagnostic: LJDiagnostic): string => {
if (!diagnostic.position || !diagnostic.file) return "";
Expand Down