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

@ -12,7 +12,7 @@ import {isAstResult} from './common';
import {getTemplateCompletions} from './completions';
import {getDefinitionAndBoundSpan, getTsDefinitionAndBoundSpan} from './definitions';
import {getDeclarationDiagnostics, getTemplateDiagnostics, ngDiagnosticToTsDiagnostic, uniqueBySpan} from './diagnostics';
import {getHover} from './hover';
import {getHover, getTsHover} from './hover';
import {Diagnostic, LanguageService} from './types';
import {TypeScriptServiceHost} from './typescript_host';
@ -97,5 +97,14 @@ class LanguageServiceImpl implements LanguageService {
if (templateInfo) {
return getHover(templateInfo, position);
}
// Attempt to get Angular-specific hover information in a TypeScript file, the NgModule a
// directive belongs to.
if (fileName.endsWith('.ts')) {
const sf = this.host.getSourceFile(fileName);
if (sf) {
return getTsHover(sf, position, this.host);
}
}
}
}