forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecorator.ts
More file actions
39 lines (34 loc) · 1.17 KB
/
Decorator.ts
File metadata and controls
39 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export class Decorator {
public static isValid(decoratorKindString: string): boolean {
return this.getDecoratorKind(decoratorKindString) !== undefined;
}
public static getDecoratorKind(decoratorKindString: string): DecoratorKind | undefined {
return Object.values(DecoratorKind).find(
decoratorKind => decoratorKind.toLowerCase() === decoratorKindString.toLowerCase()
);
}
public kind: DecoratorKind;
constructor(name: string, public args: string[]) {
const kind = Decorator.getDecoratorKind(name);
if (kind === undefined) {
throw new Error(`Failed to parse decorator '${name}'`);
}
this.kind = kind;
}
}
export enum DecoratorKind {
Extension = "Extension",
MetaExtension = "MetaExtension",
CustomConstructor = "CustomConstructor",
CompileMembersOnly = "CompileMembersOnly",
NoResolution = "NoResolution",
PureAbstract = "PureAbstract",
Phantom = "Phantom",
TupleReturn = "TupleReturn",
LuaIterator = "LuaIterator",
LuaTable = "LuaTable",
NoSelf = "NoSelf",
NoSelfInFile = "NoSelfInFile",
Vararg = "Vararg",
ForRange = "ForRange",
}