/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as mobxlite from 'mobx-react-lite'; import * as React from 'react'; import { EvaluationError } from '../stores/amlResults'; import { ISimulationTest } from '../stores/simulationTestsProvider'; import { DiffEditor } from './diffEditor'; export const ErrorComparison = mobxlite.observer( ({ test }: { test: ISimulationTest }) => { const errorsOnlyInBefore = test.errorsOnlyInBefore; const errorsOnlyInAfter = test.errorsOnlyInAfter; if ( !errorsOnlyInBefore || !errorsOnlyInAfter || !errorsOnlyInBefore.length || !errorsOnlyInAfter.length ) { return null; } const [expanded, setExpanded] = React.useState(false); return (
{'\n'}
setExpanded(!expanded)}> {expanded ? '▼' : '▶'} Error Comparison
{' '} {!expanded ? null : (

{`- Source: `} {errorsOnlyInBefore[0].tool}

{`- Number of errors that appear in the diagnostics strictly only before the change: `} {errorsOnlyInBefore.length}

{`- Number of errors that appear in the diagnostics strictly only after the change: `} {errorsOnlyInAfter.length}

{`- Diff of errors before and after : `}
)}
); } ); function errorText(errors: EvaluationError[]) { let errorText = ``; for (const error of errors) { errorText += [ `- Start Line : ${error.startLine}`, `- Start Column : ${error.startColumn}`, `- End line : ${error.endLine}`, `- End column : ${error.endColumn}`, `- Message : ${error.message}`, ].join('\n') + '\n\n'; } return errorText; }