feat(Compiler): case sensitive html parser

close #4417

Closes #5264
This commit is contained in:
Victor Berchet
2015-11-16 21:09:09 +00:00
parent 86aeb8be0a
commit a8edc1eb58
13 changed files with 737 additions and 344 deletions
+28 -6
View File
@@ -1,10 +1,8 @@
import {Math} from 'angular2/src/facade/math';
export class ParseLocation {
constructor(public file: ParseSourceFile, public offset: number, public line: number,
public col: number) {}
toString() { return `${this.file.url}@${this.line}:${this.col}`; }
toString(): string { return `${this.file.url}@${this.line}:${this.col}`; }
}
export class ParseSourceFile {
@@ -16,9 +14,33 @@ export abstract class ParseError {
toString(): string {
var source = this.location.file.content;
var ctxStart = Math.max(this.location.offset - 10, 0);
var ctxEnd = Math.min(this.location.offset + 10, source.length);
return `${this.msg} (${source.substring(ctxStart, ctxEnd)}): ${this.location}`;
var ctxStart = this.location.offset;
var ctxEnd = this.location.offset;
var ctxLen = 0;
var ctxLines = 0;
while (ctxLen < 100 && ctxStart > 0) {
ctxStart--;
ctxLen++;
if (source[ctxStart] == "\n") {
if (++ctxLines == 3) {
break;
}
}
}
ctxLen = 0;
ctxLines = 0;
while (ctxLen < 100 && ctxEnd < source.length - 1) {
ctxEnd++;
ctxLen++;
if (source[ctxEnd] == "\n") {
if (++ctxLines == 3) {
break;
}
}
}
return `${this.msg} ("${source.substring(ctxStart, ctxEnd + 1)}"): ${this.location}`;
}
}