1- import { renderDiagnosticDataAttributes , renderExpressionSection , renderDiagnosticHeader , renderSection , renderCustomSection , renderTranslationTable , renderLocation , } from "../sections" ;
1+ import { renderDiagnosticDataAttributes , renderExpressionSection , renderDiagnosticHeader , renderCustomSection , renderLocation , renderDiagnosticContextButton } from "../sections" ;
22import { renderDerivationNode } from "./derivation-nodes" ;
33import type {
44 ArgumentMismatchError ,
@@ -11,19 +11,18 @@ import type {
1111 StateConflictError ,
1212 StateRefinementError ,
1313 SyntaxError ,
14- TranslationTable ,
1514} from "../../../types/diagnostics" ;
1615import { renderCopyDiagnosticButton } from "./diagnostics" ;
1716
18- export function renderErrors ( errors : LJError [ ] , expandedErrors : Set < number > ) : string {
17+ export function renderErrors ( errors : LJError [ ] ) : string {
1918 return /*html*/ `
2019 <ul>
2120 ${ errors . map ( ( error , index ) => {
22- const isExpanded = expandedErrors . has ( index ) ;
2321 return /*html*/ `
2422 <li class="diagnostic-item error-item" ${ renderDiagnosticDataAttributes ( error ) } >
23+ ${ renderDiagnosticContextAction ( error ) }
2524 ${ renderCopyDiagnosticButton ( 'error' , index ) }
26- ${ renderError ( error , index , isExpanded ) }
25+ ${ renderError ( error ) }
2726 </li>
2827 ` ;
2928 } ) . join ( "" ) }
@@ -62,25 +61,15 @@ const errorContentRenderers: ErrorRendererMap = {
6261 'custom-error' : ( _ : CustomError ) => "" ,
6362} ;
6463
65- export function renderError ( error : LJError , errorIndex : number , isExpanded : boolean ) : string {
64+ export function renderError ( error : LJError ) : string {
6665 const message = error . type === 'refinement-error' || error . type === 'state-refinement-error' ? error . customMessage : error . message ;
6766 const header = renderDiagnosticHeader ( error . title , message || '' ) ;
6867 const content = ( errorContentRenderers [ error . type ] as ( error : LJError ) => string ) ?.( error ) || '' ;
6968 const location = renderLocation ( error ) ;
70- const extra = renderExtra ( error , errorIndex , isExpanded ) ;
71- return /*html*/ `${ header } ${ content } ${ location } ${ extra } ` ;
69+ return /*html*/ `${ header } ${ content } ${ location } ` ;
7270}
7371
74- function renderExtra ( error : LJError , errorIndex : number , isExpanded : boolean ) : string {
75- const button = /*html*/ `
76- <button class="show-more-button" data-error-index="${ errorIndex } " title="Toggle show extra information about the diagnostic">
77- ${ isExpanded ? '↑' : '↓' }
78- </button>
79- ` ;
80-
81- let extra = "" ;
82- if ( Object . prototype . hasOwnProperty . call ( error , 'translationTable' ) ) {
83- extra += renderTranslationTable ( ( error as any ) . translationTable as TranslationTable ) ;
84- }
85- return extra ? isExpanded ? /*html*/ `${ button } <div class="extra-content">${ extra } </div>` : button : "" ;
72+ function renderDiagnosticContextAction ( error : LJError ) : string {
73+ if ( error . type !== 'refinement-error' && error . type !== 'state-refinement-error' ) return "" ;
74+ return renderDiagnosticContextButton ( error . position ) ;
8675}
0 commit comments