sourcecheck

package
v0.13.0-a.7 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeFactoryBody added in v0.12.0

func AnalyzeFactoryBody(body syntax.FactoryBody, opts Options) (*program.CheckedBody, error)

AnalyzeFactoryBody retains resolved imports and local types when body checks fail. Import-resolution failures return no analysis.

func AnalyzeProgram added in v0.12.0

func AnalyzeProgram(
	refs map[string]resolve.ImportRef,
	opts ImportAnalysisOptions,
) (*program.Imports, error)

func CheckLibraryFile

func CheckLibraryFile(file *syntax.LibraryFile, opts Options) error

CheckLibraryFile checks every exported composite body in file.

func CheckUBLibrary

func CheckUBLibrary(source *resolve.Source, opts Options) error

CheckUBLibrary checks every exported composite body in source.

Types

type ImportAnalysis

type ImportAnalysis struct {
	Top                  []resolve.Resolution
	Libraries            map[string]*runtime.Library
	LibraryConfigSchemas map[string]runtime.LibraryConfigSchema
	GoImports            map[string]string
	GoModules            map[string]string
	UBImports            map[string]string
	UBPackages           map[string][]byte
	Assets               *asset.Collection
	RootAssetSetID       string
	Compatibility        *golibrary.CompatibilityContext
	LibraryMetadata      []golibrary.PackageMetadata
}

ImportAnalysis is the resolved import data shared by source checks, compile, and graph printing.

func AnalyzeImports

func AnalyzeImports(
	refs map[string]resolve.ImportRef,
	opts ImportAnalysisOptions,
) (*ImportAnalysis, error)

type ImportAnalysisOptions

type ImportAnalysisOptions struct {
	ProjectDir              string
	Source                  *resolve.Source
	Resolver                resolve.Resolver
	Versions                map[string]string
	SchemaCache             *SchemaCache
	Reporter                diagnostic.Reporter
	Mode                    Mode
	StackName               string
	GeneratePackages        bool
	ValidateCompositeBodies bool
	Body                    *syntax.FactoryBody
	RootSourceFile          syntax.SourceFileSpec
	GeneratedOutputPath     string
	Compatibility           *golibrary.CompatibilityContext
}

ImportAnalysisOptions configures AnalyzeImports.

type Mode

type Mode int

Mode controls whether remote imports may be fetched.

const (
	// ModeFetch uses the resolver normally.
	ModeFetch Mode = iota
	// ModeNoFetch treats uncached remote imports as opaque libraries.
	ModeNoFetch
)

type Options

type Options struct {
	ProjectDir     string
	Source         *resolve.Source
	RootSourceFile syntax.SourceFileSpec
	Resolver       resolve.Resolver
	Versions       map[string]string
	SchemaCache    *SchemaCache
	Reporter       diagnostic.Reporter
	Mode           Mode
}

Options configures source checks.

type Result

type Result struct {
	Libraries            map[string]*runtime.Library
	LibraryConfigSchemas map[string]runtime.LibraryConfigSchema
	DAG                  *runtime.DAG
}

Result is the source-check result for a factory or composite body.

func CheckFactoryBody

func CheckFactoryBody(body syntax.FactoryBody, opts Options) (*Result, error)

CheckFactoryBody resolves imports and runs compile-time checks for body.

type SchemaCache

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

SchemaCache memoizes Go library schema reads by source path.

func NewSchemaCache

func NewSchemaCache(extra ...goschema.ModuleRoot) *SchemaCache

NewSchemaCache returns a cache that reads Go source with extra module roots.

func NewSchemaCacheWithCompatibility added in v0.12.0

func NewSchemaCacheWithCompatibility(
	compatibility *golibrary.CompatibilityContext, extra ...goschema.ModuleRoot,
) *SchemaCache

func NewSchemaCacheWithReader

func NewSchemaCacheWithReader(
	read func(sourcePath string) (*runtime.LibrarySchema, []string, error),
) *SchemaCache

NewSchemaCacheWithReader returns a cache that reads Go schemas through read.

func NewSchemaCacheWithReaders added in v0.10.0

func NewSchemaCacheWithReaders(
	read func(sourcePath string) (*runtime.LibrarySchema, []string, error),
	readConfiguration func(sourcePath string) (*runtime.LibrarySchema, []string, error),
	extra ...goschema.ModuleRoot,
) *SchemaCache

NewSchemaCacheWithReaders returns a cache with separate readers for full libraries and config-schema packages.

func NewSchemaCacheWithReadersAndCompatibility added in v0.12.0

func NewSchemaCacheWithReadersAndCompatibility(
	compatibility *golibrary.CompatibilityContext,
	read func(string) (*runtime.LibrarySchema, []string, error),
	readConfiguration func(string) (*runtime.LibrarySchema, []string, error),
	extra ...goschema.ModuleRoot,
) *SchemaCache

func (*SchemaCache) CompatibilityContext added in v0.12.0

func (c *SchemaCache) CompatibilityContext() *golibrary.CompatibilityContext

func (*SchemaCache) Read

func (c *SchemaCache) Read(sourcePath string) (*runtime.LibrarySchema, []string, error)

Read returns the schema and warnings for the current source contents.

func (*SchemaCache) ReadLibraryConfiguration added in v0.10.0

func (c *SchemaCache) ReadLibraryConfiguration(
	sourcePath string,
) (*runtime.LibrarySchema, []string, error)

ReadLibraryConfiguration returns the config schema for sourcePath.

Jump to

Keyboard shortcuts

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