@@ -68,12 +68,10 @@ function createSuperExpressionStatement(j) {
68
68
* @param {MethodDefinition } methodDefinition - MethodDefinition to replce instances from
69
69
* @returns {MethodDefinition }
70
70
*/
71
- function replaceSuperExpressions (
72
- j ,
73
- methodDefinition ,
74
- replaceWithUndefined ,
75
- isAction = false
76
- ) {
71
+ function replaceSuperExpressions ( j , methodDefinition , functionProp ) {
72
+ const replaceWithUndefined = functionProp . hasRuntimeData
73
+ ? ! functionProp . isOverridden
74
+ : false ;
77
75
const superExprs = j ( methodDefinition ) . find ( j . CallExpression , {
78
76
callee : {
79
77
type : "MemberExpression" ,
@@ -93,7 +91,9 @@ function replaceSuperExpressions(
93
91
} else {
94
92
let superMethodCall ;
95
93
const superMethodArgs = get ( superExpr , "value.arguments" ) || [ ] ;
96
- if ( isAction ) {
94
+ if ( functionProp . isComputed ) {
95
+ superMethodCall = j . memberExpression ( j . super ( ) , functionProp . key ) ;
96
+ } else if ( functionProp . isAction ) {
97
97
superMethodCall = j . callExpression (
98
98
j . memberExpression (
99
99
j . memberExpression (
@@ -131,24 +131,15 @@ function replaceSuperExpressions(
131
131
* @param {Decorator[] } decorators
132
132
* @returns {MethodDefinition[] }
133
133
*/
134
- function createMethodProp (
135
- j ,
136
- functionProp ,
137
- decorators = [ ] ,
138
- replaceWithUndefined = false ,
139
- isAction = false
140
- ) {
134
+ function createMethodProp ( j , functionProp , decorators = [ ] ) {
141
135
const propKind = functionProp . kind === "init" ? "method" : functionProp . kind ;
142
- if ( functionProp . hasRuntimeData ) {
143
- replaceWithUndefined = ! functionProp . isOverridden ;
144
- }
136
+
145
137
return withDecorators (
146
138
withComments (
147
139
replaceSuperExpressions (
148
140
j ,
149
141
j . methodDefinition ( propKind , functionProp . key , functionProp . value ) ,
150
- replaceWithUndefined ,
151
- isAction
142
+ functionProp
152
143
) ,
153
144
functionProp
154
145
) ,
@@ -232,16 +223,12 @@ function createActionDecoratedProps(j, actionsProp) {
232
223
const actionProps = get ( actionsProp , "value.properties" ) ;
233
224
const overriddenActions = get ( actionsProp , "overriddenActions" ) || [ ] ;
234
225
const actionDecorators = createIdentifierDecorators ( j ) ;
235
- return actionProps . map ( actionProp =>
236
- createMethodProp (
237
- j ,
238
- actionProp ,
239
- actionDecorators ,
240
- actionsProp . hasRuntimeData &&
241
- ! overriddenActions . includes ( actionProp . key . name ) ,
242
- true
243
- )
244
- ) ;
226
+ return actionProps . map ( actionProp => {
227
+ actionProp . isAction = true ;
228
+ actionProp . hasRuntimeData = actionsProp . hasRuntimeData ;
229
+ actionProp . isOverridden = overriddenActions . includes ( actionProp . key . name ) ;
230
+ return createMethodProp ( j , actionProp , actionDecorators ) ;
231
+ } ) ;
245
232
}
246
233
247
234
/**
@@ -258,6 +245,7 @@ function createCallExpressionProp(j, callExprProp) {
258
245
259
246
if ( lastArgType === "FunctionExpression" ) {
260
247
const functionExpr = {
248
+ isComputed : true ,
261
249
kind : callExprProp . kind ,
262
250
key : callExprProp . key ,
263
251
value : callExprLastArg ,
@@ -272,6 +260,7 @@ function createCallExpressionProp(j, callExprProp) {
272
260
] ;
273
261
} else if ( lastArgType === "ObjectExpression" ) {
274
262
const callExprMethods = callExprLastArg . properties . map ( callExprFunction => {
263
+ callExprFunction . isComputed = true ;
275
264
callExprFunction . kind = getPropName ( callExprFunction ) ;
276
265
callExprFunction . key = callExprProp . key ;
277
266
callExprFunction . value . params . shift ( ) ;
0 commit comments