mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Remove one-based helper function.
This commit is contained in:
parent
8ef4df8acb
commit
1098e80f4b
@ -1733,6 +1733,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getOneBasedLineAndCharacterOfPosition(sourceFile: SourceFile, pos: number) {
|
||||
var result = getZeroBasedLineAndCharacterOfPosition(sourceFile, pos);
|
||||
result.line++;
|
||||
result.character++;
|
||||
return result;
|
||||
}
|
||||
|
||||
function recordSourceMapSpan(pos: number) {
|
||||
var sourceLinePos = getOneBasedLineAndCharacterOfPosition(currentSourceFile, pos);
|
||||
var emittedLine = writer.getLine();
|
||||
|
||||
@ -319,10 +319,6 @@ module ts {
|
||||
return computeZeroBasedLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
||||
}
|
||||
|
||||
export function getOneBasedLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter {
|
||||
return computeOneBasedLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
export function isWhiteSpace(ch: number): boolean {
|
||||
|
||||
@ -72,7 +72,7 @@ module ts {
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getOneBasedLineAndCharacterOfPosition(file, file.end).line;
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@ -86,9 +86,9 @@ module ts {
|
||||
var output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
var loc = getOneBasedLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
var loc = getZeroBasedLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += diagnostic.file.fileName + "(" + loc.line + "," + loc.character + "): ";
|
||||
output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): ";
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
|
||||
@ -118,8 +118,8 @@ module ts {
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = getOneBasedLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + loc.line + "," + loc.character + ")";
|
||||
var loc = getZeroBasedLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
|
||||
@ -756,7 +756,10 @@ module ts {
|
||||
}
|
||||
|
||||
public getOneBasedLineAndCharacterOfPosition(position: number): LineAndCharacter {
|
||||
return ts.getOneBasedLineAndCharacterOfPosition(this, position);
|
||||
var result = ts.getZeroBasedLineAndCharacterOfPosition(this, position);
|
||||
result.line++;
|
||||
result.character++;
|
||||
return result;
|
||||
}
|
||||
|
||||
public getLineStarts(): number[] {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user