packageextension

package
v0.3.30 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package packageextension defines versioned, data-only boundaries used by compiler-integrated packages. Providers never receive parser, checker, or typed-IR objects.

Index

Constants

View Source
const DeclarationAdapterProtocolVersion = 2
View Source
const DeclarationProtocolVersion = 2
View Source
const NativeRuntimeAdapterProtocolVersion = 1
View Source
const ProjectDeclarationInputProtocolVersion = 4
View Source
const ProjectGenerationProtocolVersion = 1
View Source
const ProtocolVersion = 2

Variables

This section is empty.

Functions

func RegisterCallProvider

func RegisterCallProvider(name string, provider CallProvider)

func ValidateDeclarationAdapterCatalog added in v0.3.16

func ValidateDeclarationAdapterCatalog(catalog DeclarationAdapterCatalog) error

func ValidateDeclarationCatalog added in v0.3.14

func ValidateDeclarationCatalog(catalog DeclarationCatalog) error

func ValidateNativeRuntimeAdapterCatalog added in v0.3.23

func ValidateNativeRuntimeAdapterCatalog(catalog NativeRuntimeAdapterCatalog) error

func ValidateProjectDeclarationInput added in v0.3.14

func ValidateProjectDeclarationInput(input ProjectDeclarationInput) error

func ValidateProjectGenerationResponse added in v0.3.15

func ValidateProjectGenerationResponse(response ProjectGenerationResponse) error

Types

type CallSite

type CallSite struct {
	ID         string `json:"id"`
	ModulePath string `json:"modulePath"`
}

type DeclarationAdapterCatalog added in v0.3.16

type DeclarationAdapterCatalog struct {
	ProtocolVersion int                                 `json:"protocolVersion"`
	Modules         map[string]DeclarationAdapterModule `json:"modules"`
}

DeclarationAdapterCatalog is the versioned, mode-independent declaration input consumed by a native-ecosystem adapter. It contains semantic data only; an adapter validates target-specific bridge kinds before importing the declarations into the compiler.

type DeclarationAdapterExport added in v0.3.16

type DeclarationAdapterExport struct {
	Kind              string                              `json:"kind"`
	Type              DeclarationAdapterType              `json:"type"`
	AliasTarget       *DeclarationAdapterType             `json:"aliasTarget,omitempty"`
	Parameters        []DeclarationAdapterType            `json:"parameters,omitempty"`
	Required          int                                 `json:"required,omitempty"`
	Variadic          bool                                `json:"variadic,omitempty"`
	TypeParameters    []string                            `json:"typeParameters,omitempty"`
	Fields            []DeclarationAdapterField           `json:"fields,omitempty"`
	Members           map[string]DeclarationAdapterExport `json:"members,omitempty"`
	InstanceMembers   map[string]DeclarationAdapterExport `json:"instanceMembers,omitempty"`
	ClassMembers      map[string]DeclarationAdapterExport `json:"classMembers,omitempty"`
	ResultBridge      *DeclarationAdapterResultBridge     `json:"resultBridge,omitempty"`
	UnsupportedFields map[string]string                   `json:"unsupportedFields,omitempty"`
}

type DeclarationAdapterField added in v0.3.16

type DeclarationAdapterField struct {
	Name     string                 `json:"name"`
	Type     DeclarationAdapterType `json:"type"`
	Optional bool                   `json:"optional,omitempty"`
}

type DeclarationAdapterModule added in v0.3.16

type DeclarationAdapterModule struct {
	Exports map[string]DeclarationAdapterExport `json:"exports,omitempty"`
	Records map[string]DeclarationAdapterExport `json:"records,omitempty"`
}

type DeclarationAdapterResultBridge added in v0.3.16

type DeclarationAdapterResultBridge struct {
	Kind  string                 `json:"kind"`
	Error DeclarationAdapterType `json:"error"`
}

type DeclarationAdapterType added in v0.3.16

