File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1733,6 +1733,13 @@ module ts {
17331733 }
17341734 }
17351735
1736+ function getOneBasedLineAndCharacterOfPosition ( sourceFile : SourceFile , pos : number ) {
1737+ var result = getZeroBasedLineAndCharacterOfPosition ( sourceFile , pos ) ;
1738+ result . line ++ ;
1739+ result . character ++ ;
1740+ return result ;
1741+ }
1742+
17361743 function recordSourceMapSpan ( pos : number ) {
17371744 var sourceLinePos = getOneBasedLineAndCharacterOfPosition ( currentSourceFile , pos ) ;
17381745 var emittedLine = writer . getLine ( ) ;
Original file line number Diff line number Diff line change @@ -319,10 +319,6 @@ module ts {
319319 return computeZeroBasedLineAndCharacterOfPosition ( getLineStarts ( sourceFile ) , position ) ;
320320 }
321321
322- export function getOneBasedLineAndCharacterOfPosition ( sourceFile : SourceFile , position : number ) : LineAndCharacter {
323- return computeOneBasedLineAndCharacterOfPosition ( getLineStarts ( sourceFile ) , position ) ;
324- }
325-
326322 var hasOwnProperty = Object . prototype . hasOwnProperty ;
327323
328324 export function isWhiteSpace ( ch : number ) : boolean {
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ module ts {
7272 function countLines ( program : Program ) : number {
7373 var count = 0 ;
7474 forEach ( program . getSourceFiles ( ) , file => {
75- count += getOneBasedLineAndCharacterOfPosition ( file , file . end ) . line ;
75+ count += getLineStarts ( file ) . length ;
7676 } ) ;
7777 return count ;
7878 }
@@ -86,9 +86,9 @@ module ts {
8686 var output = "" ;
8787
8888 if ( diagnostic . file ) {
89- var loc = getOneBasedLineAndCharacterOfPosition ( diagnostic . file , diagnostic . start ) ;
89+ var loc = getZeroBasedLineAndCharacterOfPosition ( diagnostic . file , diagnostic . start ) ;
9090
91- output += diagnostic . file . fileName + "(" + loc . line + "," + loc . character + "): " ;
91+ output += diagnostic . file . fileName + "(" + ( loc . line + 1 ) + "," + ( loc . character + 1 ) + "): " ;
9292 }
9393
9494 var category = DiagnosticCategory [ diagnostic . category ] . toLowerCase ( ) ;
Original file line number Diff line number Diff line change @@ -118,8 +118,8 @@ module ts {
118118 // This is a useful function for debugging purposes.
119119 export function nodePosToString ( node : Node ) : string {
120120 var file = getSourceFileOfNode ( node ) ;
121- var loc = getOneBasedLineAndCharacterOfPosition ( file , node . pos ) ;
122- return file . fileName + "(" + loc . line + "," + loc . character + ")" ;
121+ var loc = getZeroBasedLineAndCharacterOfPosition ( file , node . pos ) ;
122+ return file . fileName + "(" + ( loc . line + 1 ) + "," + ( loc . character + 1 ) + ")" ;
123123 }
124124
125125 export function getStartPosOfNode ( node : Node ) : number {
Original file line number Diff line number Diff line change @@ -756,7 +756,10 @@ module ts {
756756 }
757757
758758 public getOneBasedLineAndCharacterOfPosition ( position : number ) : LineAndCharacter {
759- return ts . getOneBasedLineAndCharacterOfPosition ( this , position ) ;
759+ var result = ts . getZeroBasedLineAndCharacterOfPosition ( this , position ) ;
760+ result . line ++ ;
761+ result . character ++ ;
762+ return result ;
760763 }
761764
762765 public getLineStarts ( ) : number [ ] {
You can’t perform that action at this time.
0 commit comments