MCPcopy Create free account
hub / github.com/microsoft/typescript-go / VisitFunctionBody

Method VisitFunctionBody

internal/printer/emitcontext.go:895–917  ·  view source on GitHub ↗
(node *ast.BlockOrExpression, visitor *ast.NodeVisitor)

Source from the content-addressed store, hash-verified

893}
894
895func (c *EmitContext) VisitFunctionBody(node *ast.BlockOrExpression, visitor *ast.NodeVisitor) *ast.BlockOrExpression {
896 // !!! c.resumeVariableEnvironment()
897 updated := visitor.VisitNode(node)
898 declarations := c.EndVariableEnvironment()
899 if len(declarations) == 0 {
900 return updated
901 }
902
903 if updated == nil {
904 return c.Factory.NewBlock(c.Factory.NewNodeList(declarations), true /*multiLine*/)
905 }
906
907 if !ast.IsBlock(updated) {
908 statements := c.MergeEnvironment([]*ast.Statement{c.Factory.NewReturnStatement(updated)}, declarations)
909 return c.Factory.NewBlock(c.Factory.NewNodeList(statements), false /*multiLine*/)
910 }
911
912 return c.Factory.UpdateBlock(
913 updated.AsBlock(),
914 c.MergeEnvironmentList(updated.StatementList(), declarations),
915 updated.AsBlock().MultiLine,
916 )
917}
918
919func (c *EmitContext) VisitIterationBody(body *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement {
920 if body == nil {

Calls 12

MergeEnvironmentMethod · 0.95
MergeEnvironmentListMethod · 0.95
IsBlockFunction · 0.92
lenFunction · 0.85
VisitNodeMethod · 0.80
NewBlockMethod · 0.80
NewNodeListMethod · 0.80
NewReturnStatementMethod · 0.80
UpdateBlockMethod · 0.80
AsBlockMethod · 0.80
StatementListMethod · 0.80

Tested by

no test coverage detected