Skip to content

Commit afb083a

Browse files
Make method more clearly indicate that it is one based.
1 parent 11a9df2 commit afb083a

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/compiler/emitter.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ module ts {
133133
};
134134
}
135135

136-
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) {
136+
function getOneBasedLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) {
137137
return getOneBasedLineAndCharacterOfPosition(currentSourceFile, pos).line;
138138
}
139139

140140
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) {
141141
// If the leading comments start on different line than the start of node, write new line
142142
if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos &&
143-
getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) {
143+
getOneBasedLineOfLocalPosition(currentSourceFile, node.pos) !== getOneBasedLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) {
144144
writer.writeLine();
145145
}
146146
}
@@ -2973,13 +2973,13 @@ module ts {
29732973
}
29742974

29752975
function isOnSameLine(node1: Node, node2: Node) {
2976-
return getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) ===
2977-
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
2976+
return getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) ===
2977+
getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
29782978
}
29792979

29802980
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
2981-
return getLineOfLocalPosition(currentSourceFile, node1.end) ===
2982-
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
2981+
return getOneBasedLineOfLocalPosition(currentSourceFile, node1.end) ===
2982+
getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
29832983
}
29842984

29852985
function emitCaseOrDefaultClause(node: CaseOrDefaultClause) {
@@ -4470,8 +4470,8 @@ module ts {
44704470

44714471
forEach(leadingComments, comment => {
44724472
if (lastComment) {
4473-
var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end);
4474-
var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos);
4473+
var lastCommentLine = getOneBasedLineOfLocalPosition(currentSourceFile, lastComment.end);
4474+
var commentLine = getOneBasedLineOfLocalPosition(currentSourceFile, comment.pos);
44754475

44764476
if (commentLine >= lastCommentLine + 2) {
44774477
// There was a blank line between the last comment and this comment. This
@@ -4489,8 +4489,8 @@ module ts {
44894489
// All comments look like they could have been part of the copyright header. Make
44904490
// sure there is at least one blank line between it and the node. If not, it's not
44914491
// a copyright header.
4492-
var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
4493-
var astLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
4492+
var lastCommentLine = getOneBasedLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
4493+
var astLine = getOneBasedLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
44944494
if (astLine >= lastCommentLine + 2) {
44954495
// Valid detachedComments
44964496
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);

0 commit comments

Comments
 (0)