edit

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 6 Imported by: 11

Documentation

Overview

Package edit contains helpers for creating suggested fixes.

Index

Constants

This section is empty.

Variables

This section is empty.

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.

Jump to

Keyboard shortcuts

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