feat(compiler): add name spans for property reads and method calls (#36826)
ASTs for property read and method calls contain information about the entire span of the expression, including its receiver. Use cases like a language service and compile error messages may be more interested in the span of the direct identifier for which the expression is constructed (i.e. an accessed property). To support this, this commit adds a `nameSpan` property on - `PropertyRead`s - `SafePropertyRead`s - `PropertyWrite`s - `MethodCall`s - `SafeMethodCall`s The `nameSpan` property already existed for `BindingPipe`s. This commit also updates usages of these expressions' `sourceSpan`s in Ngtsc and the langauge service to use `nameSpan`s where appropriate. PR Close #36826
This commit is contained in:
@ -77,7 +77,7 @@ describe('definitions', () => {
|
||||
it('should be able to find a method from a call', () => {
|
||||
const fileName = mockHost.addCode(`
|
||||
@Component({
|
||||
template: '<div (click)="~{start-my}«myClick»()~{end-my};"></div>'
|
||||
template: '<div (click)="«myClick»();"></div>'
|
||||
})
|
||||
export class MyComponent {
|
||||
«ᐱmyClickᐱ() { }»
|
||||
@ -88,7 +88,7 @@ describe('definitions', () => {
|
||||
expect(result).toBeDefined();
|
||||
const {textSpan, definitions} = result!;
|
||||
|
||||
expect(textSpan).toEqual(mockHost.getLocationMarkerFor(fileName, 'my'));
|
||||
expect(textSpan).toEqual(marker);
|
||||
expect(definitions).toBeDefined();
|
||||
expect(definitions!.length).toBe(1);
|
||||
const def = definitions![0];
|
||||
|
Reference in New Issue
Block a user