positioner

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: GPL-3.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Positioner

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

Positioner is a transformation that only changes positional information. The transformation should be initialized with the source code by calling OnCode.

func FromLineCol added in v2.13.0

func FromLineCol() Positioner

FromLineCol fills the Offset field of all Position nodes by using their Line and Col.

func FromOffset added in v2.13.0

func FromOffset() Positioner

FromOffset fills the Line and Col fields of all Position nodes by using their Offset.

func FromUTF16Offset added in v2.16.4

func FromUTF16Offset() Positioner

FromUTF16Offset fills the Line, Col and Offset fields of all Position nodes by interpreting their Offset as a 0-based UTF-16 code point index.

func FromUnicodeOffset added in v2.13.0

func FromUnicodeOffset() Positioner

FromUnicodeOffset fills the Line, Col and Offset fields of all Position nodes by interpreting their Offset as a 0-based Unicode character index.

func NewFillLineColFromOffset deprecated

func NewFillLineColFromOffset() Positioner

NewFillLineColFromOffset fills the Line and Col fields of all Position nodes by using their Offset.

Deprecated: see FromOffset

func NewFillOffsetFromLineCol deprecated

func NewFillOffsetFromLineCol() Positioner

NewFillOffsetFromLineCol fills the Offset field of all Position nodes by using their Line and Col.

Deprecated: see FromLineCol

func (Positioner) OnCode

func (t Positioner) OnCode(code string) transformer.Transformer

OnCode uses the source code to update positional information of UAST nodes.

type TokenFromSource added in v2.13.0

type TokenFromSource struct {
	// Key is the name of the token field to update. Uses uast.KeyToken, if not set.
	// Only nodes with this field will be considered.
	Key string
	// Types is the list of node types that will be updated. Empty means all nodes.
	Types []string
}

TokenFromSource extract node's token from the source code by using positional information.

func (TokenFromSource) OnCode added in v2.13.0

OnCode implements transformer.CodeTransformer.

type VerifyToken added in v2.13.0

type VerifyToken struct {
	// Key is the name of the token field to check. Uses uast.KeyToken, if not set.
	Key string
	// Types is the list of node types that will be checked. Empty means all nodes.
	Types []string
}

VerifyToken check that node's token matches its positional information.

func (VerifyToken) Verify added in v2.13.0

func (t VerifyToken) Verify(code string, root nodes.Node) error

Jump to

Keyboard shortcuts

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