sourcemap

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sourcemap maps positions in emitted Go back to .gpp source.

Because emission is text-edit-based (intra-line splices plus inserted header/marker lines) and then gofmt-formatted, a line-level diff between source and output recovers an accurate mapping: unchanged lines map exactly, spliced lines map with line fidelity, inserted lines attribute to the nearest preceding mapped line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	GppPath string
	// contains filtered or unexported fields
}

Map maps one emitted file's positions to its .gpp source.

func Build

func Build(gppPath string, gppSrc, emitted []byte) *Map

Build diffs gpp source against emitted output.

func (*Map) Forward added in v0.9.0

func (m *Map) Forward(pos token.Position) (token.Position, bool)

Forward maps a .gpp position to its emitted counterpart — the inverse direction, built from the same line pairing (the first emitted line attributed to the .gpp line wins; columns carry over on exact lines and clamp to column 1 otherwise). ok is false for .gpp lines with no emitted counterpart.

func (*Map) Map

func (m *Map) Map(pos token.Position) (token.Position, bool)

Map translates an emitted-file position to a .gpp position. ok is false when the line has no plausible source counterpart (e.g. the header).

Jump to

Keyboard shortcuts

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