sourcemap

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapping

type Mapping struct {
	// Generated position (in output)
	GeneratedLine   int
	GeneratedColumn int

	// Original position (in source)
	SourceLine   int
	SourceColumn int

	// Optional: index into the names array
	NameIndex int
	HasName   bool
}

Mapping represents a single source map mapping entry. It connects a position in the generated code to a position in the original source.

type SourceMap

type SourceMap struct {
	Version        int      `json:"version"`
	File           string   `json:"file,omitempty"`
	SourceRoot     string   `json:"sourceRoot,omitempty"`
	Sources        []string `json:"sources"`
	SourcesContent []string `json:"sourcesContent,omitempty"`
	Names          []string `json:"names,omitempty"`
	Mappings       string   `json:"mappings"`
}

SourceMap represents a Source Map v3 structure.

type SourceMapper

type SourceMapper struct {
	// contains filtered or unexported fields
}

SourceMapper accumulates mappings during code generation. It tracks the current position in the generated output and allows adding mappings back to the original source positions.

func New

func New() *SourceMapper

New creates a new SourceMapper for the given source file.

func (*SourceMapper) AddMapping

func (m *SourceMapper) AddMapping(sourceLine, sourceColumn int)

AddMapping records a mapping from the current generated position to the given original source position (0-based line and column from token).

func (*SourceMapper) AddNamedMapping

func (m *SourceMapper) AddNamedMapping(sourceLine, sourceColumn int, name string)

AddNamedMapping records a mapping with an associated name (for identifiers).

func (*SourceMapper) AdvanceColumn

func (m *SourceMapper) AdvanceColumn(n int)

AdvanceColumn advances the generated column position by n characters.

func (*SourceMapper) AdvanceLine

func (m *SourceMapper) AdvanceLine()

NewLine advances to the next line in the generated output.

func (*SourceMapper) AdvanceString

func (m *SourceMapper) AdvanceString(s string)

AdvanceString advances the position based on the content of a string, handling newlines appropriately.

func (*SourceMapper) SourceMap

func (m *SourceMapper) SourceMap() *SourceMap

SourceMap produces the final SourceMap structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL