@@ -170,34 +170,38 @@ export class DbQueryGraph extends BaseGraph<DbQueryState> {
170170 }
171171
172172 private _mergeValidationResults ( state : DbQueryState ) {
173- const hasSyntacticFailure =
174- state . syntacticStatus && state . syntacticStatus !== EvaluationResult . Pass ;
175- const hasSemanticFailure =
176- state . semanticStatus && state . semanticStatus !== EvaluationResult . Pass ;
173+ const hasSyntacticFailure = this . _isValidationFailure (
174+ state . syntacticStatus ,
175+ ) ;
176+ const hasSemanticFailure = this . _isValidationFailure ( state . semanticStatus ) ;
177177
178178 if ( ! hasSyntacticFailure && ! hasSemanticFailure ) {
179179 return this . _buildPassedResult ( state ) ;
180180 }
181181
182+ return this . _buildFailedResult ( state , hasSyntacticFailure ) ;
183+ }
184+
185+ private _isValidationFailure ( status : DbQueryState [ 'syntacticStatus' ] ) {
186+ return ! ! status && status !== EvaluationResult . Pass ;
187+ }
188+
189+ private _buildFailedResult (
190+ state : DbQueryState ,
191+ hasSyntacticFailure : boolean ,
192+ ) {
182193 const clearedState = this . _buildClearedState ( state ) ;
183194 const baseFeedbacks = state . feedbacks ?? [ ] ;
184195 const semanticFb = this . _toArray ( state . semanticFeedback ) ;
185-
186- if ( hasSyntacticFailure ) {
187- return {
188- status : state . syntacticStatus ,
189- feedbacks : [
190- ...baseFeedbacks ,
191- ...this . _toArray ( state . syntacticFeedback ) ,
192- ...semanticFb ,
193- ] ,
194- ...clearedState ,
195- } ;
196- }
196+ const syntacticFb = hasSyntacticFailure
197+ ? this . _toArray ( state . syntacticFeedback )
198+ : [ ] ;
197199
198200 return {
199- status : state . semanticStatus ,
200- feedbacks : [ ...baseFeedbacks , ...semanticFb ] ,
201+ status : hasSyntacticFailure
202+ ? state . syntacticStatus
203+ : state . semanticStatus ,
204+ feedbacks : [ ...baseFeedbacks , ...syntacticFb , ...semanticFb ] ,
201205 ...clearedState ,
202206 } ;
203207 }
0 commit comments