-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathnodesUtils.ts
More file actions
28 lines (22 loc) · 845 Bytes
/
nodesUtils.ts
File metadata and controls
28 lines (22 loc) · 845 Bytes
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
import {TokenObject} from "../compiler_tokenizer/tokenObject";
import {EntityAttribute, NodeType, ReferenceModifier} from "./nodes";
export function isEntityModifierForClass(modifier: EntityAttribute) {
return modifier.isAbstract || modifier.isFinal;
}
export function stringifyNodeType(type: NodeType): string {
let str = type.isConst ? 'const ' : '';
str += type.dataType.identifier.text;
if (type.typeTemplates.length > 0) {
str += '<' + type.typeTemplates.map(stringifyNodeType).join(', ') + '>';
}
if (type.isArray) {
str += '[]';
}
if (type.refModifier !== undefined) {
str += (type.refModifier === ReferenceModifier.AtConst ? '@const' : '@');
}
return str;
}
export function getIdentifierInNodeType(type: NodeType): TokenObject {
return type.dataType.identifier;
}