@@ -16,7 +16,7 @@ const {
1616class EOProp {
1717 constructor ( eoProp ) {
1818 this . _prop = eoProp ;
19- this . decoratorNames = [ ] ;
19+ this . decorators = [ ] ;
2020 this . modifiers = [ ] ;
2121 this . decoratorArgs = { } ;
2222 }
@@ -27,9 +27,20 @@ class EOProp {
2727
2828 get kind ( ) {
2929 let kind = get ( this . _prop , 'kind' ) ;
30- if ( kind === 'init' && this . hasDecorators && ! this . hasMethodDecorator ) {
30+ let method = get ( this . _prop , 'method' ) ;
31+
32+ if (
33+ kind === 'init' &&
34+ this . hasDecorators &&
35+ this . decorators . find ( d => d . importedName === 'computed' )
36+ ) {
3137 kind = 'get' ;
3238 }
39+
40+ if ( method || this . hasMethodDecorator ) {
41+ kind = 'method' ;
42+ }
43+
3344 return kind ;
3445 }
3546
@@ -61,6 +72,10 @@ class EOProp {
6172 return isClassDecoratorProp ( this . name ) ;
6273 }
6374
75+ get decoratorNames ( ) {
76+ return this . decorators . map ( d => d . name ) ;
77+ }
78+
6479 get classDecoratorName ( ) {
6580 if ( this . name === LAYOUT_DECORATOR_NAME && this . value . name === LAYOUT_DECORATOR_NAME ) {
6681 return LAYOUT_DECORATOR_LOCAL_NAME ;
@@ -81,20 +96,15 @@ class EOProp {
8196 }
8297
8398 get hasDecorators ( ) {
84- return this . decoratorNames . length ;
99+ return this . decorators . length ;
85100 }
86101
87102 get callExprArgs ( ) {
88103 return get ( this . calleeObject , 'arguments' ) || [ ] ;
89104 }
90105
91106 get shouldRemoveLastArg ( ) {
92- const lastArg = this . callExprArgs . slice ( - 1 ) || [ ] ;
93-
94- return (
95- lastArg . length > 0 &&
96- ( lastArg [ 0 ] . type === 'FunctionExpression' || lastArg [ 0 ] . type === 'ObjectExpression' )
97- ) ;
107+ return this . kind === 'method' || this . kind === 'get' ;
98108 }
99109
100110 get hasModifierWithArgs ( ) {
@@ -141,14 +151,18 @@ class EOProp {
141151 return this . decoratorNames . includes ( 'off' ) ;
142152 }
143153
144- get hasWrapComputedDecorator ( ) {
145- return this . decoratorNames . includes ( 'wrapComputed' ) ;
146- }
147-
148154 get hasRuntimeData ( ) {
149155 return ! ! this . runtimeType ;
150156 }
151157
158+ get hasMethodDecorator ( ) {
159+ return this . decorators . find ( d => d . isMethodDecorator ) ;
160+ }
161+
162+ get hasMetaDecorator ( ) {
163+ return this . decorators . find ( d => d . isMetaDecorator ) ;
164+ }
165+
152166 setCallExpressionProps ( ) {
153167 let calleeObject = get ( this . _prop , 'value' ) ;
154168 const modifiers = [ getModifier ( calleeObject ) ] ;
@@ -164,25 +178,21 @@ class EOProp {
164178 setDecorators ( importedDecoratedProps ) {
165179 if ( this . isCallExpression ) {
166180 this . setCallExpressionProps ( ) ;
167- const { decoratorName, isMethodDecorator, isMetaDecorator, importedName } =
168- importedDecoratedProps [ this . calleeName ] || { } ;
169- if ( decoratorName ) {
170- this . hasMapDecorator = importedName === 'map' ;
171- this . hasFilterDecorator = importedName === 'filter' ;
172- this . hasComputedDecorator = importedName === 'computed' ;
173- this . hasMethodDecorator = isMethodDecorator ;
174- this . hasMetaDecorator = isMetaDecorator ;
175- this . decoratorNames . push ( decoratorName ) ;
181+
182+ if ( importedDecoratedProps [ this . calleeName ] ) {
183+ this . decorators . push ( importedDecoratedProps [ this . calleeName ] ) ;
184+ } else if ( this . isComputed ) {
185+ this . decorators . push ( { name : this . calleeName } ) ;
176186 }
177187 }
178188 }
179189
180190 addBindingProps ( attributeBindingsProps , classNameBindingsProps ) {
181191 if ( attributeBindingsProps [ this . name ] ) {
182- this . decoratorNames . push ( 'attribute' ) ;
192+ this . decorators . push ( { name : 'attribute' } ) ;
183193 this . propList = attributeBindingsProps [ this . name ] ;
184194 } else if ( classNameBindingsProps [ this . name ] ) {
185- this . decoratorNames . push ( 'className' ) ;
195+ this . decorators . push ( { name : 'className' } ) ;
186196 this . propList = classNameBindingsProps [ this . name ] ;
187197 }
188198 }
@@ -201,17 +211,18 @@ class EOProp {
201211 if ( ! type ) {
202212 return ;
203213 }
214+
204215 const name = this . name ;
205216 if ( Object . keys ( unobservedProperties ) . includes ( name ) ) {
206- this . decoratorNames . push ( 'unobserves' ) ;
217+ this . decorators . push ( { name : 'unobserves' } ) ;
207218 this . decoratorArgs [ 'unobserves' ] = unobservedProperties [ name ] ;
208219 }
209220 if ( Object . keys ( offProperties ) . includes ( name ) ) {
210- this . decoratorNames . push ( 'off' ) ;
221+ this . decorators . push ( { name : 'off' } ) ;
211222 this . decoratorArgs [ 'off' ] = offProperties [ name ] ;
212223 }
213- if ( computedProperties . includes ( name ) && ! this . hasComputedDecorator && ! this . hasMetaDecorator ) {
214- this . decoratorNames . push ( 'wrapComputed' ) ;
224+ if ( computedProperties . includes ( name ) ) {
225+ this . isComputed = true ;
215226 }
216227 if ( this . isAction ) {
217228 this . overriddenActions = overriddenActions ;
0 commit comments