refactor(language-service): test case (#34564)

PR Close #34564
This commit is contained in:
ivanwonder
2020-01-04 11:30:14 +08:00
committed by atscott
parent 7005645592
commit c8c6fd7153
3 changed files with 21 additions and 37 deletions

View File

@ -148,14 +148,14 @@ function findAttribute(info: AstResult, position: number): Attribute|undefined {
return path.first(Attribute);
}
function findParentOfDirectivePropertyAst(ast: TemplateAst[], binding: BoundDirectivePropertyAst) {
function findParentOfBinding(ast: TemplateAst[], binding: BoundDirectivePropertyAst) {
let res: DirectiveAst|undefined;
const visitor = new class extends RecursiveTemplateAstVisitor {
visitDirective(ast: DirectiveAst) {
const result = this.visitChildren(ast, visit => { visit(ast.inputs); });
return result;
}
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any) {
visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: DirectiveAst) {
if (ast === binding) {
res = context;
}
@ -167,7 +167,7 @@ function findParentOfDirectivePropertyAst(ast: TemplateAst[], binding: BoundDire
function findInputBinding(
info: AstResult, path: TemplateAstPath, binding: BoundDirectivePropertyAst): Symbol|undefined {
const directiveAst = findParentOfDirectivePropertyAst(info.templateAst, binding);
const directiveAst = findParentOfBinding(info.templateAst, binding);
if (directiveAst) {
const invertedInput = invertMap(directiveAst.directive.inputs);
const fieldName = invertedInput[binding.templateName];