(node *ast.Node)
| 4602 | } |
| 4603 | |
| 4604 | func (p *Printer) emitHelpers(node *ast.Node) bool { |
| 4605 | helpersEmitted := false |
| 4606 | sourceFile := p.currentSourceFile |
| 4607 | shouldSkip := p.Options.NoEmitHelpers || (sourceFile != nil && p.emitContext.HasRecordedExternalHelpers(sourceFile)) |
| 4608 | helpers := slices.Clone(p.emitContext.GetEmitHelpers(node)) |
| 4609 | if len(helpers) > 0 { |
| 4610 | slices.SortStableFunc(helpers, compareEmitHelpers) |
| 4611 | for _, helper := range helpers { |
| 4612 | if !helper.Scoped { |
| 4613 | // Skip the helper if it can be skipped and the noEmitHelpers compiler |
| 4614 | // option is set, or if it can be imported and the importHelpers compiler |
| 4615 | // option is set. |
| 4616 | if shouldSkip { |
| 4617 | continue |
| 4618 | } |
| 4619 | } |
| 4620 | if helper.TextCallback != nil { |
| 4621 | p.writeLines(helper.TextCallback(p.makeFileLevelOptimisticUniqueName)) |
| 4622 | } else { |
| 4623 | p.writeLines(helper.Text) |
| 4624 | } |
| 4625 | helpersEmitted = true |
| 4626 | } |
| 4627 | } |
| 4628 | |
| 4629 | return helpersEmitted |
| 4630 | } |
| 4631 | |
| 4632 | func (p *Printer) emitSourceFile(node *ast.SourceFile) { |
| 4633 | savedCurrentSourceFile := p.currentSourceFile |
no test coverage detected