Documentation
¶
Overview ¶
Package resolver turns syntax imports into project or compiler-known package identities before type checking. Backends therefore never interpret a raw TypeRB import path on their own.
Index ¶
- func CanonicalPackageImport(importPath string, aliases map[string]string) string
- func CollectExports(statements []ast.Statement) map[string]Export
- func ValidateImportGraph(catalog *Catalog, results map[string]Result) map[string][]diagnostic.Diagnostic
- type Binding
- type Catalog
- type EnumVariant
- type Export
- type ExportKind
- type Import
- type ImportKind
- type Member
- type Module
- type Options
- type RecordField
- type Result
- func (r Result) CompilerOwnedType(name string) (Export, bool)
- func (r Result) ImportedType(typeName string) (Binding, bool)
- func (r Result) InferredType(typeName string) (Binding, bool)
- func (r Result) InferredTypeMember(typeName, memberName string) (Binding, bool)
- func (r Result) Member(alias, name string) (Binding, bool)
- func (r Result) ReceiverMethod(receiver types.Type, name string) (Binding, bool)
- func (r Result) TypeMember(typeName, name string) (Binding, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalPackageImport ¶ added in v0.2.27
CanonicalPackageImport applies the longest matching TypeRB package alias to a source import path. Compile-time providers use the same mapping before the ordinary resolver has produced its import graph.
func ValidateImportGraph ¶
func ValidateImportGraph(catalog *Catalog, results map[string]Result) map[string][]diagnostic.Diagnostic
ValidateImportGraph rejects project import cycles with a deterministic path. A single cross-mode rule keeps initialization order independent of Ruby, TypeScript, or Go runtime loader behavior.
Types ¶
type Binding ¶
type Binding struct {
Import *Import
Name string
Export *Export
Member *Member
Library *stdlib.Symbol
}
func (Binding) FailureType ¶ added in v0.2.0
type Catalog ¶
func NewCatalog ¶
func NewCatalog(modules []Module) (*Catalog, map[string][]diagnostic.Diagnostic)
type EnumVariant ¶
type EnumVariant struct {
Name string
Fields []RecordField
RawValue string
}
type Export ¶
type Export struct {
Name string
Kind ExportKind
Type types.Type
Fails types.Type
Parameters []types.Type
ParameterBridges []string
Required int
Variadic bool
Members map[string]Member
Fields []RecordField
EnumMembers []string
EnumVariants []EnumVariant
EnumRawType types.Type
TypeParameters []string
AliasTarget types.Type
AliasEnum bool
Superclass string
Interfaces []types.Type
Span token.Span
UnsupportedFields map[string]string
// NativeExported distinguishes a real target-package type export from a
// provider-only structural record used to describe another declaration.
NativeExported bool
}
type ExportKind ¶
type ExportKind string
const ( ClassExport ExportKind = "class" RecordExport ExportKind = "record" EnumExport ExportKind = "enum" TypeAliasExport ExportKind = "type_alias" ModuleExport ExportKind = "module" InterfaceExport ExportKind = "interface" FunctionExport ExportKind = "function" ValueExport ExportKind = "value" )
type Import ¶
type Import struct {
Node *ast.ImportStatement
Kind ImportKind
Path string
ModulePath string
Alias string
Symbols []string
Definition *stdlib.Package
Exports map[string]Export
Filename string
}
func (*Import) RuntimePath ¶
type ImportKind ¶
type ImportKind string
const ( StandardImport ImportKind = "standard" OfficialImport ImportKind = "official" ProjectImport ImportKind = "project" NativeImport ImportKind = "native" )
type RecordField ¶
type Result ¶
type Result struct {
Imports map[*ast.ImportStatement]*Import
Packages map[string]*Import
Symbols map[string]Binding
NativeSyntax bool
Declarations *declaration.Catalog
Catalog *Catalog
}
func Resolve ¶
func Resolve(program *ast.Program, options Options) (Result, []diagnostic.Diagnostic)
func (Result) CompilerOwnedType ¶ added in v0.1.9
CompilerOwnedType returns declarations that were inferred from a portable library result. It supports member checking on inferred values without making the type name available to source annotations that omitted an import.
func (Result) InferredType ¶ added in v0.2.3
InferredType resolves a type that appears in the contract of an explicitly imported symbol without making that type available to source annotations. Source-visible type names continue to use ImportedType and therefore still require an explicit named or namespace import.
func (Result) InferredTypeMember ¶ added in v0.2.3
InferredTypeMember resolves a member on a type produced by an explicitly imported package even when the source did not import that type by name. This keeps inferred library values usable without weakening named-import rules for source annotations.
func (Result) ReceiverMethod ¶
ReceiverMethod returns an implicit portable method binding. The binding is deliberately backed by the same standard package definition as its function form, even though TypeRB source does not need to import the method.