mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This allows a build using summaries to not need .metadata.json files at all any more. Part of #12787
36 lines
No EOL
1.1 KiB
TypeScript
36 lines
No EOL
1.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* A token representing the a reference to a static type.
|
|
*
|
|
* This token is unique for a filePath and name and can be used as a hash table key.
|
|
*/
|
|
export class StaticSymbol {
|
|
constructor(public filePath: string, public name: string, public members?: string[]) {}
|
|
}
|
|
|
|
/**
|
|
* A cache of static symbol used by the StaticReflector to return the same symbol for the
|
|
* same symbol values.
|
|
*/
|
|
export class StaticSymbolCache {
|
|
private cache = new Map<string, StaticSymbol>();
|
|
|
|
get(declarationFile: string, name: string, members?: string[]): StaticSymbol {
|
|
members = members || [];
|
|
const memberSuffix = members.length ? `.${ members.join('.')}` : '';
|
|
const key = `"${declarationFile}".${name}${memberSuffix}`;
|
|
let result = this.cache.get(key);
|
|
if (!result) {
|
|
result = new StaticSymbol(declarationFile, name, members);
|
|
this.cache.set(key, result);
|
|
}
|
|
return result;
|
|
}
|
|
} |