type DeclarationAdapterType struct {
	Kind         string                          `json:"kind"`
	Name         string                          `json:"name,omitempty"`
	Arguments    []DeclarationAdapterType        `json:"arguments,omitempty"`
	ResultBridge *DeclarationAdapterResultBridge `json:"resultBridge,omitempty"`
	Nullable     bool                            `json:"nullable,omitempty"`
	Readonly     bool                            `json:"readonly,omitempty"`
}

DeclarationAdapterType is a backend-independent semantic TypeRB type. A nested result bridge applies to a callback function; a bridge on DeclarationAdapterExport applies to the native call itself. Both remain boundary metadata rather than a second TypeRB failure model.

type DeclarationCatalog added in v0.3.14

type DeclarationCatalog struct {
	ProtocolVersion                int                                     `json:"protocolVersion"`
	Provider                       string                                  `json:"provider"`
	Types                          []DeclaredType                          `json:"types,omitempty"`
	Modules                        []DeclaredModule                        `json:"modules,omitempty"`
	FunctionBlockRules             []DeclaredFunctionBlockRule             `json:"functionBlockRules,omitempty"`
	FunctionArgumentReferenceRules []DeclaredFunctionArgumentReferenceRule `json:"functionArgumentReferenceRules,omitempty"`
	RuntimeTypes                   []DeclaredModuleRuntimeTypes            `json:"runtimeTypes,omitempty"`
}

DeclarationCatalog is the versioned, mode-independent output of a package declaration provider. It contains semantic data only: the compiler host validates and converts it before resolution and checking.

type DeclaredBlock added in v0.3.14

type DeclaredBlock struct {
	Parameters      []Type `json:"parameters,omitempty"`
	ControlBoundary bool   `json:"controlBoundary,omitempty"`
	Return          Type   `json:"return,omitempty"`
	ResultBoundary  Type   `json:"resultBoundary,omitempty"`
	Structured      bool   `json:"structured,omitempty"`
}

type DeclaredFunctionArgumentReferenceRule added in v0.3.14

type DeclaredFunctionArgumentReferenceRule struct {
	Package  string              `json:"package"`
	Function string              `json:"function"`
	Argument int                 `json:"argument"`
	Owner    DeclaredReference   `json:"owner"`
	Targets  []DeclaredReference `json:"targets,omitempty"`
}

type DeclaredFunctionBlockRule added in v0.3.14

type DeclaredFunctionBlockRule struct {
	Package             string `json:"package"`
	Function            string `json:"function"`
	EnclosingSuperclass string `json:"enclosingSuperclass,omitempty"`
	TypeArgument        int    `json:"typeArgument"`
	ParameterTypeSuffix string `json:"parameterTypeSuffix,omitempty"`
}

type DeclaredMember added in v0.3.14

type DeclaredMember struct {
	Name             string              `json:"name"`
	Kind             string              `json:"kind"`
	RuntimeOperation string              `json:"runtimeOperation,omitempty"`
	CallSpecializer  string              `json:"callSpecializer,omitempty"`
	Parameters       []DeclaredParameter `json:"parameters,omitempty"`
	MinimumArguments int                 `json:"minimumArguments,omitempty"`
	MaximumArguments int                 `json:"maximumArguments,omitempty"`
	Return           Type                `json:"return"`
	Variadic         bool                `json:"variadic,omitempty"`
	TypeParameters   []string            `json:"typeParameters,omitempty"`
	Alternatives     []DeclaredSignature `json:"alternatives,omitempty"`
	Block            *DeclaredBlock      `json:"block,omitempty"`
}

type DeclaredModule added in v0.3.14

type DeclaredModule struct {
	Name            string           `json:"name"`
	InstanceMembers []DeclaredMember `json:"instanceMembers,omitempty"`
}

type DeclaredModuleRuntimeTypes added in v0.3.14

type DeclaredModuleRuntimeTypes struct {
	ModulePath string `json:"modulePath"`
	Types      []Type `json:"types"`
}

type DeclaredParameter added in v0.3.14

