Documentation ¶
Overview ¶
Package imports provides handling of claw.mod, local.replace and global.replace files.
Index ¶
- func AppendImports(ctx context.Context, pkgPath string) context.Context
- func FindClawFile(fs fs.ReadDirFS, path string) (string, error)
- func ValidModuleName(module string) error
- type ACL
- type ClawImports
- type Config
- type Directive
- type ImportFlow
- type LocalReplace
- func (l *LocalReplace) FindNext(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (l *LocalReplace) ParseReplace(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (l *LocalReplace) ReplaceMe(path string) Replace
- func (l *LocalReplace) SkipLinesWithComments(p *halfpike.Parser)
- func (l *LocalReplace) Start(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (l *LocalReplace) Validate() error
- type Module
- func (m *Module) FindNext(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) ParseACLs(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) ParseModule(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) ParseReplace(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) ParseRequire(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) SkipLinesWithComments(p *halfpike.Parser)
- func (m *Module) Start(ctx context.Context, p *halfpike.Parser) halfpike.ParseFn
- func (m *Module) Validate() error
- type Replace
- type Require
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendImports ¶
AppendImports extracts the ImportFlow in the Context and appends pkgPath to it and returns the new Context.
func FindClawFile ¶
FindClawFile will return the absolute path of the .claw file at path.
func ValidModuleName ¶
ValidModuleName determines if a module name is valid.
Types ¶
type ClawImports ¶
type ClawImports struct { // Directive informs where to put all external repository imports. Directive Directive }
ClawImports represents a claw.imports file and includes halfpike methods to decode the file. A claw.imports file looks like the following:
directive { path: "claw/external/imports" }
func (*ClawImports) ParseDirective ¶
func (*ClawImports) SkipLinesWithComments ¶
func (c *ClawImports) SkipLinesWithComments(p *halfpike.Parser)
func (*ClawImports) Validate ¶
func (c *ClawImports) Validate() error
type Config ¶
type Config struct { Root *idl.File // Imports is a mapping of all package paths to their IDL. If the idl.File == nil but // there is a key, then there is a replacement, check the LocalReplace. Imports map[string]*idl.File Module *Module LocalReplace LocalReplace GlobalReplace map[string]Replace // contains filtered or unexported fields }
Config just holds the overall union of claw.mod, local.replace and global.replace.
func (*Config) InRootRepo ¶
InRootRepo will determine if pkgPath is in the root file's repo.
func (*Config) Read ¶
Read reads the .claw file at clawFilePath, any claw.mod files found, any local.replace file, and uses it to build up our Config with all the files that are imported and that they import until we error or have all the files needed to begin building our Claw language files.
type Directive ¶
type Directive struct { // Path is the path to the location in the git repo to store the imports. Path string }
Directive is a directive on where to store our external package renders.
type ImportFlow ¶
type ImportFlow []string
ImportFlow is a list of imports that have been imported in this import path. It is used when going down the tree of imports to make sure we do not see ourselves already in the path, which would indicate a cyclic import.
func ExtractImports ¶
func ExtractImports(ctx context.Context) ImportFlow
ExtractImports extracts a list of packages that have been imported in this import chain from the Context object. A nil return indicates you are at the first file.
func (ImportFlow) String ¶
func (i ImportFlow) String() string
type LocalReplace ¶
type LocalReplace struct { Replace []Replace // contains filtered or unexported fields }
LocalReplace represents the local.replace file and includes halfpike methods to decode the file.
func NewLocalReplace ¶
func NewLocalReplace(fs neededFS, f *idl.File) LocalReplace
func (*LocalReplace) ParseReplace ¶
func (*LocalReplace) ReplaceMe ¶
func (l *LocalReplace) ReplaceMe(path string) Replace
ReplaceMe returns the replacement for path. Use Replace.IsZero() to dermine if it was found or not.
func (*LocalReplace) SkipLinesWithComments ¶
func (l *LocalReplace) SkipLinesWithComments(p *halfpike.Parser)
func (*LocalReplace) Validate ¶
func (l *LocalReplace) Validate() error
type Module ¶
type Module struct { // Path is the module path. Path string // Required is a list of specific versions of packages that must be imported. Required []Require // Replace is a list of packages that should be replaced with a different location. Replace []Replace // ACLs are a list of ACLs that are provided. If it is set to acls = public, then // the first and only ACL will be *. ACLs []ACL }
Module represents a claw.mod file and includes halpike methods to decode the file.
func (*Module) FindNext ¶
FindNext is used to scan lines until we find the next thing to parse and direct to the halfpike.ParseFn responsible.