Move typewriter over to using zero based math.

This commit is contained in:
Cyrus Najmabadi 2015-02-16 19:06:47 -08:00
parent e723d4cee0
commit 041b646004

View File

@ -85,15 +85,17 @@ class TypeWriterWalker {
private log(node: ts.Node, type: ts.Type): void {
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
var lineAndCharacter = this.currentSourceFile.getOneBasedLineAndCharacterOfPosition(actualPos);
var lineAndCharacter = this.currentSourceFile.getZeroBasedLineAndCharacterOfPosition(actualPos);
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
// If we got an unknown type, we temporarily want to fall back to just pretending the name
// (source text) of the node is the type. This is to align with the old typeWriter to make
// baseline comparisons easier. In the long term, we will want to just call typeToString
this.results.push({
line: lineAndCharacter.line - 1,
column: lineAndCharacter.character,
line: lineAndCharacter.line,
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
// that behavior to prevent having a lot of baselines to fix up.
column: lineAndCharacter.character + 1,
syntaxKind: node.kind,
sourceText: sourceText,
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)