feat(language-service): allow retreiving synchronized analyzed NgModules (#32779)

Sometimes modules retreived from the language service need to be
synchronized to the last time they were updated, and not updated
on-the-fly. This PR adds a flag to
`TypeScriptServiceHost#getAnalyzedModules` that retreives cached
analyzed NgModules rather than potentially recomputing them.

PR Close #32779
This commit is contained in:
ayazhafiz
2019-09-19 16:26:39 -05:00
committed by atscott
parent 28358b6395
commit 98feee7e0e
2 changed files with 33 additions and 2 deletions

View File

@ -152,9 +152,13 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
* and templateReferences.
* In addition to returning information about NgModules, this method plays the
* same role as 'synchronizeHostData' in tsserver.
* @param ensureSynchronized whether or not the Language Service should make sure analyzedModules
* are synced to the last update of the project. If false, returns the set of analyzedModules
* that is already cached. This is useful if the project must not be reanalyzed, even if its
* file watchers (which are disjoint from the TypeScriptServiceHost) detect an update.
*/
getAnalyzedModules(): NgAnalyzedModules {
if (this.upToDate()) {
getAnalyzedModules(ensureSynchronized = true): NgAnalyzedModules {
if (!ensureSynchronized || this.upToDate()) {
return this.analyzedModules;
}