@@ -62,6 +62,8 @@ class FunctionNode {
6262 this . strictTypingChecking = false ;
6363 this . fixIntegerDivisionAccuracy = null ;
6464 this . warnVarUsage = true ;
65+ this . onIstanbulCoverageVariable = null ;
66+ this . removeIstanbulCoverage = false ;
6567
6668 if ( settings ) {
6769 for ( const p in settings ) {
@@ -571,6 +573,8 @@ class FunctionNode {
571573 return null ;
572574 case 'IfStatement' :
573575 return this . getType ( ast . consequent ) ;
576+ case 'SequenceExpression' :
577+ return this . getType ( ast . expressions [ ast . expressions . length - 1 ] ) ;
574578 default :
575579 throw this . astErrorOutput ( `Unhandled getType Type "${ ast . type } "` , ast ) ;
576580 }
@@ -771,6 +775,8 @@ class FunctionNode {
771775 }
772776 return dependencies ;
773777 }
778+ case 'SequenceExpression' :
779+ return this . getDependencies ( ast . expressions , dependencies , isNotSafe ) ;
774780 default :
775781 throw this . astErrorOutput ( `Unhandled type ${ ast . type } in getDependencies` , ast ) ;
776782 }
@@ -827,6 +833,8 @@ class FunctionNode {
827833 'value[][][]' ,
828834 'value[][][][]' ,
829835 'value.value' ,
836+ 'value.value[]' , // istanbul coverage
837+ 'value.value[][]' , // istanbul coverage
830838 'value.thread.value' ,
831839 'this.thread.value' ,
832840 'this.output.value' ,
@@ -1144,12 +1152,28 @@ class FunctionNode {
11441152 astThisExpression ( ast , retArr ) {
11451153 return retArr ;
11461154 }
1155+ isIstanbulAST ( ast ) {
1156+ const variableSignature = this . getVariableSignature ( ast ) ;
1157+ return variableSignature === 'value.value[]' || variableSignature === 'value.value[][]' ;
1158+ }
11471159 astSequenceExpression ( sNode , retArr ) {
1148- for ( let i = 0 ; i < sNode . expressions . length ; i ++ ) {
1149- if ( i > 0 ) {
1150- retArr . push ( ',' ) ;
1160+ const { expressions } = sNode ;
1161+ const sequenceResult = [ ] ;
1162+ for ( let i = 0 ; i < expressions . length ; i ++ ) {
1163+ const expression = expressions [ i ] ;
1164+ if ( this . removeIstanbulCoverage ) {
1165+ if ( expression . type === 'UpdateExpression' && this . isIstanbulAST ( expression . argument ) ) {
1166+ continue ;
1167+ }
11511168 }
1152- this . astGeneric ( sNode . expressions , retArr ) ;
1169+ const expressionResult = [ ] ;
1170+ this . astGeneric ( expression , expressionResult ) ;
1171+ sequenceResult . push ( expressionResult . join ( '' ) ) ;
1172+ }
1173+ if ( sequenceResult . length > 1 ) {
1174+ retArr . push ( '(' , sequenceResult . join ( ',' ) , ')' ) ;
1175+ } else {
1176+ retArr . push ( sequenceResult [ 0 ] ) ;
11531177 }
11541178 return retArr ;
11551179 }
@@ -1185,6 +1209,12 @@ class FunctionNode {
11851209 * @returns {Array } the append retArr
11861210 */
11871211 astUpdateExpression ( uNode , retArr ) {
1212+ if ( this . removeIstanbulCoverage ) {
1213+ const signature = this . getVariableSignature ( uNode . argument ) ;
1214+ if ( this . isIstanbulAST ( uNode . argument ) ) {
1215+ return retArr ;
1216+ }
1217+ }
11881218 if ( uNode . prefix ) {
11891219 retArr . push ( uNode . operator ) ;
11901220 this . astGeneric ( uNode . argument , retArr ) ;
@@ -1398,8 +1428,28 @@ class FunctionNode {
13981428 signature : variableSignature ,
13991429 property : ast . property ,
14001430 } ;
1401- default :
1402- throw this . astErrorOutput ( 'Unexpected expression' , ast ) ;
1431+ case 'value.value[]' : // istanbul coverage
1432+ if ( this . removeIstanbulCoverage ) {
1433+ return { signature : variableSignature } ;
1434+ }
1435+ if ( this . onIstanbulCoverageVariable ) {
1436+ this . onIstanbulCoverageVariable ( ast . object . object . name ) ;
1437+ return {
1438+ signature : variableSignature
1439+ } ;
1440+ }
1441+ case 'value.value[][]' : // istanbul coverage
1442+ if ( this . removeIstanbulCoverage ) {
1443+ return { signature : variableSignature } ;
1444+ }
1445+ if ( this . onIstanbulCoverageVariable ) {
1446+ this . onIstanbulCoverageVariable ( ast . object . object . object . name ) ;
1447+ return {
1448+ signature : variableSignature
1449+ } ;
1450+ }
1451+ default :
1452+ throw this . astErrorOutput ( 'Unexpected expression' , ast ) ;
14031453 }
14041454 }
14051455
0 commit comments