feat(language-service): module definitions on directive hover (#32763)

Adds information about the NgModule a Directive is declared in when the
Directive class name is hovered over, in the form

```
(directive) NgModule.Directive: class
```

Closes #32565

PR Close #32763
This commit is contained in:
ayazhafiz
2019-09-16 21:07:43 -05:00
committed by atscott
parent 3de59d48b5
commit 0d186dda35
3 changed files with 96 additions and 1 deletions

View File

@ -148,6 +148,25 @@ describe('hover', () => {
const quickInfo = ngLS.getHoverAt(fileName, marker.start);
expect(quickInfo).toBeUndefined();
});
it('should be able to find a directive module', () => {
const fileName = '/app/app.component.ts';
mockHost.override(fileName, `
import {Component} from '@angular/core';
@Component({
template: '<div></div>'
})
export class «AppComponent» {
name: string;
}`);
const marker = mockHost.getReferenceMarkerFor(fileName, 'AppComponent');
const quickInfo = ngLS.getHoverAt(fileName, marker.start);
expect(quickInfo).toBeTruthy();
const {textSpan, displayParts} = quickInfo !;
expect(textSpan).toEqual(marker);
expect(toText(displayParts)).toBe('(directive) AppModule.AppComponent: class');
});
});
function toText(displayParts?: ts.SymbolDisplayPart[]): string {