* Transforms the body of a module declaration. * * @param node The module declaration node.
(node, namespaceLocalName)
| 93732 | * @param node The module declaration node. |
| 93733 | */ |
| 93734 | function transformModuleBody(node, namespaceLocalName) { |
| 93735 | var savedCurrentNamespaceContainerName = currentNamespaceContainerName; |
| 93736 | var savedCurrentNamespace = currentNamespace; |
| 93737 | var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; |
| 93738 | currentNamespaceContainerName = namespaceLocalName; |
| 93739 | currentNamespace = node; |
| 93740 | currentScopeFirstDeclarationsOfName = undefined; |
| 93741 | var statements = []; |
| 93742 | startLexicalEnvironment(); |
| 93743 | var statementsLocation; |
| 93744 | var blockLocation; |
| 93745 | if (node.body) { |
| 93746 | if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { |
| 93747 | saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); |
| 93748 | statementsLocation = node.body.statements; |
| 93749 | blockLocation = node.body; |
| 93750 | } |
| 93751 | else { |
| 93752 | var result = visitModuleDeclaration(node.body); |
| 93753 | if (result) { |
| 93754 | if (ts.isArray(result)) { |
| 93755 | ts.addRange(statements, result); |
| 93756 | } |
| 93757 | else { |
| 93758 | statements.push(result); |
| 93759 | } |
| 93760 | } |
| 93761 | var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; |
| 93762 | statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); |
| 93763 | } |
| 93764 | } |
| 93765 | ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); |
| 93766 | currentNamespaceContainerName = savedCurrentNamespaceContainerName; |
| 93767 | currentNamespace = savedCurrentNamespace; |
| 93768 | currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; |
| 93769 | var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), |
| 93770 | /*location*/ statementsLocation), |
| 93771 | /*multiLine*/ true); |
| 93772 | ts.setTextRange(block, blockLocation); |
| 93773 | // namespace hello.hi.world { |
| 93774 | // function foo() {} |
| 93775 | // |
| 93776 | // // TODO, blah |
| 93777 | // } |
| 93778 | // |
| 93779 | // should be emitted as |
| 93780 | // |
| 93781 | // var hello; |
| 93782 | // (function (hello) { |
| 93783 | // var hi; |
| 93784 | // (function (hi) { |
| 93785 | // var world; |
| 93786 | // (function (world) { |
| 93787 | // function foo() { } |
| 93788 | // // TODO, blah |
| 93789 | // })(world = hi.world || (hi.world = {})); |
| 93790 | // })(hi = hello.hi || (hello.hi = {})); |
| 93791 | // })(hello || (hello = {})); |
no test coverage detected
searching dependent graphs…