import { DiagnosticSeverity } from "vscode-languageserver" ; import { Range } from "vscode-languageserver-textdocument" ; import { ConditionPredicate , createMachine } from "xstate" ; import { DiagnosticGetter } from "../getDiagnostics" ; export const miscDiagnostics = ( machine , textDocument ) => { try { const config = machine . parseResult ?. toConfig ( ) ; if ( ! config ) return [ ] ; const guards = { } ; machine . introspectionResult ?. guards . lines . forEach ( ( cond ) => { guards [ cond . name ] = ( ) => true ; } ) ; const createdMachine = createMachine ( config , { guards , } ) ; createdMachine . transition ( createdMachine . initialState , { } ) ; } catch ( e ) { let range = { start : textDocument . positionAt ( machine . parseResult ?. ast ?. definition ?. node . start || 0 ) , end : textDocument . positionAt ( machine . parseResult ?. ast ?. definition ?. node . end || 0 ) , } ; return [ { message : e . message , range , severity : DiagnosticSeverity . Error , } , ] ; } return [ ] ; } ;