fix(compiler): narrow the span reported for invalid pipes

fixes #13326
closes #13411
This commit is contained in:
Chuck Jazdzewski
2016-12-12 15:59:12 -08:00
committed by Victor Berchet
parent 0a7364feea
commit 307d305b2d
4 changed files with 42 additions and 6 deletions

View File

@ -377,9 +377,12 @@ export class BindingParser {
if (isPresent(ast)) {
const collector = new PipeCollector();
ast.visit(collector);
collector.pipes.forEach((pipeName) => {
collector.pipes.forEach((ast, pipeName) => {
if (!this.pipesByName.has(pipeName)) {
this._reportError(`The pipe '${pipeName}' could not be found`, sourceSpan);
this._reportError(
`The pipe '${pipeName}' could not be found`,
new ParseSourceSpan(
sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end)));
}
});
}
@ -402,9 +405,9 @@ export class BindingParser {
}
export class PipeCollector extends RecursiveAstVisitor {
pipes = new Set<string>();
pipes = new Map<string, BindingPipe>();
visitPipe(ast: BindingPipe, context: any): any {
this.pipes.add(ast.name);
this.pipes.set(ast.name, ast);
ast.exp.visit(this);
this.visitAll(ast.args, context);
return null;