Source Maps
(source sourcemap.Source)
| 5776 | // |
| 5777 | |
| 5778 | func (p *Printer) setSourceMapSource(source sourcemap.Source) { |
| 5779 | if p.sourceMapsDisabled { |
| 5780 | return |
| 5781 | } |
| 5782 | |
| 5783 | p.sourceMapSource = source |
| 5784 | p.sourceMapLineCharCache = newLineCharacterCache(source) |
| 5785 | if p.mostRecentSourceMapSource == source { |
| 5786 | p.sourceMapSourceIndex = p.mostRecentSourceMapSourceIndex |
| 5787 | return |
| 5788 | } |
| 5789 | |
| 5790 | p.sourceMapSourceIsJson = tspath.FileExtensionIs(source.FileName(), tspath.ExtensionJson) |
| 5791 | if p.sourceMapSourceIsJson { |
| 5792 | return |
| 5793 | } |
| 5794 | |
| 5795 | p.sourceMapSourceIndex = p.sourceMapGenerator.AddSource(source.FileName()) |
| 5796 | if p.Options.InlineSources { |
| 5797 | if err := p.sourceMapGenerator.SetSourceContent(p.sourceMapSourceIndex, source.Text()); err != nil { |
| 5798 | panic(err) |
| 5799 | } |
| 5800 | } |
| 5801 | |
| 5802 | p.mostRecentSourceMapSource = source |
| 5803 | p.mostRecentSourceMapSourceIndex = p.sourceMapSourceIndex |
| 5804 | } |
| 5805 | |
| 5806 | func (p *Printer) emitPos(pos int) { |
| 5807 | if p.sourceMapsDisabled || p.sourceMapSource == nil || p.sourceMapGenerator == nil || p.sourceMapSourceIsJson || ast.PositionIsSynthesized(pos) { |
no test coverage detected