fix(language-service): global autocomplete doesn't work when the user tries to modify the symbol (#42923)

When the user tries to trigger suggestions from an interruption,
the LS should provide the global completions. For example,
`[input]="t¦"`, the `t` can be the `true` or the symbol from
the component context.

PR Close #42923
This commit is contained in:
ivanwonder
2021-07-22 17:54:26 +08:00
committed by atscott
parent f62366fd16
commit f0c5ba08f6
2 changed files with 26 additions and 1 deletions
@@ -7,7 +7,7 @@
*/
import {TmplAstReference, TmplAstTemplate} from '@angular/compiler';
import {AST, EmptyExpr, LiteralPrimitive, MethodCall, PropertyRead, PropertyWrite, SafeMethodCall, SafePropertyRead, TmplAstNode} from '@angular/compiler/src/compiler';
import {AST, EmptyExpr, ImplicitReceiver, LiteralPrimitive, MethodCall, PropertyRead, PropertyWrite, SafeMethodCall, SafePropertyRead, TmplAstNode} from '@angular/compiler/src/compiler';
import {TextAttribute} from '@angular/compiler/src/render3/r3_ast';
import * as ts from 'typescript';
@@ -91,6 +91,19 @@ export class CompletionEngine {
}
}
if (node instanceof PropertyRead && node.receiver instanceof ImplicitReceiver) {
const nodeLocation = findFirstMatchingNode(this.tcb, {
filter: ts.isPropertyAccessExpression,
withSpan: node.sourceSpan,
});
if (nodeLocation) {
nodeContext = {
shimPath: this.shimPath,
positionInShimFile: nodeLocation.getStart(),
};
}
}
return {
componentContext: this.componentContext,
templateContext,