* Returns the name of the rune if the given expression is a `CallExpression` using a rune. * @param {Expression | Super} node * @param {Scope} scope
(node, scope)
| 1446 | * @param {Scope} scope |
| 1447 | */ |
| 1448 | function get_global_keypath(node, scope) { |
| 1449 | let n = node; |
| 1450 | |
| 1451 | let joined = ''; |
| 1452 | |
| 1453 | while (n.type === 'MemberExpression') { |
| 1454 | if (n.computed) return null; |
| 1455 | if (n.property.type !== 'Identifier') return null; |
| 1456 | joined = '.' + n.property.name + joined; |
| 1457 | n = n.object; |
| 1458 | } |
| 1459 | |
| 1460 | if (n.type === 'CallExpression' && n.callee.type === 'Identifier') { |
| 1461 | joined = '()' + joined; |
| 1462 | n = n.callee; |
| 1463 | } |
| 1464 | |
| 1465 | if (n.type !== 'Identifier') return null; |
| 1466 | |
| 1467 | const binding = scope.get(n.name); |
| 1468 | if (binding !== null) return null; // rune name, but references a variable or store |
| 1469 | |
| 1470 | return n.name + joined; |
| 1471 | } |
no test coverage detected