package edit

import "honnef.co/go/tools/analysis/edit"

Package edit contains helpers for creating suggested fixes.

Index

Functions

func Delete

func Delete(old Ranger) analysis.TextEdit

Delete deletes a range of code.

func Fix

func Fix(msg string, edits ...analysis.TextEdit) analysis.SuggestedFix

func ReplaceWithNode

func ReplaceWithNode(fset *token.FileSet, old Ranger, new ast.Node) analysis.TextEdit

ReplaceWithNode replaces a range with an AST node.

func ReplaceWithPattern

func ReplaceWithPattern(fset *token.FileSet, old Ranger, new pattern.Pattern, state pattern.State) analysis.TextEdit

ReplaceWithPattern replaces a range with the result of executing a pattern.

func ReplaceWithString

func ReplaceWithString(old Ranger, new string) analysis.TextEdit

ReplaceWithString replaces a range with a string.

func Selector

func Selector(x, sel string) *ast.SelectorExpr

Selector creates a new selector expression.

Types

type Range

type Range [2]token.Pos

Range implements the Ranger interface.

func (Range) End

func (r Range) End() token.Pos

func (Range) Pos

func (r Range) Pos() token.Pos

type Ranger

type Ranger interface {
	Pos() token.Pos
	End() token.Pos
}

Ranger describes values that have a start and end position. In most cases these are either ast.Node or manually constructed ranges.

Source Files

edit.go

Version
v0.5.0-rc.1
Published
Jul 1, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
2 minutes ago

Tools for package owners.