fix(language-service): create StaticReflector once only (#32543)

The creation of StaticReflector in createMetadataResolver() is a very expensive operation because it involves numerous module resolutions.
To make matter worse, since the API of the Reflector does not provide the ability to invalidate its internal caches, it has to be destroyed and recreated on *every* program change.
This has a HUGE impact on performance.
This PR fixes this problem by carefully invalidating all StaticSymbols in a file that has changed, thereby reducing the overhead of recomputation on program change.

PR Close #32543
This commit is contained in:
Keen Yee Liau
2019-09-07 11:51:04 -07:00
committed by atscott
parent 900d0055e0
commit adb562bca6
5 changed files with 51 additions and 35 deletions

View File

@ -280,7 +280,7 @@ export class UndecoratedClassesTransform {
return [{
node,
message: `Class cannot be migrated as the inherited metadata from ` +
`${identifier.getText()} cannot be converted into a decorator. Please manually
`${identifier.getText()} cannot be converted into a decorator. Please manually
decorate the class.`,
}];
}
@ -431,7 +431,7 @@ export class UndecoratedClassesTransform {
// future calls to "StaticReflector#annotations" are based on metadata files.
this.symbolResolver['_resolveSymbolFromSummary'] = () => null;
this.symbolResolver['resolvedSymbols'].clear();
this.symbolResolver['resolvedFilePaths'].clear();
this.symbolResolver['symbolFromFile'].clear();
this.compiler.reflector['annotationCache'].clear();
// Original summary resolver used by the AOT compiler.