The name of the decorated class if it's a block on the form ... ... = __decorate([registerGObjectClass, ...], NameOfDecoratedClass); ...
(node: BaseNode)
| 124 | ... |
| 125 | */ |
| 126 | function getDecoratorTargets(node: BaseNode): string[] | null { |
| 127 | if (isBlockStatement(node) || isProgram(node)) { |
| 128 | let targets = []; |
| 129 | for (let child of node.body) { |
| 130 | if (!isExpressionStatement(child)) continue; |
| 131 | if (!isAssignmentExpression(child.expression)) continue; |
| 132 | let rhs = child.expression.right; |
| 133 | |
| 134 | // Essentially go from expressions on the form `a = b = c = d` to `a = d` |
| 135 | while (isAssignmentExpression(rhs)) rhs = rhs.right; |
| 136 | |
| 137 | if (!isSimpleCallExpression(rhs)) continue; |
| 138 | if (!isIdentifier(rhs.callee)) continue; |
| 139 | |
| 140 | if (rhs.callee.name != '__decorate') continue; |
| 141 | |
| 142 | let args = rhs.arguments; |
| 143 | if (args.length != 2) continue; |
| 144 | |
| 145 | let decoratorFunctions = args[0]; |
| 146 | if (!isArrayExpression(decoratorFunctions)) continue; |
| 147 | |
| 148 | const gObjectDecorator = decoratorFunctions.elements.find( |
| 149 | (item) => { |
| 150 | return ( |
| 151 | isIdentifier(item) && |
| 152 | item.name == 'registerGObjectClass' |
| 153 | ); |
| 154 | } |
| 155 | ); |
| 156 | if (gObjectDecorator === undefined) continue; |
| 157 | |
| 158 | let targetClass = args[1]; |
| 159 | if (!isIdentifier(targetClass)) continue; |
| 160 | |
| 161 | targets.push(targetClass.name); |
| 162 | } |
| 163 | return targets; |
| 164 | } |
| 165 | return null; |
| 166 | } |
| 167 | |
| 168 | /// Converts imports on the form |
| 169 | /// import * from 'source' |
no test coverage detected