(src)
| 190 | } |
| 191 | |
| 192 | tagLevel (src) { |
| 193 | let ast, moreTags |
| 194 | if (((src != null ? src.source : undefined) == null)) { return [] } |
| 195 | try { |
| 196 | ast = this.parser(src.source) |
| 197 | moreTags = tagger(src, this.concepts) |
| 198 | } catch (error) { |
| 199 | const e = error |
| 200 | return ['parse error: ' + e.message] |
| 201 | } |
| 202 | |
| 203 | const tags = {} |
| 204 | var process = function (n) { |
| 205 | if (n == null) { return } |
| 206 | switch (n.type) { |
| 207 | case 'Program': case 'BlockStatement': |
| 208 | return (() => { |
| 209 | const result = [] |
| 210 | for (n of Array.from(n.body)) { |
| 211 | result.push(process(n)) |
| 212 | } |
| 213 | return result |
| 214 | })() |
| 215 | case 'FunctionDeclaration': |
| 216 | tags['function-def'] = true |
| 217 | if (n.params > 0) { |
| 218 | tags['function-params:' + n.params.length] = true |
| 219 | } |
| 220 | return process(n.body) |
| 221 | case 'ExpressionStatement': |
| 222 | return process(n.expression) |
| 223 | case 'CallExpression': |
| 224 | return process(n.callee) |
| 225 | case 'MemberExpression': |
| 226 | if ((n.object != null ? n.object.name : undefined) === 'hero') { |
| 227 | return tags['hero.' + n.property.name] = true |
| 228 | } |
| 229 | break |
| 230 | case 'WhileStatement': |
| 231 | if ((n.test.type === 'Literal') && (n.test.value === true)) { |
| 232 | tags['while-true'] = true |
| 233 | } else { |
| 234 | tags.while = true |
| 235 | process(n.test) |
| 236 | } |
| 237 | return process(n.body) |
| 238 | case 'ForStatement': |
| 239 | tags.for = true |
| 240 | process(n.init) |
| 241 | process(n.test) |
| 242 | process(n.update) |
| 243 | return process(n.body) |
| 244 | case 'IfStatement': |
| 245 | tags.if = true |
| 246 | process(n.test) |
| 247 | process(n.consequent) |
| 248 | return process(n.alternate) |
| 249 | case 'Literal': |
no test coverage detected