astutils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertLinePosToOffsets

func ConvertLinePosToOffsets(base int, lines []token.Pos) []int

ConvertLinePosToOffsets adjusts file lines by base offset for splicing into a file via SetLines call. Note: it is often easier to track newlines in terms of global positions in the file set, however SetLines excepts an array of integer offsets for lines that are relative to the file base.

func FileSpliceLines

func FileSpliceLines(f *token.File, newLines []int) bool

FileSpliceLines adds new lines into a file.

func ShiftCommentGroupPos

func ShiftCommentGroupPos(delta token.Pos, cg *ast.CommentGroup)

ShiftCommentGroupPos moves a comment group and all of its dependent AST notes by a given delta in the fileset.

func ShiftGenDeclPos

func ShiftGenDeclPos(delta token.Pos, spec *ast.GenDecl)

ShiftGenDeclPos moves a declaration spec and all of its dependent AST notes by a given delta in the fileset.

func ShiftImportSpecPos

func ShiftImportSpecPos(delta token.Pos, spec *ast.ImportSpec)

ShiftImportSpecPos moves an import spec and all of its dependent AST notes by a given delta in the fileset.

Types

type PosRange

type PosRange struct {
	Pos token.Pos
	End token.Pos
}

func ASTNodeRangeWithComments

func ASTNodeRangeWithComments(node ast.Node) PosRange

ASTNodeRangeWithComments returns a position range for an AST note, start and end locations with doc and line comments attached to the node accounted for.

Jump to

Keyboard shortcuts

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