parsectx

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInfo

type BuildInfo struct {
	GOARCH string   // target architecture
	GOOS   string   // target operating system
	GOROOT paths.FS // GOROOT to use

	EncoreRuntime paths.FS // Encore runtime to use

	BuildTags  []string // additional build tags to set
	CgoEnabled bool

	// Experiments are the enabled experiments.
	Experiments *experiments.Set

	// StaticLink enables static linking of C libraries.
	StaticLink bool

	// Debug enables compiling in debug mode.
	Debug builder.DebugMode

	// Revision specifies the revision of the build.
	Revision string

	// UncommittedChanges, if true, specifies there are uncommitted changes
	// part of the build .
	UncommittedChanges bool

	// MainPkg is the existing main package to use, if any.
	// If None a main package is generated.
	MainPkg option.Option[paths.Pkg]
}

BuildInfo represents the information needed to parse and build an Encore application.

type Context

type Context struct {
	// AppID is a unique id of the application, used for workdir caching.
	// If left empty, a random workdir is used.
	AppID option.Option[string]

	// Ctx provides cancellation.
	Ctx context.Context

	// Log is the configured logger.
	Log zerolog.Logger

	// Build controls what files to build.
	Build BuildInfo

	// MainModuleDir is the directory containing the main module.
	MainModuleDir paths.FS

	// FS holds the fileset used for parsing.
	FS *token.FileSet

	// ParseTests controls whether to parse test files.
	ParseTests bool

	// Errs contains encountered errors.
	Errs *perr.List

	// Overlay is an optional replacement for reading files using the os pkg.
	// If unset, os is used instead.
	Overlay OverlaidOSFS
}

Context holds all the context for parsing.

func (*Context) IsDir added in v1.35.3

func (c *Context) IsDir(path string) bool

func (*Context) OpenFile added in v1.35.3

func (c *Context) OpenFile(file string) (io.ReadCloser, error)

func (*Context) PkgOverlay added in v1.35.3

func (c *Context) PkgOverlay() map[string][]byte

func (*Context) ReadDir added in v1.35.3

func (c *Context) ReadDir(dir string) ([]fs.DirEntry, error)

func (*Context) ReadFile added in v1.35.3

func (c *Context) ReadFile(dir string) ([]byte, error)

func (*Context) ReadFileInfo added in v1.35.3

func (c *Context) ReadFileInfo(dir string) ([]fs.FileInfo, error)

func (*Context) Trace

func (c *Context) Trace(op string, kvs ...any) *TraceLogger

Trace traces the execution of a function. It emits trace-level log messages, using the given message and key-value pairs. It returns the logger for logging additional information during the processing.

Usage:

tr := ctx.Trace("operation-name", "key", value)
// ... invoke tr.Emit(...) to log additional information
defer tr.Done()

type OverlaidOSFS added in v1.35.3

type OverlaidOSFS interface {
	ReadDir(name string) ([]os.DirEntry, error)
	ReadFile(name string) ([]byte, error)
	Stat(name string) (os.FileInfo, error)
	Open(name string) (io.ReadCloser, error)
	PkgOverlay() map[string][]byte
}

OverlaidOSFS is an interface that allows overlaying the os package with custom implementations. This is used to allow for e.g. in-memory files. The name parameters are os paths, like the corresponding methods in the os package.

type TraceLogger

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

func (*TraceLogger) Done

func (t *TraceLogger) Done(kvs ...any)

func (*TraceLogger) Emit

func (t *TraceLogger) Emit(msg string, kvs ...any)

Jump to

Keyboard shortcuts

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