Merge pull request #2321 from Microsoft/diagnosticAsserts

Add additional asserts to ensure we don't create diagnostics with bogus ...
This commit is contained in:
CyrusNajmabadi 2015-03-12 10:27:47 -07:00
commit ecfa19a760

View file

@ -269,8 +269,12 @@ module ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
var end = start + length;
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
var text = getLocaleSpecificMessage(message.key);