remap

package
v5.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package remap handles tracking the locations of Go tokens in a source text across a rewrite by the Go formatter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	Pos, End int // End is exclusive
}

A Location represents a span of byte offsets in the source text.

type Map

type Map map[Location]Location

A Map represents a mapping between token locations in an input source text and locations in the correspnding output text.

func Compute

func Compute(input, output []byte) (Map, error)

Compute constructs a location mapping from input to output. An error is reported if any of the tokens of output cannot be mapped.

func (Map) Find

func (m Map) Find(pos, end int) (Location, bool)

Find reports whether the specified span is recorded by m, and if so returns the new location it was mapped to. If the input span was not found, the returned location is the same as the input.

Jump to

Keyboard shortcuts

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