feat(compiler): Propagate source span and value span to Variable AST (#36047)

This commit propagates the `sourceSpan` and `valueSpan` of a `VariableBinding`
in a microsyntax expression to `ParsedVariable`, and subsequently to
View Engine Variable AST and Ivy Variable AST.

Note that this commit does not propagate the `keySpan`, because it involves
significant changes to the template AST.

PR Close #36047
This commit is contained in:
Keen Yee Liau
2020-03-11 16:46:08 -07:00
committed by Andrew Kushnir
parent e179c5827f
commit 31bec8ce61
7 changed files with 46 additions and 18 deletions

View File

@ -292,7 +292,7 @@ describe('diagnostics', () => {
it('should suggest refining a template context missing a property', () => {
mockHost.override(
TEST_TEMPLATE,
`<button type="button" ~{start-emb}*counter="let hero of heroes"~{end-emb}></button>`);
`<button type="button" *counter="~{start-emb}let hero ~{end-emb}of heroes"></button>`);
const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE);
expect(diags.length).toBe(1);
const {messageText, start, length, category} = diags[0];
@ -310,7 +310,7 @@ describe('diagnostics', () => {
it('should report an unknown context reference', () => {
mockHost.override(
TEST_TEMPLATE,
`<div ~{start-emb}*ngFor="let hero of heroes; let e = even_1"~{end-emb}></div>`);
`<div *ngFor="let hero of heroes; ~{start-emb}let e = even_1~{end-emb}"></div>`);
const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE);
expect(diags.length).toBe(1);
const {messageText, start, length, category} = diags[0];