From 3b2d2c467a98e0585ef79113fcf1f828a2dfbae9 Mon Sep 17 00:00:00 2001 From: Chuck Jazdzewski Date: Fri, 7 Jul 2017 09:46:18 -0600 Subject: [PATCH] fix(language-service): do not crash when hovering over a label definitions (#17974) Fixes: #17972 --- packages/language-service/src/locate_symbol.ts | 2 +- packages/language-service/test/hover_spec.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/language-service/src/locate_symbol.ts b/packages/language-service/src/locate_symbol.ts index d9e497b5f1..9dd47837bf 100644 --- a/packages/language-service/src/locate_symbol.ts +++ b/packages/language-service/src/locate_symbol.ts @@ -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) {}, diff --git a/packages/language-service/test/hover_spec.ts b/packages/language-service/test/hover_spec.ts index 3cada95ae2..b07ecb79c5 100644 --- a/packages/language-service/test/hover_spec.ts +++ b/packages/language-service/test/hover_spec.ts @@ -68,6 +68,16 @@ describe('hover', () => { 'property name of TestComponent'); }); + it('should be able to ignore a reference declaration', () => { + addCode( + ` @Component({template: '
'}) 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;