MCPcopy Create free account
hub / github.com/compilets/compilets / parseFunctionDeclaration

Method parseFunctionDeclaration

src/parser.ts:444–464  ·  view source on GitHub ↗
(node: ts.FunctionDeclaration)

Source from the content-addressed store, hash-verified

442 }
443
444 parseFunctionDeclaration(node: ts.FunctionDeclaration): syntax.FunctionDeclaration {
445 if (!node.name)
446 throw new UnimplementedError(node, 'Empty function name is not supported');
447 if (node.asteriskToken)
448 throw new UnimplementedError(node, 'Generator is not supported');
449 if (node.questionToken)
450 throw new UnimplementedError(node, 'Question token in function is not supported');
451 if (node.exclamationToken)
452 throw new UnimplementedError(node, 'Exclamation token in function is not supported');
453 if (node.modifiers?.find(m => m.kind == ts.SyntaxKind.AsyncKeyword))
454 throw new UnimplementedError(node, 'Async function is not supported');
455 if (!ts.isSourceFile(node.parent))
456 throw new UnimplementedError(node, 'Local function declaration is not supported');
457 const {body, name, parameters} = node;
458 this.typer.forbidClosure(node);
459 return new syntax.FunctionDeclaration(this.typer.parseNodeType(node) as syntax.FunctionType,
460 isExportedDeclaration(node),
461 name.text,
462 this.parseParameters(parameters),
463 body ? this.parseStatement(body) as syntax.Block : undefined);
464 }
465
466 parseFunctionExpression(node: ts.FunctionExpression | ts.ArrowFunction): syntax.FunctionExpression {
467 const {body, parameters, modifiers, asteriskToken, exclamationToken, questionToken, typeParameters} = node;

Callers 1

parseSourceFileMethod · 0.95

Calls 5

parseParametersMethod · 0.95
parseStatementMethod · 0.95
isExportedDeclarationFunction · 0.90
forbidClosureMethod · 0.80
parseNodeTypeMethod · 0.80

Tested by

no test coverage detected