feat(compiler): Added spans to HTML parser errors
Allows using the HTML parser in contexts errors are reported in a development tool such as an editor.
This commit is contained in:

committed by
Vikram Subramanian

parent
a3d7629134
commit
19a08f3a43
@ -581,7 +581,8 @@ export function main() {
|
||||
let src = "111\n222\n333\nE\n444\n555\n666\n";
|
||||
let file = new ParseSourceFile(src, 'file://');
|
||||
let location = new ParseLocation(file, 12, 123, 456);
|
||||
let error = new HtmlTokenError('**ERROR**', null, location);
|
||||
let span = new ParseSourceSpan(location, location);
|
||||
let error = new HtmlTokenError('**ERROR**', null, span);
|
||||
expect(error.toString())
|
||||
.toEqual(`**ERROR** ("\n222\n333\n[ERROR ->]E\n444\n555\n"): file://@123:456`);
|
||||
});
|
||||
@ -631,7 +632,9 @@ function tokenizeAndHumanizeLineColumn(input: string): any[] {
|
||||
|
||||
function tokenizeAndHumanizeErrors(input: string): any[] {
|
||||
return tokenizeHtml(input, 'someUrl')
|
||||
.errors.map(
|
||||
tokenError =>
|
||||
[<any>tokenError.tokenType, tokenError.msg, humanizeLineColumn(tokenError.location)]);
|
||||
.errors.map(tokenError => [
|
||||
<any>tokenError.tokenType,
|
||||
tokenError.msg,
|
||||
humanizeLineColumn(tokenError.span.start)
|
||||
]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user