refactor(compiler-cli): Include pipe nameSpan
in TCB (#39768)
In order to map the pipe's `transform` method in the type check block directly back to the pipe name in the template source, we need to include the `BindingPipe`'s `nameSpan` with the `ts.methodAccess` for the pipe's transform method. Note that this is specifically relevant to the Language Service's "find references" feature. As an example, with something like `-2.5 | number:'1.0-0'`,, when calling "find references" on the 'number' pipe we want the text span of the reference to just be `number` rather than the entire binding pipe's source `-2.5 | number:'1.0-0'`. PR Close #39768
This commit is contained in:
parent
82e3f546db
commit
1a5e5f86a3
@ -1618,7 +1618,12 @@ class TcbExpressionTranslator {
|
|||||||
pipe = NULL_AS_ANY;
|
pipe = NULL_AS_ANY;
|
||||||
}
|
}
|
||||||
const args = ast.args.map(arg => this.translate(arg));
|
const args = ast.args.map(arg => this.translate(arg));
|
||||||
const result = tsCallMethod(pipe, 'transform', [expr, ...args]);
|
const methodAccess = ts.createPropertyAccess(pipe, 'transform');
|
||||||
|
addParseSpanInfo(methodAccess, ast.nameSpan);
|
||||||
|
const result = ts.createCall(
|
||||||
|
/* expression */ methodAccess,
|
||||||
|
/* typeArguments */ undefined,
|
||||||
|
/* argumentsArray */[expr, ...args]);
|
||||||
addParseSpanInfo(result, ast.sourceSpan);
|
addParseSpanInfo(result, ast.sourceSpan);
|
||||||
return result;
|
return result;
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -147,7 +147,7 @@ describe('type check blocks diagnostics', () => {
|
|||||||
}];
|
}];
|
||||||
const block = tcbWithSpans(TEMPLATE, PIPES);
|
const block = tcbWithSpans(TEMPLATE, PIPES);
|
||||||
expect(block).toContain(
|
expect(block).toContain(
|
||||||
'((null as TestPipe).transform(((ctx).a /*3,4*/) /*3,4*/, ((ctx).b /*12,13*/) /*12,13*/) /*3,13*/);');
|
'((null as TestPipe).transform /*7,11*/(((ctx).a /*3,4*/) /*3,4*/, ((ctx).b /*12,13*/) /*12,13*/) /*3,13*/);');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('attaching multiple comments for multiple references', () => {
|
describe('attaching multiple comments for multiple references', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user