fix(language-service): fix calculation of pipe spans (#35986)
This commit accomplishes two tasks: - Fixes the span of queried pipes to only be applied on pipe names - By consequence, fixes how pipes are located in arguments (previously, pipes with arguments could not be found because the span of a pipe uses a relative span, while the template position is absolute) The screenshots attached to the PR for this commit demonstrate the change. Closes https://github.com/angular/vscode-ng-language-service/issues/677 PR Close #35986
This commit is contained in:

committed by
Matias Niemelä

parent
a73e125c04
commit
406419bc0f
@ -138,6 +138,19 @@ describe('hover', () => {
|
||||
expect(toText(displayParts)).toBe('(property) TemplateReference.heroes: Hero[]');
|
||||
});
|
||||
|
||||
it('should work for pipes', () => {
|
||||
mockHost.override(TEST_TEMPLATE, `
|
||||
<p>The hero's birthday is {{birthday | «date»: "MM/dd/yy"}}</p>`);
|
||||
const marker = mockHost.getReferenceMarkerFor(TEST_TEMPLATE, 'date');
|
||||
const quickInfo = ngLS.getQuickInfoAtPosition(TEST_TEMPLATE, marker.start);
|
||||
expect(quickInfo).toBeTruthy();
|
||||
const {textSpan, displayParts} = quickInfo !;
|
||||
expect(textSpan).toEqual(marker);
|
||||
expect(toText(displayParts))
|
||||
.toBe(
|
||||
'(pipe) date: (value: any, format?: string | undefined, timezone?: string | undefined, locale?: string | undefined) => string | null');
|
||||
});
|
||||
|
||||
it('should work for the $any() cast function', () => {
|
||||
const content = mockHost.override(TEST_TEMPLATE, '<div>{{$any(title)}}</div>');
|
||||
const position = content.indexOf('$any');
|
||||
|
Reference in New Issue
Block a user