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

Function generateCloneBody

packages/alphatab/scripts/CloneEmitter.ts:261–298  ·  view source on GitHub ↗
(
    program: ts.Program,
    input: ts.ClassDeclaration,
    importer: (name: string, module: string) => void
)

Source from the content-addressed store, hash-verified

259}
260
261function generateCloneBody(
262 program: ts.Program,
263 input: ts.ClassDeclaration,
264 importer: (name: string, module: string) => void
265): ts.Block {
266 const propertiesToSerialize = input.members
267 .filter(m => ts.isPropertyDeclaration(m) && isCloneMember(m))
268 .map(m => m as ts.PropertyDeclaration);
269
270 const bodyStatements = propertiesToSerialize.reduce((stmts, prop) => {
271 stmts.push(...generateClonePropertyStatements(prop, program, importer));
272 return stmts;
273 }, [] as ts.Statement[]);
274
275 return ts.factory.createBlock(
276 [
277 // const clone = new Type();
278 ts.factory.createVariableStatement(
279 undefined,
280 ts.factory.createVariableDeclarationList(
281 [
282 ts.factory.createVariableDeclaration(
283 'clone',
284 undefined,
285 undefined,
286 ts.factory.createNewExpression(ts.factory.createIdentifier(input.name!.text), undefined, [])
287 )
288 ],
289 ts.NodeFlags.Const
290 )
291 ),
292 ...bodyStatements,
293 // return json;
294 ts.factory.createReturnStatement(ts.factory.createIdentifier('clone'))
295 ],
296 true
297 );
298}
299
300function createCloneMethod(
301 program: ts.Program,

Callers 1

createCloneMethodFunction · 0.85

Calls 6

isCloneMemberFunction · 0.85
filterMethod · 0.80
mapMethod · 0.45
reduceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected