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

Method VisitIterationBody

internal/printer/emitcontext.go:919–943  ·  view source on GitHub ↗
(body *ast.Statement, visitor *ast.NodeVisitor)

Source from the content-addressed store, hash-verified

917}
918
919func (c *EmitContext) VisitIterationBody(body *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement {
920 if body == nil {
921 return nil
922 }
923
924 c.StartLexicalEnvironment()
925 updated := c.VisitEmbeddedStatement(body, visitor)
926 if updated == nil {
927 panic("Expected visitor to return a statement.")
928 }
929
930 statements := c.EndLexicalEnvironment()
931 if len(statements) > 0 {
932 if ast.IsBlock(updated) {
933 statements = append(statements, updated.Statements()...)
934 statementsList := c.Factory.NewNodeList(statements)
935 statementsList.Loc = updated.StatementList().Loc
936 return c.Factory.UpdateBlock(updated.AsBlock(), statementsList, updated.AsBlock().MultiLine)
937 }
938 statements = append(statements, updated)
939 return c.Factory.NewBlock(c.Factory.NewNodeList(statements), true /*multiLine*/)
940 }
941
942 return updated
943}
944
945func (c *EmitContext) VisitEmbeddedStatement(node *ast.Statement, visitor *ast.NodeVisitor) *ast.Statement {
946 if node == nil {

Calls 13

EndLexicalEnvironmentMethod · 0.95
IsBlockFunction · 0.92
panicFunction · 0.85
lenFunction · 0.85
StatementsMethod · 0.80
NewNodeListMethod · 0.80
StatementListMethod · 0.80
UpdateBlockMethod · 0.80
AsBlockMethod · 0.80
NewBlockMethod · 0.80

Tested by

no test coverage detected