fix(language-service): do not crash when hovering over a label definitions (#17974)

Fixes: #17972
This commit is contained in:
Chuck Jazdzewski 2017-07-07 09:46:18 -06:00 committed by Jason Aden
parent ae27af7399
commit 3b2d2c467a
2 changed files with 11 additions and 1 deletions

View File

@ -68,7 +68,7 @@ export function locateSymbol(info: TemplateInfo): SymbolInfo|undefined {
}
},
visitReference(ast) {
symbol = info.template.query.getTypeSymbol(tokenReference(ast.value));
symbol = ast.value && info.template.query.getTypeSymbol(tokenReference(ast.value));
span = spanOf(ast);
},
visitVariable(ast) {},

View File

@ -68,6 +68,16 @@ describe('hover', () => {
'property name of TestComponent');
});
it('should be able to ignore a reference declaration', () => {
addCode(
` @Component({template: '<div #«chart»></div>'}) export class MyComponent { }`,
fileName => {
const markers = mockHost.getReferenceMarkers(fileName) !;
const hover = ngService.getHoverAt(fileName, markers.references.chart[0].start);
expect(hover).toBeUndefined();
});
});
function hover(code: string, hoverText: string) {
addCode(code, fileName => {
let tests = 0;