@@ -1064,63 +1064,17 @@ class Parser extends Tapable {
10641064 }
10651065
10661066 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 ) {
11141071 switch ( declarator . type ) {
11151072 case "VariableDeclarator" :
11161073 {
11171074 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 ) ;
11221076 if ( hook === undefined || ! hook . call ( decl ) ) {
1123- const hook = this . hooks . varDeclaration . get ( name ) ;
1077+ hook = this . hooks . varDeclaration . get ( name ) ;
11241078 if ( hook === undefined || ! hook . call ( decl ) ) {
11251079 this . scope . renames . set ( name , null ) ;
11261080 this . scope . definitions . add ( name ) ;
@@ -1133,8 +1087,8 @@ class Parser extends Tapable {
11331087 }
11341088 }
11351089
1136- walkVariableDeclarators ( declarators ) {
1137- for ( const declarator of declarators ) {
1090+ walkVariableDeclaration ( statement ) {
1091+ for ( const declarator of statement . declarations ) {
11381092 switch ( declarator . type ) {
11391093 case "VariableDeclarator" :
11401094 {
@@ -1160,6 +1114,42 @@ class Parser extends Tapable {
11601114 }
11611115 }
11621116
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+
11631153 walkPattern ( pattern ) {
11641154 switch ( pattern . type ) {
11651155 case "ArrayPattern" :
0 commit comments