Skip to content

Commit

Permalink
fix(language-service): do not crash when hovering over a label defini…
Browse files Browse the repository at this point in the history
…tions (angular#17974)

Fixes: angular#17972
  • Loading branch information
chuckjaz authored and jasonaden committed Jul 8, 2017
1 parent 9c3217d commit 38f2670
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/language-service/src/locate_symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {},
Expand Down
10 changes: 10 additions & 0 deletions packages/language-service/test/hover_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 38f2670

Please sign in to comment.