@@ -1064,63 +1064,17 @@ class Parser extends Tapable {
1064
1064
}
1065
1065
1066
1066
prewalkVariableDeclaration ( statement ) {
1067
- if ( statement . declarations )
1068
- this . prewalkVariableDeclarators ( statement . declarations ) ;
1069
- }
1070
-
1071
- walkVariableDeclaration ( statement ) {
1072
- if ( statement . declarations )
1073
- this . walkVariableDeclarators ( statement . declarations ) ;
1074
- }
1075
-
1076
- prewalkClassDeclaration ( statement ) {
1077
- if ( statement . id ) {
1078
- this . scope . renames . set ( statement . id . name , null ) ;
1079
- this . scope . definitions . add ( statement . id . name ) ;
1080
- }
1081
- }
1082
-
1083
- walkClassDeclaration ( statement ) {
1084
- this . walkClass ( statement ) ;
1085
- }
1086
-
1087
- prewalkSwitchCases ( switchCases ) {
1088
- for ( let index = 0 , len = switchCases . length ; index < len ; index ++ ) {
1089
- const switchCase = switchCases [ index ] ;
1090
- this . prewalkStatements ( switchCase . consequent ) ;
1091
- }
1092
- }
1093
-
1094
- walkSwitchCases ( switchCases ) {
1095
- for ( let index = 0 , len = switchCases . length ; index < len ; index ++ ) {
1096
- const switchCase = switchCases [ index ] ;
1097
-
1098
- if ( switchCase . test ) {
1099
- this . walkExpression ( switchCase . test ) ;
1100
- }
1101
- this . walkStatements ( switchCase . consequent ) ;
1102
- }
1103
- }
1104
-
1105
- walkCatchClause ( catchClause ) {
1106
- this . inScope ( [ catchClause . param ] , ( ) => {
1107
- this . prewalkStatement ( catchClause . body ) ;
1108
- this . walkStatement ( catchClause . body ) ;
1109
- } ) ;
1110
- }
1111
-
1112
- prewalkVariableDeclarators ( declarators ) {
1113
- for ( const declarator of declarators ) {
1067
+ const hookMap = statement . kind === "const" ? this . hooks . varDeclarationConst :
1068
+ statement . kind === "let" ? this . hooks . varDeclarationLet :
1069
+ this . hooks . varDeclarationVar ;
1070
+ for ( const declarator of statement . declarations ) {
1114
1071
switch ( declarator . type ) {
1115
1072
case "VariableDeclarator" :
1116
1073
{
1117
1074
this . enterPattern ( declarator . id , ( name , decl ) => {
1118
- const hookMap = declarator . kind === "const" ? this . hooks . varDeclarationConst :
1119
- declarator . kind === "let" ? this . hooks . varDeclarationLet :
1120
- this . hooks . varDeclarationVar ;
1121
- const hook = hookMap . get ( name ) ;
1075
+ let hook = hookMap . get ( name ) ;
1122
1076
if ( hook === undefined || ! hook . call ( decl ) ) {
1123
- const hook = this . hooks . varDeclaration . get ( name ) ;
1077
+ hook = this . hooks . varDeclaration . get ( name ) ;
1124
1078
if ( hook === undefined || ! hook . call ( decl ) ) {
1125
1079
this . scope . renames . set ( name , null ) ;
1126
1080
this . scope . definitions . add ( name ) ;
@@ -1133,8 +1087,8 @@ class Parser extends Tapable {
1133
1087
}
1134
1088
}
1135
1089
1136
- walkVariableDeclarators ( declarators ) {
1137
- for ( const declarator of declarators ) {
1090
+ walkVariableDeclaration ( statement ) {
1091
+ for ( const declarator of statement . declarations ) {
1138
1092
switch ( declarator . type ) {
1139
1093
case "VariableDeclarator" :
1140
1094
{
@@ -1160,6 +1114,42 @@ class Parser extends Tapable {
1160
1114
}
1161
1115
}
1162
1116
1117
+ prewalkClassDeclaration ( statement ) {
1118
+ if ( statement . id ) {
1119
+ this . scope . renames . set ( statement . id . name , null ) ;
1120
+ this . scope . definitions . add ( statement . id . name ) ;
1121
+ }
1122
+ }
1123
+
1124
+ walkClassDeclaration ( statement ) {
1125
+ this . walkClass ( statement ) ;
1126
+ }
1127
+
1128
+ prewalkSwitchCases ( switchCases ) {
1129
+ for ( let index = 0 , len = switchCases . length ; index < len ; index ++ ) {
1130
+ const switchCase = switchCases [ index ] ;
1131
+ this . prewalkStatements ( switchCase . consequent ) ;
1132
+ }
1133
+ }
1134
+
1135
+ walkSwitchCases ( switchCases ) {
1136
+ for ( let index = 0 , len = switchCases . length ; index < len ; index ++ ) {
1137
+ const switchCase = switchCases [ index ] ;
1138
+
1139
+ if ( switchCase . test ) {
1140
+ this . walkExpression ( switchCase . test ) ;
1141
+ }
1142
+ this . walkStatements ( switchCase . consequent ) ;
1143
+ }
1144
+ }
1145
+
1146
+ walkCatchClause ( catchClause ) {
1147
+ this . inScope ( [ catchClause . param ] , ( ) => {
1148
+ this . prewalkStatement ( catchClause . body ) ;
1149
+ this . walkStatement ( catchClause . body ) ;
1150
+ } ) ;
1151
+ }
1152
+
1163
1153
walkPattern ( pattern ) {
1164
1154
switch ( pattern . type ) {
1165
1155
case "ArrayPattern" :
0 commit comments