feat(language-service): implement autocompletion for global properties (Ivy) (#39250)

This commit adds support in the Ivy Language Service for autocompletion in a
global context - e.g. a {{foo|}} completion.

Support is added both for the primary function `getCompletionsAtPosition` as
well as the detail functions `getCompletionEntryDetails` and
`getCompletionEntrySymbol`. These latter operations are not used yet as an
upstream change to the extension is required to advertise and support this
capability.

PR Close #39250
This commit is contained in:
Alex Rickabaugh
2020-10-13 11:14:13 -07:00
committed by Misko Hevery
parent 67c5fe06e6
commit 28a0bcb424
7 changed files with 560 additions and 8 deletions
@@ -50,7 +50,7 @@ export interface TemplateTypeChecker {
* is not valid. If the template cannot be parsed correctly, no override will occur.
*/
overrideComponentTemplate(component: ts.ClassDeclaration, template: string):
{nodes: TmplAstNode[], errors?: ParseError[]};
{nodes: TmplAstNode[], errors: ParseError[]|null};
/**
* Get all `ts.Diagnostic`s currently available for the given `ts.SourceFile`.
@@ -32,6 +32,11 @@ export enum SymbolKind {
export type Symbol = InputBindingSymbol|OutputBindingSymbol|ElementSymbol|ReferenceSymbol|
VariableSymbol|ExpressionSymbol|DirectiveSymbol|TemplateSymbol|DomBindingSymbol;
/**
* A `Symbol` which declares a new named entity in the template scope.
*/
export type TemplateDeclarationSymbol = ReferenceSymbol|VariableSymbol;
/** Information about where a `ts.Node` can be found in the type check block shim file. */
export interface ShimLocation {
/**
@@ -138,16 +138,12 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
}
overrideComponentTemplate(component: ts.ClassDeclaration, template: string):
{nodes: TmplAstNode[], errors?: ParseError[]} {
{nodes: TmplAstNode[], errors: ParseError[]|null} {
const {nodes, errors} = parseTemplate(template, 'override.html', {
preserveWhitespaces: true,
leadingTriviaChars: [],
});
if (errors !== null) {
return {nodes, errors};
}
const filePath = absoluteFromSourceFile(component.getSourceFile());
const fileRecord = this.getFileData(filePath);
@@ -169,7 +165,7 @@ export class TemplateTypeCheckerImpl implements TemplateTypeChecker {
this.completionCache.delete(component);
this.symbolBuilderCache.delete(component);
return {nodes};
return {nodes, errors};
}
isTrackedTypeCheckFile(filePath: AbsoluteFsPath): boolean {