MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / handleMember

Function handleMember

packages/alphatab/scripts/TypeSchema.ts:39–89  ·  view source on GitHub ↗
(
        member: ts.ClassDeclaration['members'][0],
        typeArgumentMapping: Map<string, ts.Type> | undefined
    )

Source from the content-addressed store, hash-verified

37 };
38
39 const handleMember = (
40 member: ts.ClassDeclaration['members'][0],
41 typeArgumentMapping: Map<string, ts.Type> | undefined
42 ) => {
43 if (ts.isPropertyDeclaration(member)) {
44 const propertyDeclaration = member as ts.PropertyDeclaration;
45 if (
46 !propertyDeclaration.modifiers!.find(
47 m => m.kind === ts.SyntaxKind.StaticKeyword || m.kind === ts.SyntaxKind.PrivateKeyword
48 )
49 ) {
50 const jsonNames = [(member.name as ts.Identifier).text.toLowerCase()];
51 const jsDoc = ts.getJSDocTags(member);
52
53 if (jsDoc.find(t => t.tagName.text === 'json_on_parent')) {
54 jsonNames.push('');
55 }
56
57 if (!jsDoc.find(t => t.tagName.text === 'json_ignore')) {
58 const asRaw = !!jsDoc.find(t => t.tagName.text === 'json_raw');
59 const isReadonly = !!jsDoc.find(t => t.tagName.text === 'json_read_only');
60 schema.properties.push({
61 jsonNames: jsonNames,
62 asRaw,
63 partialNames: !!jsDoc.find(t => t.tagName.text === 'json_partial_names'),
64 target: jsDoc.find(t => t.tagName.text === 'target')?.comment as string,
65 isJsonReadOnly: isReadonly,
66 isReadOnly: propertyDeclaration.modifiers!.some(m => m.kind == ts.SyntaxKind.ReadonlyKeyword),
67 name: (member.name as ts.Identifier).text,
68 jsDocTags: jsDoc,
69 type: getTypeWithNullableInfo(
70 program,
71 member.type ?? program.getTypeChecker().getTypeAtLocation(member.name),
72 asRaw || isReadonly,
73 !!member.questionToken,
74 typeArgumentMapping
75 )
76 });
77 }
78 }
79 } else if (ts.isMethodDeclaration(member)) {
80 switch ((member.name as ts.Identifier).text) {
81 case 'toJson':
82 schema.hasToJsonExtension = true;
83 break;
84 case 'setProperty':
85 schema.hasSetPropertyExtension = true;
86 break;
87 }
88 }
89 };
90
91 let hierarchy: ts.ClassDeclaration | undefined = input;
92 let typeArgumentMapping: Map<string, ts.Type> | undefined;

Callers 1

buildTypeSchemaFunction · 0.85

Calls 3

getTypeWithNullableInfoFunction · 0.85
someMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected