File tree Expand file tree Collapse file tree 4 files changed +94
-9
lines changed Expand file tree Collapse file tree 4 files changed +94
-9
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,8 @@ AST.prototype.resolvePrecedence = function(result, parser) {
336
336
this . swapLocations ( buffer , buffer . left , buffer . right , parser ) ;
337
337
result = buffer ;
338
338
}
339
+ } else if ( result . kind === "expressionstatement" ) {
340
+ this . swapLocations ( result , result . expression , result , parser ) ;
339
341
}
340
342
return result ;
341
343
} ;
Original file line number Diff line number Diff line change @@ -435,11 +435,11 @@ Program {
435
435
" line" : 3 ,
436
436
" offset" : 18 ,
437
437
},
438
- " source" : " ();" ,
438
+ " source" : " foo ();" ,
439
439
" start" : Position {
440
- " column" : 3 ,
440
+ " column" : 0 ,
441
441
" line" : 3 ,
442
- " offset" : 15 ,
442
+ " offset" : 12 ,
443
443
},
444
444
},
445
445
},
@@ -528,11 +528,11 @@ Program {
528
528
" line" : 5 ,
529
529
" offset" : 45 ,
530
530
},
531
- " source" : " () /* inner */ ;" ,
531
+ " source" : " bar () /* inner */ ;" ,
532
532
" start" : Position {
533
- " column" : 3 ,
533
+ " column" : 0 ,
534
534
" line" : 5 ,
535
- " offset" : 29 ,
535
+ " offset" : 26 ,
536
536
},
537
537
},
538
538
" trailingComments" : Array [
Original file line number Diff line number Diff line change @@ -10026,6 +10026,79 @@ Program {
10026
10026
}
10027
10027
` ;
10028
10028
10029
+ exports [` Test locations single call 1` ] = `
10030
+ Program {
10031
+ " children" : Array [
10032
+ ExpressionStatement {
10033
+ " expression" : Call {
10034
+ " arguments" : Array [],
10035
+ " kind" : " call" ,
10036
+ " loc" : Location {
10037
+ " end" : Position {
10038
+ " column" : 7 ,
10039
+ " line" : 1 ,
10040
+ " offset" : 7 ,
10041
+ },
10042
+ " source" : " call();" ,
10043
+ " start" : Position {
10044
+ " column" : 0 ,
10045
+ " line" : 1 ,
10046
+ " offset" : 0 ,
10047
+ },
10048
+ },
10049
+ " what" : ClassReference {
10050
+ " kind" : " classreference" ,
10051
+ " loc" : Location {
10052
+ " end" : Position {
10053
+ " column" : 4 ,
10054
+ " line" : 1 ,
10055
+ " offset" : 4 ,
10056
+ },
10057
+ " source" : " call" ,
10058
+ " start" : Position {
10059
+ " column" : 0 ,
10060
+ " line" : 1 ,
10061
+ " offset" : 0 ,
10062
+ },
10063
+ },
10064
+ " name" : " call" ,
10065
+ " resolution" : " uqn" ,
10066
+ },
10067
+ },
10068
+ " kind" : " expressionstatement" ,
10069
+ " loc" : Location {
10070
+ " end" : Position {
10071
+ " column" : 7 ,
10072
+ " line" : 1 ,
10073
+ " offset" : 7 ,
10074
+ },
10075
+ " source" : " call();" ,
10076
+ " start" : Position {
10077
+ " column" : 0 ,
10078
+ " line" : 1 ,
10079
+ " offset" : 0 ,
10080
+ },
10081
+ },
10082
+ },
10083
+ ],
10084
+ " errors" : Array [],
10085
+ " kind" : " program" ,
10086
+ " loc" : Location {
10087
+ " end" : Position {
10088
+ " column" : 7 ,
10089
+ " line" : 1 ,
10090
+ " offset" : 7 ,
10091
+ },
10092
+ " source" : " call();" ,
10093
+ " start" : Position {
10094
+ " column" : 0 ,
10095
+ " line" : 1 ,
10096
+ " offset" : 0 ,
10097
+ },
10098
+ },
10099
+ }
10100
+ ` ;
10101
+
10029
10102
exports [` Test locations static 1` ] = `
10030
10103
Program {
10031
10104
" children" : Array [
@@ -12483,11 +12556,11 @@ Program {
12483
12556
" line" : 1 ,
12484
12557
" offset" : 14 ,
12485
12558
},
12486
- " source" : " (...$var);" ,
12559
+ " source" : " call (...$var);" ,
12487
12560
" start" : Position {
12488
- " column" : 4 ,
12561
+ " column" : 0 ,
12489
12562
" line" : 1 ,
12490
- " offset" : 4 ,
12563
+ " offset" : 0 ,
12491
12564
},
12492
12565
},
12493
12566
},
Original file line number Diff line number Diff line change @@ -1168,4 +1168,14 @@ string";`,
1168
1168
} )
1169
1169
) . toMatchSnapshot ( ) ;
1170
1170
} ) ;
1171
+ it ( "single call" , function ( ) {
1172
+ expect (
1173
+ parser . parseEval ( `call();` , {
1174
+ ast : {
1175
+ withPositions : true ,
1176
+ withSource : true
1177
+ }
1178
+ } )
1179
+ ) . toMatchSnapshot ( ) ;
1180
+ } ) ;
1171
1181
} ) ;
You can’t perform that action at this time.
0 commit comments