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) {
336336 this . swapLocations ( buffer , buffer . left , buffer . right , parser ) ;
337337 result = buffer ;
338338 }
339+ } else if ( result . kind === "expressionstatement" ) {
340+ this . swapLocations ( result , result . expression , result , parser ) ;
339341 }
340342 return result ;
341343} ;
Original file line number Diff line number Diff line change @@ -435,11 +435,11 @@ Program {
435435 " line" : 3 ,
436436 " offset" : 18 ,
437437 },
438- " source" : " ();" ,
438+ " source" : " foo ();" ,
439439 " start" : Position {
440- " column" : 3 ,
440+ " column" : 0 ,
441441 " line" : 3 ,
442- " offset" : 15 ,
442+ " offset" : 12 ,
443443 },
444444 },
445445 },
@@ -528,11 +528,11 @@ Program {
528528 " line" : 5 ,
529529 " offset" : 45 ,
530530 },
531- " source" : " () /* inner */ ;" ,
531+ " source" : " bar () /* inner */ ;" ,
532532 " start" : Position {
533- " column" : 3 ,
533+ " column" : 0 ,
534534 " line" : 5 ,
535- " offset" : 29 ,
535+ " offset" : 26 ,
536536 },
537537 },
538538 " trailingComments" : Array [
Original file line number Diff line number Diff line change @@ -10026,6 +10026,79 @@ Program {
1002610026}
1002710027` ;
1002810028
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+
1002910102exports [` Test locations static 1` ] = `
1003010103Program {
1003110104 " children" : Array [
@@ -12483,11 +12556,11 @@ Program {
1248312556 " line" : 1 ,
1248412557 " offset" : 14 ,
1248512558 },
12486- " source" : " (...$var);" ,
12559+ " source" : " call (...$var);" ,
1248712560 " start" : Position {
12488- " column" : 4 ,
12561+ " column" : 0 ,
1248912562 " line" : 1 ,
12490- " offset" : 4 ,
12563+ " offset" : 0 ,
1249112564 },
1249212565 },
1249312566 },
Original file line number Diff line number Diff line change @@ -1168,4 +1168,14 @@ string";`,
11681168 } )
11691169 ) . toMatchSnapshot ( ) ;
11701170 } ) ;
1171+ it ( "single call" , function ( ) {
1172+ expect (
1173+ parser . parseEval ( `call();` , {
1174+ ast : {
1175+ withPositions : true ,
1176+ withSource : true
1177+ }
1178+ } )
1179+ ) . toMatchSnapshot ( ) ;
1180+ } ) ;
11711181} ) ;
You can’t perform that action at this time.
0 commit comments