1- import { renderHeader , renderLocation , renderSection , renderCustomSection } from "./utils" ;
1+ import { renderHeader , renderLocation , renderSection , renderCustomSection , renderShowAllButton , renderTranslationTable } from "./utils" ;
2+ import { renderDerivationNode } from "./derivation-nodes" ;
23import {
34 ArgumentMismatchError ,
45 InvalidRefinementError ,
@@ -8,12 +9,10 @@ import {
89 StateConflictError ,
910 StateRefinementError ,
1011 SyntaxError ,
11-
12+ TranslationTable ,
1213} from "../../../types" ;
13- import { renderDerivationNode } from "./derivation-nodes" ;
14- import { renderShowAllButton } from "./show-all-button" ;
1514
16- export function getErrorsView ( errors : LJError [ ] , showAll : boolean , currentFile : string | undefined ) : string {
15+ export function getErrorsView ( errors : LJError [ ] , showAll : boolean , currentFile : string | undefined , expandedErrors : Set < number > ) : string {
1716 const displayDiagnostics = showAll ? errors : errors . filter ( error => error . file && error . file ?. toLowerCase ( ) === currentFile ?. toLowerCase ( ) ) ;
1817 const hiddenCount = errors . length - displayDiagnostics . length ;
1918 return /*html*/ `
@@ -25,11 +24,15 @@ export function getErrorsView(errors: LJError[], showAll: boolean, currentFile:
2524 <p class="info">${ `${ errors . length } error${ errors . length !== 1 ? 's were' : ' was' } found by the LiquidJava verifier.` } </p>
2625 <div class="content">
2726 <ul>
28- ${ displayDiagnostics . map ( ( error ) => /*html*/ `
27+ ${ displayDiagnostics . map ( ( error , index ) => {
28+ const errorIndex = errors . indexOf ( error ) ;
29+ const isExpanded = expandedErrors . has ( errorIndex ) ;
30+ return /*html*/ `
2931 <li class="diagnostic-item error-item">
30- ${ renderError ( error ) }
32+ ${ renderError ( error , errorIndex , isExpanded ) }
3133 </li>
32- ` ) . join ( "" ) }
34+ ` ;
35+ } ) . join ( "" ) }
3336 </ul>
3437 ${ hiddenCount > 0 ? `<p class="more-indicator">(+${ hiddenCount } error${ hiddenCount !== 1 ? 's' : '' } )</p>` : '' }
3538 </div>
@@ -63,9 +66,27 @@ const errorContentRenderers: Partial<Record<LJError['type'], (error: LJError) =>
6366 `
6467} ;
6568
66- export function renderError ( error : LJError ) : string {
69+ export function renderError ( error : LJError , errorIndex : number , isExpanded : boolean ) : string {
6770 const header = renderHeader ( error ) ;
6871 const content = errorContentRenderers [ error . type ] ?.( error ) ?? '' ;
6972 const location = renderLocation ( error ) ;
70- return /*html*/ `${ header } ${ content } ${ location } ` ;
73+ const extra = renderExtra ( error , errorIndex , isExpanded ) ;
74+ return /*html*/ `${ header } ${ content } ${ location } ${ extra } ` ;
7175}
76+
77+ function renderExtra ( error : LJError , errorIndex : number , isExpanded : boolean ) : string {
78+ const button = /*html*/ `
79+ <button class="show-more-button" data-error-index="${ errorIndex } " title="Toggle show extra information about the diagnostic">
80+ ${ isExpanded ? '↑' : '↓' }
81+ </button>
82+ ` ;
83+ if ( ! isExpanded ) return button ;
84+
85+ let extra = button ;
86+ extra += '<div class="extra-content">' ;
87+ if ( error . hasOwnProperty ( 'translationTable' ) ) {
88+ extra += renderTranslationTable ( ( error as any ) . translationTable as TranslationTable ) ;
89+ }
90+ extra += '</div>' ;
91+ return extra ;
92+ }
0 commit comments