type DeclaredParameter struct {
	Name                   string     `json:"name"`
	Type                   Type       `json:"type"`
	Keyword                bool       `json:"keyword,omitempty"`
	Optional               bool       `json:"optional,omitempty"`
	RepresentationBoundary bool       `json:"representationBoundary,omitempty"`
	LiteralValues          []string   `json:"literalValues,omitempty"`
	LiteralArrays          [][]string `json:"literalArrays,omitempty"`
	LiteralArrayElements   []string   `json:"literalArrayElements,omitempty"`
}

type DeclaredReference added in v0.3.14

type DeclaredReference struct {
	ModulePath string `json:"modulePath"`
	Name       string `json:"name"`
}

type DeclaredSignature added in v0.3.14

type DeclaredSignature struct {
	Parameters []DeclaredParameter `json:"parameters,omitempty"`
	Return     Type                `json:"return"`
	Variadic   bool                `json:"variadic,omitempty"`
}

type DeclaredType added in v0.3.14

type DeclaredType struct {
	Name            string           `json:"name"`
	TypeParameters  []string         `json:"typeParameters,omitempty"`
	Superclass      string           `json:"superclass,omitempty"`
	SourceModule    string           `json:"sourceModule,omitempty"`
	InstanceMembers []DeclaredMember `json:"instanceMembers,omitempty"`
	ClassMembers    []DeclaredMember `json:"classMembers,omitempty"`
}

type Definition

type Definition struct {
	ModulePath string `json:"modulePath,omitempty"`
	ImportPath string `json:"importPath,omitempty"`
}

type Field

type Field struct {
	Name string `json:"name"`
	Type Type   `json:"type"`
}

type GeneratedSource

type GeneratedSource struct {
	ID     string `json:"id"`
	Source string `json:"source"`
}

type Issue

type Issue struct {
	Message string `json:"message"`
}

type NativeRuntimeAdapterBinding added in v0.3.23

type NativeRuntimeAdapterBinding struct {
	Dependency               string `json:"dependency"`
	Module                   string `json:"module"`
	Symbol                   string `json:"symbol"`
	CallConvention           string `json:"callConvention"`
	MaySuspend               bool   `json:"maySuspend,omitempty"`
	PropagatesExecutionScope bool   `json:"propagatesExecutionScope,omitempty"`
}

NativeRuntimeAdapterBinding is the target-specific half of one runtime declaration. The initial call convention supports only a top-level native function. When execution scope propagation is enabled, the generated caller passes the target's hidden scope as the first argument.

type NativeRuntimeAdapterCatalog added in v0.3.23

type NativeRuntimeAdapterCatalog struct {
	ProtocolVersion int                                    `json:"protocolVersion"`
	Bindings        map[string]NativeRuntimeAdapterBinding `json:"bindings"`
}

NativeRuntimeAdapterCatalog maps stable semantic declaration identities to target-native runtime functions. It deliberately contains no TypeRB signatures; those remain owned by the declaration adapter catalog.

type ProjectClass added in v0.3.14

type ProjectClass struct {
	Name           string             `json:"name"`
	TypeParameters []string           `json:"typeParameters,omitempty"`
	Superclass     *ProjectTypeUse    `json:"superclass,omitempty"`
	Methods        []ProjectMethod    `json:"methods,omitempty"`
	Directives     []ProjectDirective `json:"directives,omitempty"`
	Span           SourceSpan         `json:"span"`
}

type ProjectDeclarationInput added in v0.3.14

type ProjectDeclarationInput struct {
	ProtocolVersion int             `json:"protocolVersion"`
	Provider        string          `json:"provider"`
	Modules         []ProjectModule `json:"modules,omitempty"`
}

ProjectDeclarationInput is a versioned, read-only snapshot of source declarations that a declaration provider may inspect. It intentionally excludes parser nodes, method bodies, resolver state, and filesystem access.

type ProjectDirective added in v0.3.14

type ProjectDirective struct {
	Name      string                     `json:"name"`
	Arguments []ProjectDirectiveArgument `json:"arguments,omitempty"`
	Block     *ProjectDirectiveBlock     `json:"block,omitempty"`
	Span      SourceSpan                 `json:"span"`
}

