From 0de903ea1778ddbeee040e3386b8b5d02e5e0e77 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 11 Jul 2018 18:43:58 +0200 Subject: [PATCH] rename function --- src/compiler/transformers/es2015.ts | 10 +++++----- src/compiler/transformers/es2017.ts | 2 +- src/compiler/transformers/esnext.ts | 4 ++-- src/compiler/transformers/generators.ts | 2 +- src/compiler/transformers/module/module.ts | 4 ++-- src/compiler/transformers/module/system.ts | 2 +- src/compiler/transformers/ts.ts | 6 +++--- src/compiler/utilities.ts | 4 ++-- src/compiler/visitor.ts | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 46c5879481a..619cc505c8b 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -529,7 +529,7 @@ namespace ts { createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList(taggedTemplateStringDeclarations))); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return updateSourceFileNode( node, @@ -837,7 +837,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = createBlock(setTextRange(createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); setEmitFlags(block, EmitFlags.NoComments); @@ -980,7 +980,7 @@ namespace ts { ); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); @@ -1892,7 +1892,7 @@ namespace ts { } const lexicalEnvironment = context.endLexicalEnvironment(); - prependStatements(statements, lexicalEnvironment); + addStatementsAfterPrologue(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block @@ -2707,7 +2707,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - prependStatements(statements, lexicalEnvironment); + addStatementsAfterPrologue(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index ebf17ab105d..f58a24fb0a9 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -413,7 +413,7 @@ namespace ts { ) ); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = createBlock(statements, /*multiLine*/ true); setTextRange(block, node.body); diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 7400e39741d..b121eb315db 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -675,7 +675,7 @@ namespace ts { ) ); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const block = updateBlock(node.body!, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -707,7 +707,7 @@ namespace ts { const leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || some(statements) || some(leadingStatements)) { const block = convertToFunctionBody(body, /*multiLine*/ true); - prependStatements(statements, leadingStatements); + addStatementsAfterPrologue(statements, leadingStatements); addRange(statements, block.statements.slice(statementOffset)); return updateBlock(block, setTextRange(createNodeArray(statements), block.statements)); } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 97795fc89e5..5778b47a4f8 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -587,7 +587,7 @@ namespace ts { transformAndEmitStatements(body.statements, statementOffset); const buildResult = build(); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); statements.push(createReturn(buildResult)); // Restore previous generator state diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 686007aef37..ce405694cb4 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -97,7 +97,7 @@ namespace ts { append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement)); addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const updated = updateSourceFileNode(node, setTextRange(createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { @@ -426,7 +426,7 @@ namespace ts { // End the lexical environment for the module body // and merge any new lexical declarations. - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const body = createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index c0424ed58a4..82815528c21 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -257,7 +257,7 @@ namespace ts { // We emit hoisted variables early to align roughly with our previous emit output. // Two key differences in this approach are: // - Temporary variables will appear at the top rather than at the bottom of the file - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements)!; // TODO: GH#18217 const moduleObject = createObjectLiteral([ diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 2bebe6c7101..839e740b755 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -682,7 +682,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - prependStatements(statements, context.endLexicalEnvironment()); + addStatementsAfterPrologue(statements, context.endLexicalEnvironment()); const iife = createImmediatelyInvokedArrowFunction(statements); setEmitFlags(iife, EmitFlags.TypeScriptClassWrapper); @@ -2711,7 +2711,7 @@ namespace ts { const statements: Statement[] = []; startLexicalEnvironment(); const members = map(node.members, transformEnumMember); - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; @@ -3026,7 +3026,7 @@ namespace ts { statementsLocation = moveRangePos(moduleBlock.statements, -1); } - prependStatements(statements, endLexicalEnvironment()); + addStatementsAfterPrologue(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 12708755494..b771d590d5e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -401,9 +401,9 @@ namespace ts { } /** - * Prepends statements to an array taking care of prologue directives. + * Prepends statements to an array while taking care of prologue directives. */ - export function prependStatements(to: T[], from: ReadonlyArray | undefined): T[] { + export function addStatementsAfterPrologue(to: T[], from: ReadonlyArray | undefined): T[] { if (from === undefined || from.length === 0) return to; let statementIndex = 0; // skip all prologue directives to insert at the correct position diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 94b25e1bdc1..2cfb469f152 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1476,8 +1476,8 @@ namespace ts { } return isNodeArray(statements) - ? setTextRange(createNodeArray(prependStatements(statements.slice(), declarations)), statements) - : prependStatements(statements, declarations); + ? setTextRange(createNodeArray(addStatementsAfterPrologue(statements.slice(), declarations)), statements) + : addStatementsAfterPrologue(statements, declarations); } /**