engine

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler interface {
	Compile(pkgConfig *config.Config) (*interfaces.CompiledConfig, error)
}

Compiler compiles package configurations.

type Config

type Config struct {
}

Config holds the engine configuration.

type Engine

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

Engine is the main engine for adptool.

func New

func New(opts ...Option) *Engine

New creates a new Engine.

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, cfg *Config) (*Result, error)

Execute processes the input and generates output.

func (*Engine) ExecuteFile

func (e *Engine) ExecuteFile(filePath string, cfg *config.Config) error

ExecuteFile processes a single Go file and generates its adapter.

type ExecutionError

type ExecutionError struct {
	Op  string
	Err error
}

ExecutionError represents errors that occur during the execution phase.

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

func (*ExecutionError) Unwrap

func (e *ExecutionError) Unwrap() error

type ExecutionPlan

type ExecutionPlan struct {
	Packages []*PackagePlan
}

ExecutionPlan represents the plan for executing the adapter generation.

type Executor

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

Executor executes the execution plan.

func NewExecutor

func NewExecutor(generator Generator, compiler Compiler, logger Logger) *Executor

NewExecutor creates a new Executor.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, plan *ExecutionPlan) error

Execute executes the execution plan.

type FileSystemParser

type FileSystemParser struct{}

FileSystemParser implements the Parser interface using the file system.

func NewFileSystemParser

func NewFileSystemParser() *FileSystemParser

NewFileSystemParser creates a new FileSystemParser.

func (*FileSystemParser) ParseFile

func (p *FileSystemParser) ParseFile(filePath string) (*ast.File, *token.FileSet, error)

ParseFile parses a Go source file.

type Generator

type Generator interface {
	Generate(plan *PackagePlan) error
}

Generator generates adapter code.

type LoadContext

type LoadContext struct {
	Files       map[string]*ast.File
	FileSets    map[string]*token.FileSet
	Config      *config.Config
	CompiledCfg *config.Config
}

LoadContext holds the context for the loading phase.

type Loader

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

Loader loads source files and configurations.

func NewLoader

func NewLoader(fsys fs.FS, parser Parser, cfg *config.Config, logger *slog.Logger) *Loader

NewLoader creates a new Loader.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, paths []string) (*LoadContext, error)

Load loads the source files and configurations.

func (*Loader) LoadConfig

func (l *Loader) LoadConfig(path string) (*config.Config, error)

LoadConfig loads configuration from a file.

type LoaderError

type LoaderError struct {
	Op  string
	Err error
}

LoaderError represents errors that occur during the loading phase.

func (*LoaderError) Error

func (e *LoaderError) Error() string

func (*LoaderError) Unwrap

func (e *LoaderError) Unwrap() error

type Logger

type Logger interface {
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
}

Logger interface for logging.

type Option

type Option func(*Engine)

Option is a function that configures the Engine.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger for the engine.

type PackagePlan

type PackagePlan struct {
	Name        string
	ImportPath  string
	SourceFiles []string
	TargetFiles []string
	Config      *interfaces.CompiledConfig
}

PackagePlan represents the plan for a single package.

type Parser

type Parser interface {
	ParseFile(filePath string) (*ast.File, *token.FileSet, error)
}

Parser parses Go source files.

type PlanError

type PlanError struct {
	Op  string
	Err error
}

PlanError represents errors that occur during the planning phase.

func (*PlanError) Error

func (e *PlanError) Error() string

func (*PlanError) Unwrap

func (e *PlanError) Unwrap() error

type Planner

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

Planner is responsible for creating an execution plan.

func NewPlanner

func NewPlanner(cfg *config.Config, logger Logger, compiler Compiler, generator Generator) *Planner

NewPlanner creates a new Planner.

func (*Planner) Plan

func (p *Planner) Plan(loadCtx *LoadContext) (*ExecutionPlan, error)

Plan creates an execution plan based on the load context.

type RealCompiler

type RealCompiler struct{}

RealCompiler is a real implementation of the Compiler interface

func NewRealCompiler

func NewRealCompiler() *RealCompiler

NewRealCompiler creates a new RealCompiler

func (*RealCompiler) Compile

func (r *RealCompiler) Compile(pkgConfig *config.Config) (*interfaces.CompiledConfig, error)

Compile compiles package configurations

type RealGenerator

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

RealGenerator is a real implementation of the Generator interface

func NewRealGenerator

func NewRealGenerator(logger *slog.Logger) *RealGenerator

NewRealGenerator creates a new RealGenerator

func (*RealGenerator) Generate

func (r *RealGenerator) Generate(plan *PackagePlan) error

Generate generates adapter code for the given package plan

type Result

type Result struct {
}

Result holds the result of the engine execution.

Jump to

Keyboard shortcuts

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