ProjectDirective is a direct class-body call. It retains only declarative argument values and a structural block summary, never executable block statements.

type ProjectDirectiveArgument added in v0.3.14

type ProjectDirectiveArgument struct {
	Name  string       `json:"name,omitempty"`
	Splat string       `json:"splat,omitempty"`
	Value ProjectValue `json:"value"`
	Span  SourceSpan   `json:"span"`
}

type ProjectDirectiveBlock added in v0.3.15

type ProjectDirectiveBlock struct {
	Parameters       []string   `json:"parameters,omitempty"`
	StatementCount   int        `json:"statementCount"`
	ResultExpression bool       `json:"resultExpression,omitempty"`
	Span             SourceSpan `json:"span"`
}

type ProjectEnum added in v0.3.15

type ProjectEnum struct {
	Name           string              `json:"name"`
	TypeParameters []string            `json:"typeParameters,omitempty"`
	Members        []ProjectEnumMember `json:"members,omitempty"`
	Span           SourceSpan          `json:"span"`
}

type ProjectEnumMember added in v0.3.15

type ProjectEnumMember struct {
	Name       string             `json:"name"`
	Parameters []ProjectParameter `json:"parameters,omitempty"`
	RawValue   *ProjectValue      `json:"rawValue,omitempty"`
	Span       SourceSpan         `json:"span"`
}

type ProjectGeneratedSource added in v0.3.15

type ProjectGeneratedSource struct {
	ID              string           `json:"id"`
	ModulePath      string           `json:"modulePath"`
	Source          string           `json:"source"`
	RequiredImports []RequiredImport `json:"requiredImports,omitempty"`
	Origin          SourceSpan       `json:"origin"`
}

type ProjectGenerationIssue added in v0.3.15

type ProjectGenerationIssue struct {
	ModulePath string     `json:"modulePath"`
	Message    string     `json:"message"`
	Span       SourceSpan `json:"span"`
}

type ProjectGenerationResponse added in v0.3.15

type ProjectGenerationResponse struct {
	ProtocolVersion int                      `json:"protocolVersion"`
	Provider        string                   `json:"provider"`
	Sources         []ProjectGeneratedSource `json:"sources,omitempty"`
	Issues          []ProjectGenerationIssue `json:"issues,omitempty"`
}

ProjectGenerationResponse is a versioned, data-only response from a project package provider. Sources are ordinary TypeRB fragments attached to existing project modules by the compiler host.

type ProjectImport added in v0.3.14

type ProjectImport struct {
	Path       string     `json:"path"`
	ModulePath string     `json:"modulePath"`
	Symbols    []string   `json:"symbols,omitempty"`
	Alias      string     `json:"alias,omitempty"`
	Span       SourceSpan `json:"span"`
}

type ProjectMethod added in v0.3.14

type ProjectMethod struct {
	Name           string             `json:"name"`
	Class          bool               `json:"class,omitempty"`
	TypeParameters []string           `json:"typeParameters,omitempty"`
	Parameters     []ProjectParameter `json:"parameters,omitempty"`
	Return         *ProjectTypeUse    `json:"return,omitempty"`
	Span           SourceSpan         `json:"span"`
}

type ProjectModule added in v0.3.14

type ProjectModule struct {
	ModulePath  string             `json:"modulePath"`
	Imports     []ProjectImport    `json:"imports,omitempty"`
	TypeAliases []ProjectTypeAlias `json:"typeAliases,omitempty"`
	Newtypes    []ProjectNewtype   `json:"newtypes,omitempty"`
	Enums       []ProjectEnum      `json:"enums,omitempty"`
	Classes     []ProjectClass     `json:"classes,omitempty"`
}

type ProjectNewtype added in v0.3.18

type ProjectNewtype struct {
	Name   string         `json:"name"`
	Target ProjectTypeUse `json:"target"`
	Span   SourceSpan     `json:"span"`
}

type ProjectParameter added in v0.3.14

