changesig

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package changesig is the change-signature engine: it adds, removes, or renames a parameter on a function/method and rewrites every call site across the module. It is importable by the CLI, the MCP server, and other library callers without pulling in package main.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(edits []TextEdit) error

Apply applies edits grouped per file (descending offset so earlier offsets stay valid), parse-checks every result before writing, then runs goimports on each touched file.

func EditedFiles

func EditedFiles(edits []TextEdit) []string

EditedFiles returns the distinct files touched by edits, sorted.

Types

type Action

type Action struct {
	Kind      string // "add" | "remove" | "rename"
	ParamName string
	ParamType string
	Position  int // -1 = append at end
	CallValue string
	RemoveRef string // name or 0-based index
	OldName   string
	NewName   string
}

Action is the parsed --add-param/--remove-param/--rename-param request. The CLI wrapper builds it from flags; the engine consumes it in Plan.

type TextEdit

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

TextEdit is a byte-range replacement in a file. Offsets come from the shared token.FileSet of a packages.Load run.

func Plan

func Plan(file, locator string, action *Action) ([]TextEdit, string, error)

Plan loads and type-checks the module containing file, locates the target function/method named by locator, and computes the text edits (plus a human-readable detail string) that apply action to it and every call site. It performs the same refusals the CLI relies on (missing target, generic functions, unsafe call sites, interface satisfaction) as classified errors.

Jump to

Keyboard shortcuts

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