Last change
on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
4.6 KB
|
Line | |
---|
1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /**
|
---|
9 | * A token representing the a reference to a static type.
|
---|
10 | *
|
---|
11 | * This token is unique for a filePath and name and can be used as a hash table key.
|
---|
12 | */
|
---|
13 | export class StaticSymbol {
|
---|
14 | constructor(filePath, name, members) {
|
---|
15 | this.filePath = filePath;
|
---|
16 | this.name = name;
|
---|
17 | this.members = members;
|
---|
18 | }
|
---|
19 | assertNoMembers() {
|
---|
20 | if (this.members.length) {
|
---|
21 | throw new Error(`Illegal state: symbol without members expected, but got ${JSON.stringify(this)}.`);
|
---|
22 | }
|
---|
23 | }
|
---|
24 | }
|
---|
25 | /**
|
---|
26 | * A cache of static symbol used by the StaticReflector to return the same symbol for the
|
---|
27 | * same symbol values.
|
---|
28 | */
|
---|
29 | export class StaticSymbolCache {
|
---|
30 | constructor() {
|
---|
31 | this.cache = new Map();
|
---|
32 | }
|
---|
33 | get(declarationFile, name, members) {
|
---|
34 | members = members || [];
|
---|
35 | const memberSuffix = members.length ? `.${members.join('.')}` : '';
|
---|
36 | const key = `"${declarationFile}".${name}${memberSuffix}`;
|
---|
37 | let result = this.cache.get(key);
|
---|
38 | if (!result) {
|
---|
39 | result = new StaticSymbol(declarationFile, name, members);
|
---|
40 | this.cache.set(key, result);
|
---|
41 | }
|
---|
42 | return result;
|
---|
43 | }
|
---|
44 | }
|
---|
45 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdGljX3N5bWJvbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL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