compiler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendBindingsFromIR added in v0.2.8

func BackendBindingsFromIR(ir gwdkir.Program) []source.BackendBinding

BackendBindingsFromIR derives the backend binding records already attached to the program's endpoints, without inspecting Go packages on disk. Callers that only need binding metadata for reporting (e.g. build reports) should use this instead of re-running handler discovery.

func BindBackendHandlers added in v0.1.5

func BindBackendHandlers(ir *gwdkir.Program) []source.BackendBinding

BindBackendHandlers discovers same-package Go handlers for act and api blocks, attaches the resulting binding metadata to the program's endpoints and page load bindings, and returns the full binding record list (sorted by source, kind, and block name) for reporting and public manifest JSON. Discovery is intentionally non-fatal: missing packages, missing functions, and unsupported signatures are reported as binding metadata so generated apps can emit clear 501 responses.

func DiscoverGoEndpoints added in v0.2.8

func DiscoverGoEndpoints(ir *gwdkir.Program) error

DiscoverGoEndpoints merges optional //gowdk:act and //gowdk:api comments from selected feature-package Go files into the program as standalone Go endpoints.

func ValidateBackendBindingPolicyIR added in v0.2.8

func ValidateBackendBindingPolicyIR(config gowdk.Config, ir gwdkir.Program) error

ValidateBackendBindingPolicyIR enforces build-mode rules for declared backend endpoints after same-package Go handler binding metadata has been produced. When the program carries no binding metadata but declares backend endpoints (callers that build straight from an unbound program), handlers are re-discovered from disk before the policy check.

func ValidateContractReferences added in v0.1.5

func ValidateContractReferences(refs []gwdkir.ContractReference) error

ValidateContractReferences converts linked contract-reference metadata into compiler diagnostics for CLI validation paths.

func ValidateProgram added in v0.2.8

func ValidateProgram(config gowdk.Config, ir gwdkir.Program) error

ValidateProgram checks render-mode invariants that must hold before codegen. The validators read the compiler IR directly; there is no manifest intermediary on this path. It returns a non-nil error only when at least one error-severity diagnostic is present; warning-only programs return nil.

func ValidateSourceProgram added in v0.2.8

func ValidateSourceProgram(config gowdk.Config, ir gwdkir.Program) error

ValidateSourceProgram checks a program built from a single in-memory source buffer. Cross-file checks (use packages and component references resolved against the discovered project) are skipped because sibling files are not present in the program.

Types

type ContractEndpointBinding added in v0.1.5

type ContractEndpointBinding struct {
	Name        string
	Kind        gwdkir.ContractKind
	Status      gwdkir.ContractBindingStatus
	Message     string
	ImportAlias string
	ImportPath  string
	Type        string
	Result      string
	Roles       []string
	Handler     string
	Register    string
}

ContractEndpointBinding describes a command/query contract exposed through a generated backend endpoint.

type EndpointBinding added in v0.1.5

type EndpointBinding struct {
	Kind              EndpointKind
	EndpointSource    string
	Source            string
	SourceSpan        source.SourceSpan
	Package           string
	PackagePath       string
	PackageName       string
	Symbol            string
	Method            string
	Route             string
	Cache             string
	Guards            []string
	CSRF              bool
	PageID            string
	Handler           string
	BindingStatus     source.BackendBindingStatus
	BindingMessage    string
	BindingImportPath string
	BindingPackage    string
	BindingFunction   string
	BindingSignature  source.BackendSignatureKind
	BindingInputType  string
	Contract          ContractEndpointBinding
}

EndpointBinding is backend action/API metadata. Endpoints are not route kinds; they hang off the generated app/runtime backend layer.

type EndpointKind added in v0.1.5

type EndpointKind string

EndpointKind describes backend endpoint behavior separate from page/file routes.

const (
	EndpointAction   EndpointKind = "action"
	EndpointAPI      EndpointKind = "api"
	EndpointFragment EndpointKind = "fragment"
	EndpointCommand  EndpointKind = "command"
	EndpointQuery    EndpointKind = "query"
)

type RouteBinding added in v0.1.5

type RouteBinding struct {
	Kind          RouteKind
	Method        string
	Route         string
	PageID        string
	Package       string
	Render        gowdk.RenderMode
	Cache         string
	DynamicParams []string
	RouteParams   []source.RouteParam
	Layouts       []string
	Guards        []string
	Source        string
	SourceSpan    source.SourceSpan
	Handler       string
}

RouteBinding is route-level metadata. Route kinds are intentionally limited to static files, SPA routes, SSR routes, and hybrid routes.

type RouteInfo added in v0.1.5

type RouteInfo struct {
	Code    string
	PageID  string
	Route   string
	Message string
}

RouteInfo is non-fatal route metadata surfaced by CLI inspection commands.

type RouteKind added in v0.1.5

type RouteKind string

RouteKind describes route behavior in the CLI routes report.

const (
	RouteStatic RouteKind = "static"
	RouteSPA    RouteKind = "spa"
	RouteSSR    RouteKind = "ssr"
	RouteHybrid RouteKind = "hybrid"
)

type RouteMetadata added in v0.1.5

type RouteMetadata struct {
	Routes    []RouteBinding
	Endpoints []EndpointBinding
	Info      []RouteInfo
}

RouteMetadata is route and endpoint metadata used by the CLI routes report.

func BuildRouteMetadataFromIR added in v0.1.5

func BuildRouteMetadataFromIR(config gowdk.Config, ir gwdkir.Program) RouteMetadata

BuildRouteMetadataFromIR converts stable compiler IR into CLI route and endpoint metadata.

type Severity added in v0.3.0

type Severity int

Severity classifies a diagnostic as a hard error or a non-fatal warning.

const (
	// SeverityError is the default: it fails the build.
	SeverityError Severity = iota
	// SeverityWarning is surfaced to the author but does not fail the build.
	SeverityWarning
)

type ValidationError

type ValidationError struct {
	Code          string
	PageID        string
	ComponentName string
	Source        string
	Span          source.SourceSpan
	// Related carries secondary source locations, such as the first declaration
	// that a conflict diagnostic also points at. It is optional and additive.
	Related  []source.RelatedSpan
	Message  string
	Severity Severity
}

func ValidatePage

func ValidatePage(config gowdk.Config, page gwdkir.Page) []ValidationError

func (ValidationError) Error

func (err ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func ValidateProgramReport added in v0.3.0

func ValidateProgramReport(config gowdk.Config, ir gwdkir.Program) ValidationErrors

ValidateProgramReport returns every diagnostic, including warnings, so the caller can surface warnings while still gating the build on HasErrors.

func ValidateSourceProgramReport added in v0.3.0

func ValidateSourceProgramReport(config gowdk.Config, ir gwdkir.Program) ValidationErrors

ValidateSourceProgramReport is the single-source counterpart to ValidateProgramReport.

func (ValidationErrors) Error

func (errs ValidationErrors) Error() string

func (ValidationErrors) HasErrors added in v0.3.0

func (errs ValidationErrors) HasErrors() bool

HasErrors reports whether any diagnostic is error severity. Warning-only reports return false so the build proceeds.

func (ValidationErrors) Warnings added in v0.3.0

func (errs ValidationErrors) Warnings() ValidationErrors

Warnings returns only the warning-severity diagnostics.

Jump to

Keyboard shortcuts

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