fixer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFixes

func GenerateFixes(
	fixCtx *FixContext,
	validation *ValidationResult,
	mode string,
) []analysis.SuggestedFix

GenerateFixes generates suggested fixes for a converter validation result. When mode is "smart", smart fix is listed first (applied by -fix), safe fix second. When mode is "safe", only safe fix is generated.

Types

type FixContext

type FixContext struct {
	InVar         string        // input variable name (e.g., "pbTicket")
	OutVar        string        // output variable name (e.g., "result")
	InFieldVar    string        // field access var (may differ for slice inline mapping)
	InStruct      *types.Struct // input struct type
	OutStruct     *types.Struct // output struct type
	InNamedType   *types.Named  // for getter method lookup
	FnBodyLbrace  token.Pos     // insertion point after opening brace
	FnBodyRbrace  token.Pos     // insertion point before closing brace
	LastReturnPos token.Pos     // position of last return statement (insert output stubs before this)
	OutputStyle   OutputStyle   // composite-lit vs dot-assignment
	CompLitRbrace token.Pos     // for inserting into composite literal (smart fix)
	IsSliceInline bool          // true when inFieldVar is a loop variable
}

FixContext holds the context needed to generate suggested fixes for a converter.

type OutputStyle

type OutputStyle int

OutputStyle indicates how the output value is constructed in a converter.

const (
	// OutputStyleDotAssignment means fields are set via dot notation (e.g., result.Field = value).
	OutputStyleDotAssignment OutputStyle = iota
	// OutputStyleCompositeLit means the output is built via a composite literal (e.g., &Type{Field: value}).
	OutputStyleCompositeLit
)

type ValidationResult

type ValidationResult struct {
	MissingInputFields  []string
	MissingOutputFields []string
}

ValidationResult provides the missing fields needed for fix generation. This avoids an import cycle with the lf package.

Jump to

Keyboard shortcuts

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