feat(language-service): Add module name to directive quick info (#39121)
This commit adds the module name as the `containerName` to the quick info for directives. PR Close #39121
This commit is contained in:
parent
01ec0f0933
commit
4604fe9ed2
|
@ -143,9 +143,14 @@ export class QuickInfoBuilder {
|
|||
ts.QuickInfo {
|
||||
const kind = dir.isComponent ? QuickInfoKind.COMPONENT : QuickInfoKind.DIRECTIVE;
|
||||
const documentation = this.getDocumentationFromTypeDefAtLocation(dir.shimLocation);
|
||||
let containerName: string|undefined;
|
||||
if (ts.isClassDeclaration(dir.tsSymbol.valueDeclaration) && dir.ngModule !== null) {
|
||||
containerName = dir.ngModule.name.getText();
|
||||
}
|
||||
|
||||
return createQuickInfo(
|
||||
this.typeChecker.typeToString(dir.tsType), kind, getTextSpanOfNode(node),
|
||||
undefined /* containerName */, undefined, documentation);
|
||||
this.typeChecker.typeToString(dir.tsType), kind, getTextSpanOfNode(node), containerName,
|
||||
undefined, documentation);
|
||||
}
|
||||
|
||||
private getDocumentationFromTypeDefAtLocation(shimLocation: ShimLocation):
|
||||
|
|
|
@ -47,9 +47,7 @@ describe('quick info', () => {
|
|||
expectQuickInfo({
|
||||
templateOverride: `<div string-model¦></div>`,
|
||||
expectedSpanText: 'string-model',
|
||||
// TODO(atscott): Find a way to include the module
|
||||
// expectedDisplayParts: '(directive) AppModule.StringModel'
|
||||
expectedDisplayString: '(directive) StringModel'
|
||||
expectedDisplayString: '(directive) AppModule.StringModel'
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -57,9 +55,7 @@ describe('quick info', () => {
|
|||
const {documentation} = expectQuickInfo({
|
||||
templateOverride: `<t¦est-comp></test-comp>`,
|
||||
expectedSpanText: '<test-comp></test-comp>',
|
||||
// TODO(atscott): Find a way to include the module
|
||||
// expectedDisplayParts: '(component) AppModule.TestComponent'
|
||||
expectedDisplayString: '(component) TestComponent'
|
||||
expectedDisplayString: '(component) AppModule.TestComponent'
|
||||
});
|
||||
expect(toText(documentation)).toBe('This Component provides the `test-comp` selector.');
|
||||
});
|
||||
|
|
|
@ -86,7 +86,7 @@ interface DirectiveClassLike {
|
|||
* For example,
|
||||
* v---------- `decoratorId`
|
||||
* @NgModule({ <
|
||||
* declarations: [], < classDecl
|
||||
* declarations: [], < classDecln-al
|
||||
* }) <
|
||||
* class AppModule {} <
|
||||
* ^----- `classId`
|
||||
|
|
Loading…
Reference in New Issue