gen

package
v0.14.0 Latest Latest
Warning

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

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

Documentation

Overview

Package gen orchestrates generation: it drives parsing, naming, lowering, and emission for every package matched by the CLI's patterns.

Index

Constants

View Source
const LawsTestSuffix = "_gpp_laws_test.go"

LawsTestSuffix names generated law-test files.

Variables

This section is empty.

Functions

func GenSiblings added in v0.10.0

func GenSiblings(enums []*registry.Enum) map[string]bool

GenSiblings computes the derivable-enum name set for one package.

func RenderEnumGen added in v0.10.0

func RenderEnumGen(e *registry.Enum, siblings map[string]bool, qual string) (string, bool)

RenderEnumGen renders Gen<Enum> and its depth helper. qual prefixes constructor and type references when the generator is emitted outside the enum's package ("" for same-package). ok is false when the enum cannot derive a generator (generic, indexed, or uninhabited at any depth).

Types

type Options

type Options struct {
	Dir      string   // working directory; resolved against pattern paths
	Patterns []string // go-style package patterns; default ["./..."]
	Check    bool     // verify only: report stale outputs, write nothing
	Stage    bool     // after writing, git-add changed/deleted outputs

	// Overlay substitutes in-memory contents for on-disk .gpp files
	// (absolute path → bytes) — the LSP's unsaved buffers.
	Overlay map[string][]byte
	// DryRun computes diagnostics and outputs without writing anything
	// (and without staging or orphan deletion).
	DryRun bool
}

Options configures a generation run.

type Result

type Result struct {
	Written []string          // files written (or deleted orphans, in write mode)
	Stale   []string          // check mode: outputs missing or out of date
	Orphans []string          // generated files whose .gpp source is gone
	Outputs map[string][]byte // DryRun: would-be generated content
	Diags   []diag.Diagnostic
}

Result reports what a run did (paths relative to Options.Dir when under it).

func Run

func Run(opts Options) (*Result, error)

Run executes generation over all matched directories.

func (*Result) Ok

func (r *Result) Ok() bool

Ok reports whether generation completed without diagnostics.

Jump to

Keyboard shortcuts

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