@@ -16,6 +16,7 @@ const Traverser = getTraverser();
16
16
const emberUtils = require ( '../utils/ember' ) ;
17
17
const types = require ( '../utils/types' ) ;
18
18
const propertyGetterUtils = require ( '../utils/property-getter' ) ;
19
+ const assert = require ( 'assert' ) ;
19
20
20
21
/**
21
22
* Checks whether the node is an identifier and optionally, its name.
@@ -69,6 +70,37 @@ function isEmberComputed(node) {
69
70
return isIdentifier ( node , 'computed' ) || isMemberExpression ( node , 'Ember' , 'computed' ) ;
70
71
}
71
72
73
+ /**
74
+ * Checks if a node looks like: 'part1' + 'part2'
75
+ *
76
+ * @param {ASTNode } node
77
+ * @returns {boolean }
78
+ */
79
+ function isTwoPartStringLiteral ( node ) {
80
+ return (
81
+ types . isBinaryExpression ( node ) &&
82
+ types . isStringLiteral ( node . left ) &&
83
+ types . isStringLiteral ( node . right )
84
+ ) ;
85
+ }
86
+
87
+ /**
88
+ * Returns the string represented by the node.
89
+ *
90
+ * @param {ASTNode } node
91
+ * @returns {string }
92
+ */
93
+ function nodeToStringValue ( node ) {
94
+ if ( types . isStringLiteral ( node ) ) {
95
+ return node . value ;
96
+ } else if ( isTwoPartStringLiteral ( node ) ) {
97
+ return node . left . value + node . right . value ;
98
+ } else {
99
+ assert ( false ) ;
100
+ return undefined ;
101
+ }
102
+ }
103
+
72
104
/**
73
105
* Builds an array by concatenating the results of a map.
74
106
*
@@ -94,7 +126,7 @@ function parseComputedDependencies(args) {
94
126
for ( let i = 0 ; i < args . length - 1 ; i ++ ) {
95
127
const arg = args [ i ] ;
96
128
97
- if ( types . isStringLiteral ( arg ) ) {
129
+ if ( types . isStringLiteral ( arg ) || isTwoPartStringLiteral ( arg ) ) {
98
130
keys . push ( arg ) ;
99
131
} else {
100
132
dynamicKeys . push ( arg ) ;
@@ -388,9 +420,7 @@ module.exports = {
388
420
} ) ;
389
421
const usedKeys = [ ...usedKeys1 , ...usedKeys2 ] ;
390
422
391
- const expandedDeclaredKeys = expandKeys (
392
- declaredDependencies . keys . map ( node => node . value )
393
- ) ;
423
+ const expandedDeclaredKeys = expandKeys ( declaredDependencies . keys . map ( nodeToStringValue ) ) ;
394
424
395
425
const undeclaredKeysBeforeServiceCheck = removeRedundantKeys (
396
426
usedKeys
0 commit comments