feat(language-service): completions for output $event properties in (#34570)

This commit adds support for completions of properties on `$event`
variables in bound outputs.

This is the second major PR to support completions for `$event`
variables (https://github.com/angular/vscode-ng-language-service/issues/531).
The final completion support that must be provided is for `$event`
variables in bindings targeting DOM events, like `(click)`.

PR Close #34570
This commit is contained in:
ayazhafiz
2019-12-26 13:26:54 -06:00
committed by Andrew Kushnir
parent c246787ccc
commit 2a537273ca
6 changed files with 64 additions and 24 deletions

View File

@ -758,10 +758,17 @@ describe('completions', () => {
it('should suggest $event in event bindings', () => {
mockHost.override(TEST_TEMPLATE, `<div (click)="myClick(~{cursor});"></div>`);
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
debugger;
const completions = ngLS.getCompletionsAt(TEST_TEMPLATE, marker.start);
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
expectContain(completions, CompletionKind.VARIABLE, ['$event']);
});
it('should suggest $event completions in output bindings', () => {
mockHost.override(TEST_TEMPLATE, `<div string-model (modelChange)="$event.~{cursor}"></div>`);
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
// Expect string properties
expectContain(completions, CompletionKind.METHOD, ['charAt', 'substring']);
});
});
});