@@ -133,14 +133,14 @@ module ts {
133133 } ;
134134 }
135135
136- function getZeroBasedLineOfLocalPosition ( currentSourceFile : SourceFile , pos : number ) {
137- return getZeroBasedLineAndCharacterOfPosition ( currentSourceFile , pos ) . line ;
136+ function getBasedLineOfLocalPosition ( currentSourceFile : SourceFile , pos : number ) {
137+ return getLineAndCharacterOfPosition ( 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- getZeroBasedLineOfLocalPosition ( currentSourceFile , node . pos ) !== getZeroBasedLineOfLocalPosition ( currentSourceFile , leadingComments [ 0 ] . pos ) ) {
143+ getBasedLineOfLocalPosition ( currentSourceFile , node . pos ) !== getBasedLineOfLocalPosition ( currentSourceFile , leadingComments [ 0 ] . pos ) ) {
144144 writer . writeLine ( ) ;
145145 }
146146 }
@@ -169,18 +169,18 @@ module ts {
169169
170170 function writeCommentRange ( currentSourceFile : SourceFile , writer : EmitTextWriter , comment : CommentRange , newLine : string ) {
171171 if ( currentSourceFile . text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk ) {
172- var firstCommentLineAndCharacter = getZeroBasedLineAndCharacterOfPosition ( currentSourceFile , comment . pos ) ;
172+ var firstCommentLineAndCharacter = getLineAndCharacterOfPosition ( currentSourceFile , comment . pos ) ;
173173 var lineCount = getLineStarts ( currentSourceFile ) . length ;
174174 var firstCommentLineIndent : number ;
175175 for ( var pos = comment . pos , currentLine = firstCommentLineAndCharacter . line ; pos < comment . end ; currentLine ++ ) {
176176 var nextLineStart = ( currentLine + 1 ) === lineCount
177177 ? currentSourceFile . text . length + 1
178- : getStartPositionOfZeroBasedLine ( currentLine + 1 , currentSourceFile ) ;
178+ : getStartPositionOfLine ( currentLine + 1 , currentSourceFile ) ;
179179
180180 if ( pos !== comment . pos ) {
181181 // If we are not emitting first line, we need to write the spaces to adjust the alignment
182182 if ( firstCommentLineIndent === undefined ) {
183- firstCommentLineIndent = calculateIndent ( getStartPositionOfZeroBasedLine ( firstCommentLineAndCharacter . line , currentSourceFile ) , comment . pos ) ;
183+ firstCommentLineIndent = calculateIndent ( getStartPositionOfLine ( firstCommentLineAndCharacter . line , currentSourceFile ) , comment . pos ) ;
184184 }
185185
186186 // These are number of spaces writer is going to write at current indent
@@ -1734,7 +1734,7 @@ module ts {
17341734 }
17351735
17361736 function recordSourceMapSpan ( pos : number ) {
1737- var sourceLinePos = getZeroBasedLineAndCharacterOfPosition ( currentSourceFile , pos ) ;
1737+ var sourceLinePos = getLineAndCharacterOfPosition ( currentSourceFile , pos ) ;
17381738
17391739 // Convert the location to be one-based.
17401740 sourceLinePos . line ++ ;
@@ -2979,13 +2979,13 @@ module ts {
29792979 }
29802980
29812981 function isOnSameLine ( node1 : Node , node2 : Node ) {
2982- return getZeroBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node1 . pos ) ) ===
2983- getZeroBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node2 . pos ) ) ;
2982+ return getBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node1 . pos ) ) ===
2983+ getBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node2 . pos ) ) ;
29842984 }
29852985
29862986 function nodeEndIsOnSameLineAsNodeStart ( node1 : Node , node2 : Node ) {
2987- return getZeroBasedLineOfLocalPosition ( currentSourceFile , node1 . end ) ===
2988- getZeroBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node2 . pos ) ) ;
2987+ return getBasedLineOfLocalPosition ( currentSourceFile , node1 . end ) ===
2988+ getBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node2 . pos ) ) ;
29892989 }
29902990
29912991 function emitCaseOrDefaultClause ( node : CaseOrDefaultClause ) {
@@ -4476,8 +4476,8 @@ module ts {
44764476
44774477 forEach ( leadingComments , comment => {
44784478 if ( lastComment ) {
4479- var lastCommentLine = getZeroBasedLineOfLocalPosition ( currentSourceFile , lastComment . end ) ;
4480- var commentLine = getZeroBasedLineOfLocalPosition ( currentSourceFile , comment . pos ) ;
4479+ var lastCommentLine = getBasedLineOfLocalPosition ( currentSourceFile , lastComment . end ) ;
4480+ var commentLine = getBasedLineOfLocalPosition ( currentSourceFile , comment . pos ) ;
44814481
44824482 if ( commentLine >= lastCommentLine + 2 ) {
44834483 // There was a blank line between the last comment and this comment. This
@@ -4495,8 +4495,8 @@ module ts {
44954495 // All comments look like they could have been part of the copyright header. Make
44964496 // sure there is at least one blank line between it and the node. If not, it's not
44974497 // a copyright header.
4498- var lastCommentLine = getZeroBasedLineOfLocalPosition ( currentSourceFile , detachedComments [ detachedComments . length - 1 ] . end ) ;
4499- var nodeLine = getZeroBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node . pos ) ) ;
4498+ var lastCommentLine = getBasedLineOfLocalPosition ( currentSourceFile , detachedComments [ detachedComments . length - 1 ] . end ) ;
4499+ var nodeLine = getBasedLineOfLocalPosition ( currentSourceFile , skipTrivia ( currentSourceFile . text , node . pos ) ) ;
45004500 if ( nodeLine >= lastCommentLine + 2 ) {
45014501 // Valid detachedComments
45024502 emitNewLineBeforeLeadingComments ( currentSourceFile , writer , node , leadingComments ) ;
0 commit comments