type ProjectParameter struct {
	Name        string         `json:"name"`
	Type        ProjectTypeUse `json:"type"`
	NamedOnly   bool           `json:"namedOnly,omitempty"`
	Keyword     bool           `json:"keyword,omitempty"`
	Rest        bool           `json:"rest,omitempty"`
	KeywordRest bool           `json:"keywordRest,omitempty"`
	Optional    bool           `json:"optional,omitempty"`
	Span        SourceSpan     `json:"span"`
}

type ProjectTypeAlias added in v0.3.14

type ProjectTypeAlias struct {
	Name           string         `json:"name"`
	TypeParameters []string       `json:"typeParameters,omitempty"`
	Target         ProjectTypeUse `json:"target"`
	Span           SourceSpan     `json:"span"`
}

type ProjectTypeReference added in v0.3.14

type ProjectTypeReference struct {
	Name       string `json:"name"`
	ModulePath string `json:"modulePath"`
	ImportPath string `json:"importPath,omitempty"`
}

type ProjectTypeUse added in v0.3.14

type ProjectTypeUse struct {
	Authored       Type                   `json:"authored"`
	Resolved       Type                   `json:"resolved"`
	Representation *Type                  `json:"representation,omitempty"`
	ResolutionPath []ProjectTypeReference `json:"resolutionPath,omitempty"`
	Span           SourceSpan             `json:"span"`
}

ProjectTypeUse separates the source spelling from the best resolved type available before checking. ResolutionPath records namespace-stable type identities traversed while resolving transparent aliases.

type ProjectValue added in v0.3.15

type ProjectValue struct {
	Kind      string                `json:"kind"`
	Raw       string                `json:"raw,omitempty"`
	Name      string                `json:"name,omitempty"`
	Reference *ProjectTypeReference `json:"reference,omitempty"`
}

type Record

type Record struct {
	Fields []Field `json:"fields"`
}

type Replacement

type Replacement struct {
	Callee    string        `json:"callee"`
	Arguments []ValueSource `json:"arguments"`
}

type RequiredImport

type RequiredImport struct {
	Path    string   `json:"path"`
	Symbols []string `json:"symbols"`
}

type SourcePosition added in v0.3.14

type SourcePosition struct {
	Offset int `json:"offset"`
	Line   int `json:"line"`
	Column int `json:"column"`
}

type SourceSpan added in v0.3.14

type SourceSpan struct {
	Start SourcePosition `json:"start"`
	End   SourcePosition `json:"end"`
}

SourceSpan is a half-open source range. An all-zero span means that source location is unavailable, which keeps programmatically assembled inputs valid.

type SpecializeCallRequest

type SpecializeCallRequest struct {
	ProtocolVersion int      `json:"protocolVersion"`
	Provider        string   `json:"provider"`
	CallSite        CallSite `json:"callSite"`
	TypeArguments   []Type   `json:"typeArguments"`
}

type SpecializeCallResponse

type SpecializeCallResponse struct {
	ProtocolVersion int              `json:"protocolVersion"`
	GeneratedSource *GeneratedSource `json:"generatedSource,omitempty"`
	Replacement     *Replacement     `json:"replacement,omitempty"`
	RequiredImports []RequiredImport `json:"requiredImports,omitempty"`
	Issues          []Issue          `json:"issues,omitempty"`
}

func SpecializeCall

func SpecializeCall(request SpecializeCallRequest) (SpecializeCallResponse, error)

type Type

type Type struct {
	Kind       string      `json:"kind"`
	Name       string      `json:"name,omitempty"`
	Nullable   bool        `json:"nullable,omitempty"`
	Arguments  []Type      `json:"arguments,omitempty"`
	Definition *Definition `json:"definition,omitempty"`
	Record     *Record     `json:"record,omitempty"`
	// Representation is present for a nominal newtype and describes the
	// concrete boundary shape without weakening its authored TypeRB identity.
	Representation *Type `json:"representation,omitempty"`
}

type ValueSource

type ValueSource string
const ReceiverValue ValueSource = "receiver"

Jump to

Keyboard shortcuts

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