From afb083ae5a5eeef6ee9b1a9696dca3adb34347e0 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 16 Feb 2015 15:39:49 -0800 Subject: [PATCH] Make method more clearly indicate that it is one based. --- src/compiler/emitter.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 86a8ca584a2..64328517299 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -133,14 +133,14 @@ module ts { }; } - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) { + function getOneBasedLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) { return getOneBasedLineAndCharacterOfPosition(currentSourceFile, pos).line; } function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) { // If the leading comments start on different line than the start of node, write new line if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && - getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + getOneBasedLineOfLocalPosition(currentSourceFile, node.pos) !== getOneBasedLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { writer.writeLine(); } } @@ -2973,13 +2973,13 @@ module ts { } function isOnSameLine(node1: Node, node2: Node) { - return getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) === - getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos)); + return getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) === + getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos)); } function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) { - return getLineOfLocalPosition(currentSourceFile, node1.end) === - getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos)); + return getOneBasedLineOfLocalPosition(currentSourceFile, node1.end) === + getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node: CaseOrDefaultClause) { @@ -4470,8 +4470,8 @@ module ts { forEach(leadingComments, comment => { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + var lastCommentLine = getOneBasedLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getOneBasedLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { // There was a blank line between the last comment and this comment. This @@ -4489,8 +4489,8 @@ module ts { // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var astLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = getOneBasedLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var astLine = getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos)); if (astLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);