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