fix(language-service): improve performance of updateModuleAnalysis()
(#15543)
This commit is contained in:

committed by
Victor Berchet

parent
d438b88f19
commit
6269d28bb0
@ -59,6 +59,7 @@ export class StaticSymbolResolver {
|
||||
// Note: this will only contain StaticSymbols without members!
|
||||
private importAs = new Map<StaticSymbol, StaticSymbol>();
|
||||
private symbolResourcePaths = new Map<StaticSymbol, string>();
|
||||
private symbolFromFile = new Map<string, StaticSymbol[]>();
|
||||
|
||||
constructor(
|
||||
private host: StaticSymbolResolverHost, private staticSymbolCache: StaticSymbolCache,
|
||||
@ -143,6 +144,25 @@ export class StaticSymbolResolver {
|
||||
this.importAs.set(sourceSymbol, targetSymbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate all information derived from the given file.
|
||||
*
|
||||
* @param fileName the file to invalidate
|
||||
*/
|
||||
invalidateFile(fileName: string) {
|
||||
this.metadataCache.delete(fileName);
|
||||
this.resolvedFilePaths.delete(fileName);
|
||||
const symbols = this.symbolFromFile.get(fileName);
|
||||
if (symbols) {
|
||||
this.symbolFromFile.delete(fileName);
|
||||
for (const symbol of symbols) {
|
||||
this.resolvedSymbols.delete(symbol);
|
||||
this.importAs.delete(symbol);
|
||||
this.symbolResourcePaths.delete(symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _resolveSymbolMembers(staticSymbol: StaticSymbol): ResolvedStaticSymbol {
|
||||
const members = staticSymbol.members;
|
||||
const baseResolvedSymbol =
|
||||
@ -281,6 +301,7 @@ export class StaticSymbolResolver {
|
||||
}
|
||||
resolvedSymbols.forEach(
|
||||
(resolvedSymbol) => this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol));
|
||||
this.symbolFromFile.set(filePath, resolvedSymbols.map(resolvedSymbol => resolvedSymbol.symbol));
|
||||
}
|
||||
|
||||
private createResolvedSymbol(
|
||||
|
Reference in New Issue
Block a user