feat(language-service): support hover/definitions for structural directive (#34564)

PR Close #34564
This commit is contained in:
ivanwonder
2019-12-26 15:19:38 +08:00
committed by atscott
parent 7325053dfa
commit 5260021447
3 changed files with 51 additions and 10 deletions

View File

@ -150,16 +150,14 @@ function findAttribute(info: AstResult, position: number): Attribute|undefined {
function findInputBinding(
info: AstResult, path: TemplateAstPath, binding: BoundDirectivePropertyAst): Symbol|undefined {
const element = path.first(ElementAst);
if (element) {
for (const directive of element.directives) {
const invertedInput = invertMap(directive.directive.inputs);
const fieldName = invertedInput[binding.templateName];
if (fieldName) {
const classSymbol = info.template.query.getTypeSymbol(directive.directive.type.reference);
if (classSymbol) {
return classSymbol.members().get(fieldName);
}
const directive = path.parentOf(path.tail);
if (directive instanceof DirectiveAst) {
const invertedInput = invertMap(directive.directive.inputs);
const fieldName = invertedInput[binding.templateName];
if (fieldName) {
const classSymbol = info.template.query.getTypeSymbol(directive.directive.type.reference);
if (classSymbol) {
return classSymbol.members().get(fieldName);
}
}
}