cloner

package
v0.0.0-...-99bf20c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectivePrefix         = "cloner:"
	DirectiveCommentIgnore  = "ignore"
	DirectiveCommentCopyPtr = "copyptr"
	DirectiveCommentMake    = "make"
)

Variables

View Source
var (
	ErrUnknownDirective = errors.New("unknown directive")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	MatcherConfig *MatcherConfig
	Logger        *slog.Logger
}

func (*Config) Generate

func (c *Config) Generate(
	ctx context.Context,
	sourcePrinter *suffixwriter.Writer,
	pkgs []*packages.Package,
) error

type CopyHandle

type CopyHandle int
const (
	// ignore nocopy object
	CopyHandleIgnore CopyHandle = 0
	// disallow nocopy object
	CopyHandleDisallow CopyHandle = 1 << iota
	CopyHandleCopyPointer

	// Only for channel. make a new channel.
	CopyHandleMake
)

type CustomHandler

type CustomHandler struct {
	Matcher func(types.Type) bool
	Imports []imports.TargetImport
	Expr    func(CustomHandlerExprData) (expr func(s string) (expr string), isFunc bool)
}

type CustomHandlerExprData

type CustomHandlerExprData struct {
	ImportMap imports.ImportMap
	AstExpr   ast.Expr
	Ty        types.Type
}

type CustomHandlers

type CustomHandlers []CustomHandler

func (CustomHandlers) Imports

func (h CustomHandlers) Imports() []imports.TargetImport

func (CustomHandlers) Match

func (h CustomHandlers) Match(ty types.Type) int

type MatcherConfig

type MatcherConfig struct {
	NoCopyHandle  CopyHandle
	ChannelHandle CopyHandle
	FuncHandle    CopyHandle

	CustomHandlers CustomHandlers
	// contains filtered or unexported fields
}

func (*MatcherConfig) MatchEdge

func (c *MatcherConfig) MatchEdge(e typegraph.Edge) bool

func (*MatcherConfig) MatchType

func (c *MatcherConfig) MatchType(node *typegraph.Node, external bool) (ok bool, err error)

Jump to

Keyboard shortcuts

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