@@ -103,6 +103,7 @@ class Parser extends Tapable {
103103 importCall : new SyncBailHook ( [ "expression" ] ) ,
104104 call : new HookMap ( ( ) => new SyncBailHook ( [ "expression" ] ) ) ,
105105 callAnyMember : new HookMap ( ( ) => new SyncBailHook ( [ "expression" ] ) ) ,
106+ new : new HookMap ( ( ) => new SyncBailHook ( [ "expression" ] ) ) ,
106107 expression : new HookMap ( ( ) => new SyncBailHook ( [ "expression" ] ) ) ,
107108 expressionAnyMember : new HookMap ( ( ) => new SyncBailHook ( [ "expression" ] ) ) ,
108109 program : new SyncBailHook ( [ "ast" , "comments" ] ) ,
@@ -126,6 +127,7 @@ class Parser extends Tapable {
126127 expressionConditionalOperator : / ^ e x p r e s s i o n \? : $ / ,
127128 callAnyMember : / ^ c a l l ( .+ ) \. \* $ / ,
128129 call : / ^ c a l l ( .+ ) $ / ,
130+ new : / ^ n e w ( .+ ) $ / ,
129131 expressionAnyMember : / ^ e x p r e s s i o n ( .+ ) \. \* $ / ,
130132 expression : / ^ e x p r e s s i o n ( .+ ) $ / ,
131133 } ;
@@ -1200,6 +1202,17 @@ class Parser extends Tapable {
12001202 }
12011203
12021204 walkNewExpression ( expression ) {
1205+ const callee = this . evaluateExpression ( expression . callee ) ;
1206+ if ( callee . isIdentifier ( ) ) {
1207+ const hook = this . hooks . new . for ( callee . identifier ) ;
1208+ if ( hook !== undefined ) {
1209+ const result = hook . call ( expression ) ;
1210+ if ( result === true ) {
1211+ return ;
1212+ }
1213+ }
1214+ }
1215+
12031216 this . walkExpression ( expression . callee ) ;
12041217 if ( expression . arguments )
12051218 this . walkExpressions ( expression . arguments ) ;
0 commit comments