File tree 4 files changed +137
-5
lines changed
4 files changed +137
-5
lines changed Original file line number Diff line number Diff line change @@ -178,10 +178,10 @@ module.exports = {
178
178
* ```
179
179
*/
180
180
read_constant_list : function ( flags ) {
181
+ const result = this . node ( "classconstant" ) ;
181
182
if ( this . expect ( this . tok . T_CONST ) ) {
182
183
this . next ( ) ;
183
184
}
184
- const result = this . node ( "classconstant" ) ;
185
185
const items = this . read_list (
186
186
/**
187
187
* Reads a constant declaration
Original file line number Diff line number Diff line change @@ -816,11 +816,11 @@ Program {
816
816
" line" : 31 ,
817
817
" offset" : 561 ,
818
818
},
819
- " source" : " FOOBAR = 'BARFOO'" ,
819
+ " source" : " const FOOBAR = 'BARFOO'" ,
820
820
" start" : Position {
821
- " column" : 10 ,
821
+ " column" : 4 ,
822
822
" line" : 31 ,
823
- " offset" : 544 ,
823
+ " offset" : 538 ,
824
824
},
825
825
},
826
826
" visibility" : " " ,
Original file line number Diff line number Diff line change @@ -10972,6 +10972,137 @@ Program {
10972
10972
}
10973
10973
` ;
10974
10974
10975
+ exports [` Test locations test start location for class constants 1` ] = `
10976
+ Program {
10977
+ " children" : Array [
10978
+ Class {
10979
+ " body" : Array [
10980
+ ClassConstant {
10981
+ " constants" : Array [
10982
+ Constant {
10983
+ " kind" : " constant" ,
10984
+ " loc" : Location {
10985
+ " end" : Position {
10986
+ " column" : 25 ,
10987
+ " line" : 1 ,
10988
+ " offset" : 25 ,
10989
+ },
10990
+ " source" : " bar = 1" ,
10991
+ " start" : Position {
10992
+ " column" : 18 ,
10993
+ " line" : 1 ,
10994
+ " offset" : 18 ,
10995
+ },
10996
+ },
10997
+ " name" : Identifier {
10998
+ " kind" : " identifier" ,
10999
+ " loc" : Location {
11000
+ " end" : Position {
11001
+ " column" : 21 ,
11002
+ " line" : 1 ,
11003
+ " offset" : 21 ,
11004
+ },
11005
+ " source" : " bar" ,
11006
+ " start" : Position {
11007
+ " column" : 18 ,
11008
+ " line" : 1 ,
11009
+ " offset" : 18 ,
11010
+ },
11011
+ },
11012
+ " name" : " bar" ,
11013
+ },
11014
+ " value" : Number {
11015
+ " kind" : " number" ,
11016
+ " loc" : Location {
11017
+ " end" : Position {
11018
+ " column" : 25 ,
11019
+ " line" : 1 ,
11020
+ " offset" : 25 ,
11021
+ },
11022
+ " source" : " 1" ,
11023
+ " start" : Position {
11024
+ " column" : 24 ,
11025
+ " line" : 1 ,
11026
+ " offset" : 24 ,
11027
+ },
11028
+ },
11029
+ " value" : " 1" ,
11030
+ },
11031
+ },
11032
+ ],
11033
+ " kind" : " classconstant" ,
11034
+ " loc" : Location {
11035
+ " end" : Position {
11036
+ " column" : 25 ,
11037
+ " line" : 1 ,
11038
+ " offset" : 25 ,
11039
+ },
11040
+ " source" : " const bar = 1" ,
11041
+ " start" : Position {
11042
+ " column" : 12 ,
11043
+ " line" : 1 ,
11044
+ " offset" : 12 ,
11045
+ },
11046
+ },
11047
+ " visibility" : " " ,
11048
+ },
11049
+ ],
11050
+ " extends" : null ,
11051
+ " implements" : null ,
11052
+ " isAbstract" : false ,
11053
+ " isAnonymous" : false ,
11054
+ " isFinal" : false ,
11055
+ " kind" : " class" ,
11056
+ " loc" : Location {
11057
+ " end" : Position {
11058
+ " column" : 28 ,
11059
+ " line" : 1 ,
11060
+ " offset" : 28 ,
11061
+ },
11062
+ " source" : " class foo { const bar = 1; }" ,
11063
+ " start" : Position {
11064
+ " column" : 0 ,
11065
+ " line" : 1 ,
11066
+ " offset" : 0 ,
11067
+ },
11068
+ },
11069
+ " name" : Identifier {
11070
+ " kind" : " identifier" ,
11071
+ " loc" : Location {
11072
+ " end" : Position {
11073
+ " column" : 9 ,
11074
+ " line" : 1 ,
11075
+ " offset" : 9 ,
11076
+ },
11077
+ " source" : " foo" ,
11078
+ " start" : Position {
11079
+ " column" : 6 ,
11080
+ " line" : 1 ,
11081
+ " offset" : 6 ,
11082
+ },
11083
+ },
11084
+ " name" : " foo" ,
11085
+ },
11086
+ },
11087
+ ],
11088
+ " errors" : Array [],
11089
+ " kind" : " program" ,
11090
+ " loc" : Location {
11091
+ " end" : Position {
11092
+ " column" : 28 ,
11093
+ " line" : 1 ,
11094
+ " offset" : 28 ,
11095
+ },
11096
+ " source" : " class foo { const bar = 1; }" ,
11097
+ " start" : Position {
11098
+ " column" : 0 ,
11099
+ " line" : 1 ,
11100
+ " offset" : 0 ,
11101
+ },
11102
+ },
11103
+ }
11104
+ ` ;
11105
+
10975
11106
exports [` Test locations test static 1` ] = `
10976
11107
Program {
10977
11108
" children" : Array [
Original file line number Diff line number Diff line change @@ -207,7 +207,8 @@ string";`
207
207
`
208
208
] ,
209
209
[ "assign []" , `$var[] = $var` ] ,
210
- [ "single call" , `call();` ]
210
+ [ "single call" , `call();` ] ,
211
+ [ "start location for class constants" , "class foo { const bar = 1; }" ]
211
212
] ) ( "test %s" , ( _ , code ) => {
212
213
expect (
213
214
parser . parseEval ( code , {
You can’t perform that action at this time.
0 commit comments