mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #2055 from Microsoft/baseZero
Move all our document line/character APIs to be zero-based.
This commit is contained in:
+13
-7
@@ -170,16 +170,17 @@ module ts {
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
var firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
var lastLine = getLineStarts(currentSourceFile).length;
|
||||
var lineCount = getLineStarts(currentSourceFile).length;
|
||||
var firstCommentLineIndent: number;
|
||||
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : getPositionFromLineAndCharacter(currentSourceFile, currentLine + 1, /*character*/1);
|
||||
var nextLineStart = (currentLine + 1) === lineCount
|
||||
? currentSourceFile.text.length + 1
|
||||
: getStartPositionOfLine(currentLine + 1, currentSourceFile);
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
if (firstCommentLineIndent === undefined) {
|
||||
firstCommentLineIndent = calculateIndent(getPositionFromLineAndCharacter(currentSourceFile, firstCommentLineAndCharacter.line, /*character*/1),
|
||||
comment.pos);
|
||||
firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos);
|
||||
}
|
||||
|
||||
// These are number of spaces writer is going to write at current indent
|
||||
@@ -1738,6 +1739,11 @@ module ts {
|
||||
|
||||
function recordSourceMapSpan(pos: number) {
|
||||
var sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos);
|
||||
|
||||
// Convert the location to be one-based.
|
||||
sourceLinePos.line++;
|
||||
sourceLinePos.character++;
|
||||
|
||||
var emittedLine = writer.getLine();
|
||||
var emittedColumn = writer.getColumn();
|
||||
|
||||
@@ -2984,7 +2990,7 @@ module ts {
|
||||
|
||||
function isOnSameLine(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) ===
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
}
|
||||
|
||||
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
|
||||
@@ -4501,8 +4507,8 @@ module ts {
|
||||
// sure there is at least one blank line between it and the node. If not, it's not
|
||||
// a copyright header.
|
||||
var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
|
||||
var astLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
if (astLine >= lastCommentLine + 2) {
|
||||
var nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
if (nodeLine >= lastCommentLine + 2) {
|
||||
// Valid detachedComments
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
|
||||
@@ -280,13 +280,13 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionFromLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
}
|
||||
|
||||
export function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0 && line <= lineStarts.length);
|
||||
return lineStarts[line - 1] + character - 1;
|
||||
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line >= 0 && line < lineStarts.length);
|
||||
return lineStarts[line] + character;
|
||||
}
|
||||
|
||||
export function getLineStarts(sourceFile: SourceFile): number[] {
|
||||
@@ -300,11 +300,11 @@ module ts {
|
||||
// the binary search returns the negative value of the next line start
|
||||
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
|
||||
// then the search will return -2
|
||||
lineNumber = (~lineNumber) - 1;
|
||||
lineNumber = ~lineNumber - 1;
|
||||
}
|
||||
return {
|
||||
line: lineNumber + 1,
|
||||
character: position - lineStarts[lineNumber] + 1
|
||||
line: lineNumber,
|
||||
character: position - lineStarts[lineNumber]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ module ts {
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getLineAndCharacterOfPosition(file, file.end).line;
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ module ts {
|
||||
if (diagnostic.file) {
|
||||
var loc = getLineAndCharacterOfPosition(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();
|
||||
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine;
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
@@ -105,11 +105,16 @@ module ts {
|
||||
return <SourceFile>node;
|
||||
}
|
||||
|
||||
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 0);
|
||||
return getLineStarts(sourceFile)[line];
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + loc.line + "," + loc.character + ")";
|
||||
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
|
||||
+19
-27
@@ -398,7 +398,7 @@ module FourSlash {
|
||||
|
||||
var lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName));
|
||||
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos);
|
||||
this.scenarioActions.push('<MoveCaretToLineAndChar LineNumber="' + lineCharPos.line + '" CharNumber="' + lineCharPos.character + '" />');
|
||||
this.scenarioActions.push(`<MoveCaretToLineAndChar LineNumber=${ lineCharPos.line + 1 } CharNumber=${ lineCharPos.character + 1 } />`);
|
||||
}
|
||||
|
||||
public moveCaretRight(count = 1) {
|
||||
@@ -2015,39 +2015,31 @@ module FourSlash {
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
// The current caret position (in line/col terms)
|
||||
var line = this.getCurrentCaretFilePosition().line;
|
||||
// The line/col of the start of this line
|
||||
var pos = this.languageServiceAdapterHost.lineColToPosition(this.activeFile.fileName, line, 1);
|
||||
// The index of the current file
|
||||
var text = this.getFileContent(this.activeFile.fileName)
|
||||
|
||||
// The text from the start of the line to the end of the file
|
||||
var text = this.getFileContent(this.activeFile.fileName).substring(pos);
|
||||
var pos = this.currentCaretPosition;
|
||||
var startPos = pos, endPos = pos;
|
||||
|
||||
// Truncate to the first newline
|
||||
var newlinePos = text.indexOf('\n');
|
||||
if (newlinePos === -1) {
|
||||
return text;
|
||||
}
|
||||
else {
|
||||
if (text.charAt(newlinePos - 1) === '\r') {
|
||||
newlinePos--;
|
||||
while (startPos > 0) {
|
||||
var ch = text.charCodeAt(startPos - 1);
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
return text.substr(0, newlinePos);
|
||||
}
|
||||
}
|
||||
|
||||
private getCurrentCaretFilePosition() {
|
||||
var result = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (result.line >= 0) {
|
||||
result.line++;
|
||||
startPos--;
|
||||
}
|
||||
|
||||
if (result.character >= 0) {
|
||||
result.character++;
|
||||
while (endPos < text.length) {
|
||||
var ch = text.charCodeAt(endPos);
|
||||
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
|
||||
endPos++;
|
||||
}
|
||||
|
||||
return result;
|
||||
return text.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) {
|
||||
@@ -2125,7 +2117,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private getLineColStringAtPosition(position: number) {
|
||||
var pos = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
|
||||
var pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position);
|
||||
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
|
||||
}
|
||||
|
||||
|
||||
@@ -1185,13 +1185,13 @@ module Harness {
|
||||
}
|
||||
|
||||
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterOfPosition(err.start) : { line: -1, character: -1 };
|
||||
return {
|
||||
fileName: err.file && err.file.fileName,
|
||||
start: err.start,
|
||||
end: err.start + err.length,
|
||||
line: errorLineInfo.line,
|
||||
character: errorLineInfo.character,
|
||||
line: errorLineInfo.line + 1,
|
||||
character: errorLineInfo.character + 1,
|
||||
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
|
||||
category: ts.DiagnosticCategory[err.category].toLowerCase(),
|
||||
code: err.code
|
||||
|
||||
@@ -159,32 +159,15 @@ module Harness.LanguageService {
|
||||
public openFile(fileName: string): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
* @param col 1 based index
|
||||
*/
|
||||
public lineColToPosition(fileName: string, line: number, col: number): number {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
assert.isTrue(line >= 1);
|
||||
assert.isTrue(col >= 1);
|
||||
|
||||
return ts.computePositionFromLineAndCharacter(script.lineMap, line, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 0 based index
|
||||
* @param col 0 based index
|
||||
*/
|
||||
public positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter {
|
||||
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
var result = ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
|
||||
assert.isTrue(result.line >= 1);
|
||||
assert.isTrue(result.character >= 1);
|
||||
return { line: result.line - 1, character: result.character - 1 };
|
||||
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +214,7 @@ module Harness.LanguageService {
|
||||
getScriptInfo(fileName: string): ScriptInfo { return this.nativeHost.getScriptInfo(fileName); }
|
||||
addScript(fileName: string, content: string): void { this.nativeHost.addScript(fileName, content); }
|
||||
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
|
||||
lineColToPosition(fileName: string, line: number, col: number): number { return this.nativeHost.lineColToPosition(fileName, line, col); }
|
||||
positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToZeroBasedLineCol(fileName, position); }
|
||||
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
|
||||
|
||||
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
|
||||
getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); }
|
||||
@@ -471,10 +453,10 @@ module Harness.LanguageService {
|
||||
args: string[] = [];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean = false;
|
||||
|
||||
constructor(private host: NativeLanguageServiceHost) {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
constructor(private host: NativeLanguageServiceHost) {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
@@ -515,9 +497,9 @@ module Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
}
|
||||
|
||||
createDirectory(directoryName: string): void {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
@@ -529,30 +511,30 @@ module Harness.LanguageService {
|
||||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
info(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
perftrc(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
startGroup(): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
startGroup(): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.getLineAndCharacterFromPosition(actualPos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(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)
|
||||
|
||||
@@ -47,14 +47,14 @@ module ts.server {
|
||||
}
|
||||
|
||||
private lineColToPosition(fileName: string, lineCol: protocol.Location): number {
|
||||
return ts.computePositionFromLineAndCharacter(this.getLineMap(fileName), lineCol.line, lineCol.col);
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1);
|
||||
}
|
||||
|
||||
private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location {
|
||||
var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
return {
|
||||
line: lineCol.line,
|
||||
col: lineCol.character
|
||||
line: lineCol.line + 1,
|
||||
col: lineCol.character + 1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
// Get previous token if the token is returned starts on new line
|
||||
// eg: var x =10; |--- curser is here
|
||||
// eg: var x =10; |--- cursor is here
|
||||
// var y = 10;
|
||||
// token at position will return var keyword on second line as the token but we would like to use
|
||||
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
|
||||
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
|
||||
|
||||
// Its a blank line
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterFromPosition(node.getStart()).line) {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) {
|
||||
return spanInNode(node);
|
||||
}
|
||||
return spanInNode(otherwiseOnNode);
|
||||
|
||||
@@ -67,8 +67,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (line === 1) {
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (line === 0) {
|
||||
return [];
|
||||
}
|
||||
// get the span for the previous\current line
|
||||
@@ -100,7 +100,7 @@ module ts.formatting {
|
||||
export function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
// format from the beginning of the line
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(start, sourceFile),
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatSelection);
|
||||
@@ -112,7 +112,7 @@ module ts.formatting {
|
||||
return [];
|
||||
}
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
end: parent.end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, requestKind);
|
||||
@@ -283,7 +283,7 @@ module ts.formatting {
|
||||
var previousLine = Constants.Unknown;
|
||||
var childKind = SyntaxKind.Unknown;
|
||||
while (n) {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line;
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ module ts.formatting {
|
||||
formattingScanner.advance();
|
||||
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
|
||||
}
|
||||
@@ -357,8 +357,8 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(startPos).line;
|
||||
var startLinePosition = getStartLinePositionForPosition(startPos, sourceFile);
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
var startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
var column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column
|
||||
@@ -521,7 +521,7 @@ module ts.formatting {
|
||||
|
||||
var childStartPos = child.getStart(sourceFile);
|
||||
|
||||
var childStart = sourceFile.getLineAndCharacterFromPosition(childStartPos);
|
||||
var childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
var childIndentationAmount = Constants.Unknown;
|
||||
@@ -594,7 +594,7 @@ module ts.formatting {
|
||||
}
|
||||
else if (tokenInfo.token.kind === listStartToken) {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterFromPosition(tokenInfo.token.pos).line;
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
var indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
|
||||
|
||||
@@ -641,7 +641,7 @@ module ts.formatting {
|
||||
var lineAdded: boolean;
|
||||
var isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos);
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
if (isTokenInRange) {
|
||||
var rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
// save prevStartLine since processRange will overwrite this value with current ones
|
||||
@@ -674,7 +674,7 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos).line;
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
@@ -712,7 +712,7 @@ module ts.formatting {
|
||||
for (var i = 0, len = trivia.length; i < len; ++i) {
|
||||
var triviaItem = trivia[i];
|
||||
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos);
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
@@ -729,7 +729,7 @@ module ts.formatting {
|
||||
if (!rangeHasError && !previousRangeHasError) {
|
||||
if (!previousRange) {
|
||||
// trim whitespaces starting from the beginning of the span up to the current line
|
||||
var originalStart = sourceFile.getLineAndCharacterFromPosition(originalRange.pos);
|
||||
var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
|
||||
}
|
||||
else {
|
||||
@@ -807,18 +807,18 @@ module ts.formatting {
|
||||
recordReplace(pos, 0, indentationString);
|
||||
}
|
||||
else {
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(pos);
|
||||
if (indentation !== tokenStart.character - 1) {
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
if (indentation !== tokenStart.character) {
|
||||
var startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
recordReplace(startLinePosition, tokenStart.character - 1, indentationString);
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterFromPosition(commentRange.end).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
|
||||
if (startLine === endLine) {
|
||||
if (!firstLineIsIndented) {
|
||||
|
||||
@@ -71,8 +71,8 @@ module ts.formatting {
|
||||
|
||||
public TokensAreOnSameLine(): boolean {
|
||||
if (this.tokensAreOnSameLine === undefined) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(this.nextTokenSpan.pos).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine == endLine);
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(node.getEnd()).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine == endLine;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ module ts.formatting {
|
||||
var openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
var closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
if (openBrace && closeBrace) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -24,7 +24,7 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
|
||||
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
@@ -74,7 +74,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
|
||||
var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ module ts.formatting {
|
||||
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
var containingList = getContainingList(child, sourceFile);
|
||||
if (containingList) {
|
||||
return sourceFile.getLineAndCharacterFromPosition(containingList.pos);
|
||||
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
|
||||
}
|
||||
|
||||
return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -204,7 +204,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
}
|
||||
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
|
||||
@@ -279,7 +279,6 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
Debug.assert(index >= 0 && index < list.length);
|
||||
var node = list[index];
|
||||
@@ -292,7 +291,7 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
// skip list items that ends on the same line with the current list element
|
||||
var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line;
|
||||
var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
if (prevEndLine !== lineAndCharacter.line) {
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
|
||||
}
|
||||
@@ -303,7 +302,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1);
|
||||
var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ module ts {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (paramHelpStringMargin === undefined) {
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterFromPosition(firstLineParamHelpStringPos).character - 1;
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character;
|
||||
}
|
||||
|
||||
// Now consume white spaces max
|
||||
@@ -751,16 +751,16 @@ module ts {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
}
|
||||
|
||||
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
|
||||
return getLineAndCharacterOfPosition(this, position);
|
||||
public getLineAndCharacterOfPosition(position: number): LineAndCharacter {
|
||||
return ts.getLineAndCharacterOfPosition(this, position);
|
||||
}
|
||||
|
||||
public getLineStarts(): number[] {
|
||||
return getLineStarts(this);
|
||||
}
|
||||
|
||||
public getPositionFromLineAndCharacter(line: number, character: number): number {
|
||||
return getPositionFromLineAndCharacter(this, line, character);
|
||||
public getPositionOfLineAndCharacter(line: number, character: number): number {
|
||||
return ts.getPositionOfLineAndCharacter(this, line, character);
|
||||
}
|
||||
|
||||
public getNamedDeclarations() {
|
||||
|
||||
@@ -6,12 +6,11 @@ module ts {
|
||||
}
|
||||
|
||||
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 1);
|
||||
Debug.assert(line >= 0);
|
||||
var lineStarts = sourceFile.getLineStarts();
|
||||
|
||||
// lines returned by SourceFile.getLineAndCharacterForPosition are 1-based
|
||||
var lineIndex = line - 1;
|
||||
if (lineIndex === lineStarts.length - 1) {
|
||||
var lineIndex = line;
|
||||
if (lineIndex + 1 === lineStarts.length) {
|
||||
// last line - return EOF
|
||||
return sourceFile.text.length - 1;
|
||||
}
|
||||
@@ -32,15 +31,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 1);
|
||||
return sourceFile.getLineStarts()[line - 1];
|
||||
}
|
||||
|
||||
export function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number {
|
||||
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
|
||||
var lineStarts = sourceFile.getLineStarts();
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
return lineStarts[line - 1];
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
return lineStarts[line];
|
||||
}
|
||||
|
||||
export function rangeContainsRange(r1: TextRange, r2: TextRange): boolean {
|
||||
|
||||
@@ -21,8 +21,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
});
|
||||
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
@@ -1392,8 +1392,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1477,9 +1477,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -1955,8 +1955,8 @@ function compile(fileNames, options) {
|
||||
var emitResult = program.emit();
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
|
||||
});
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
console.log("Process exiting with code '" + exitCode + "'.");
|
||||
|
||||
@@ -56,27 +56,27 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
@@ -85,9 +85,11 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4393,15 +4395,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4760,16 +4762,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1423,8 +1423,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1508,9 +1508,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2012,8 +2012,8 @@ function delint(sourceFile) {
|
||||
ts.forEachChild(node, delintNode);
|
||||
}
|
||||
function report(node, message) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(sourceFile.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + message);
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(sourceFile.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + message);
|
||||
}
|
||||
}
|
||||
exports.delint = delint;
|
||||
|
||||
@@ -224,28 +224,30 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>Node : ts.Node
|
||||
>message : string
|
||||
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>sourceFile : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number
|
||||
>node : ts.Node
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number
|
||||
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
>console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`) : any
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
|
||||
>console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>sourceFile.fileName : string
|
||||
>sourceFile : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4537,15 +4539,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4904,16 +4906,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
@@ -1424,8 +1424,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1509,9 +1509,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2014,7 +2014,7 @@ function transform(contents, compilerOptions) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
return {
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
|
||||
|
||||
outputs: outputs,
|
||||
>outputs : any[]
|
||||
@@ -185,30 +185,32 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
|
||||
errors: errors.map(function (e) {
|
||||
>errors : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
|
||||
>errors.map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
|
||||
>function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
|
||||
>e : ts.Diagnostic
|
||||
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " : string
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) : string
|
||||
>e.file.fileName + "(" : string
|
||||
>e.file.fileName : string
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>e.file.getLineAndCharacterFromPosition(e.start).line : number
|
||||
>e.file.getLineAndCharacterFromPosition(e.start) : ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>(e.file.getLineAndCharacterOfPosition(e.start).line + 1) : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start).line + 1 : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start).line : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start) : ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.start : number
|
||||
>e : ts.Diagnostic
|
||||
>start : number
|
||||
@@ -4489,15 +4491,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4856,16 +4858,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${diagnostic.messageText}`);
|
||||
@@ -1461,8 +1461,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1546,9 +1546,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2074,8 +2074,8 @@ function watch(rootFileNames, options) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(" Error " + diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(" Error " + diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
||||
}
|
||||
else {
|
||||
console.log(" Error: " + diagnostic.messageText);
|
||||
|
||||
@@ -317,11 +317,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>fileName : string
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
if (diagnostic.file) {
|
||||
@@ -329,20 +329,20 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
@@ -351,9 +351,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4662,15 +4664,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -5029,16 +5031,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
});
|
||||
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
|
||||
@@ -51,8 +51,8 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
|
||||
@@ -87,8 +87,8 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${diagnostic.messageText}`);
|
||||
|
||||
Reference in New Issue
Block a user