Skip to content

Commit 22c0b4a

Browse files
committed
feat(schema): discrete entry class
1 parent 63f472c commit 22c0b4a

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sourcemod-dev/schema",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"files": [

schema/src/classes/symbol/enumeration.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ export class Enumeration extends Declaration implements IEnumeration, Searchable
66
* @brief Enum entries
77
* @readonly
88
*/
9-
readonly entries: Record<string, IEntry>;
9+
readonly entries: Record<string, Entry>;
1010

1111
readonly identifier: Identifier = Identifier.Enumeration;
1212

1313
public constructor(enumeration: IEnumeration) {
1414
super(enumeration);
1515

16-
this.entries = enumeration.entries;
16+
this.entries = Object.keys(enumeration.entries).reduce((acc, key) => {
17+
acc[key] = new Entry(enumeration.entries[key]);
18+
19+
return acc;
20+
}, {} as Record<string, Entry>);
1721
}
1822

1923
public async search(needle: string, options: Readonly<SearchOptions>): Promise<SearchResult[]> {
@@ -24,7 +28,7 @@ export class Enumeration extends Declaration implements IEnumeration, Searchable
2428
];
2529

2630
ret[0].score += 0.01;
27-
31+
2832
localOptions.parents.push(`${this.identifier}.${this.name}`);
2933

3034
if (localOptions.l1Only !== true) {
@@ -50,3 +54,18 @@ export class Enumeration extends Declaration implements IEnumeration, Searchable
5054
return ret;
5155
}
5256
}
57+
58+
export class Entry extends Declaration implements IEntry {
59+
/**
60+
* @brief Value that are explicitly set in code expressions
61+
*/
62+
value?: string;
63+
64+
readonly identifier: Identifier = Identifier.EnumerationEntry;
65+
66+
constructor(entry: IEntry) {
67+
super(entry);
68+
69+
this.value = entry.value;
70+
}
71+
}

0 commit comments

Comments
 (0)