From df3a74b6ca2d340aedf06e8595ce28fcf8320751 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 10 Dec 2015 15:35:47 -0800 Subject: [PATCH] Removed some unnecessary changes and added comments --- src/compiler/emitter.ts | 4 +++- src/compiler/sourcemap.ts | 15 ++++++--------- src/compiler/utilities.ts | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a4bbe9b7528..8084ac3c4f1 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2832,6 +2832,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi else { write("var "); } + // Note here we specifically dont emit end so that if we are going to emit binding pattern + // we can alter the source map correctly return true; } @@ -3732,7 +3734,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi const isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement); - // If this is first var declaration, we need to stary at var/let/const keyword instead + // If this is first var declaration, we need to start at var/let/const keyword instead // otherwise use nodeForSourceMap as the start position emitStart(isFirstVariableDeclaration(nodeForSourceMap) ? nodeForSourceMap.parent : nodeForSourceMap); withTemporaryNoSourceMap(() => { diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index ab079c642ea..0e90cee1fb1 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -232,20 +232,17 @@ namespace ts { sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } - function getSourceLinePos(pos: number) { - const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); - // Convert the location to be one-based. - sourceLinePos.line++; - sourceLinePos.character++; - return sourceLinePos; - } - function emitPos(pos: number) { if (pos === -1) { return; } - const sourceLinePos = getSourceLinePos(pos); + const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); + + // Convert the location to be one-based. + sourceLinePos.line++; + sourceLinePos.character++; + const emittedLine = writer.getLine(); const emittedColumn = writer.getColumn(); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0f0f50719c1..95bf4ff7fa3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1616,7 +1616,7 @@ namespace ts { return node.kind === SyntaxKind.QualifiedName; } - export function nodeIsSynthesized(node: Node | TextRange): boolean { + export function nodeIsSynthesized(node: Node): boolean { return node.pos === -1; }