Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Rel is the relative directory of this rule config Rel string // Config is the parent gazelle Config Config *config.Config // Deps is a mapping from label to +/- intent. Deps map[string]bool // Attr is a mapping from string to intent map. Attrs map[string]map[string]bool // Options is a generic key -> value string mapping. Various rule // implementations are free to document/interpret options in an // implementation-dependenct manner. Options map[string]bool // Enabled is a flag that marks language generation as enabled or not Enabled bool // Implementation is the registry identifier for the provider Implementation string // Provider is the actual implementation Provider Provider // Name is the name of the Rule config Name string }
Config carries metadata about a rule and its dependencies.
func NewConfig ¶
NewConfig returns a pointer to a new Config config with the 'Enabled' bit set to true.
func (*Config) GetOptions ¶
GetOptions returns the rule options.
func (*Config) ParseDirective ¶
ParseDirective parses the directive string or returns error.
type Package ¶
type Package interface { // ParseRule parses the sources from the named attr (typically 'srcs') and // created a new Rule. ParseRule(r *grule.Rule, attrName string) (Rule, error) // GenerateArgs returns the GenerateArgs for the package GenerateArgs() language.GenerateArgs }
Package is responsible for instantiating a Rule interface for the given gazelle.Rule, parsing the attribute name given (typically 'srcs').
type Provider ¶
type Provider interface { // Name returns the name of the rule Name() string // LoadInfo returns the gazelle LoadInfo. LoadInfo() grule.LoadInfo // KindInfo returns the gazelle KindInfo. KindInfo() grule.KindInfo // ProvideRule takes the given configuration and compilation and emits a // RuleProvider. If the state of the ScalaConfiguration is such that the // rule should not be emitted, implementation should return nil. ProvideRule(rc *Config, pkg Package) RuleProvider }
Provider is factory pattern capable of taking a config and package and returning a Provider.
type ProviderRegistry ¶
type ProviderRegistry interface { // ProviderNames returns a sorted list of rule names. ProviderNames() []string // LookupProvider returns the implementation under the given name. If the // rule is not found, false is returned. LookupProvider(name string) (Provider, bool) // RegisterProvider installs a Provider implementation under the given name // in the global rule registry. Error will occur if the same rule is // registered multiple times. RegisterProvider(name string, provider Provider) error }
ProviderRegistry represents a library of rule provider implementations.
func GlobalProviderRegistry ¶
func GlobalProviderRegistry() ProviderRegistry
GlobalProviderRegistry returns a reference to the global ProviderRegistry implementation.
type ProviderRegistryMap ¶
type ProviderRegistryMap struct {
// contains filtered or unexported fields
}
ProviderRegistryMap implements ProviderRegistry using a map.
func NewProviderRegistryMap ¶
func NewProviderRegistryMap() *ProviderRegistryMap
func (*ProviderRegistryMap) LookupProvider ¶
func (p *ProviderRegistryMap) LookupProvider(name string) (Provider, bool)
LookupProvider implements part of the RuleRegistry interface.
func (*ProviderRegistryMap) ProviderNames ¶
func (p *ProviderRegistryMap) ProviderNames() []string
ProviderNames implements part of the ProviderRegistry interface.
func (*ProviderRegistryMap) RegisterProvider ¶
func (p *ProviderRegistryMap) RegisterProvider(name string, provider Provider) error
RegisterProvider implements part of the ProviderRegistry interface.
type ResolveContext ¶
type ResolveContext struct { Config *config.Config RuleIndex *resolve.RuleIndex Rule *rule.Rule From label.Label }
ResolveContext carries context about a rule during rule provider import resolution.
type Rule ¶
type Rule interface { // Exports returns the list of provided symbols that are importable by other // rules. Provides() []resolve.ImportSpec // Import returns the list of required imports for the rule. Imports(from label.Label) resolver.ImportMap // Import returns the list of required exports for the rule. Exports(from label.Label) resolver.ImportMap }
Rule represents a collection of files with their imports and exports.
type RuleProvider ¶
type RuleProvider interface { // Kind of rule e.g. 'scala_library' Kind() string // Name of the rule. Name() string // Rule provides the gazelle rule implementation. Rule() *rule.Rule // Resolve performs deps resolution, similar to the gazelle Resolver // interface. Resolve(ctx *ResolveContext, importsRaw interface{}) // Imports implements part of the resolve.Resolver interface. Imports(c *config.Config, r *rule.Rule, file *rule.File) []resolve.ImportSpec }
RuleProvider implementations are capable of providing a rule and import list to the gazelle GenerateArgs response.
type RuleResolver ¶
type RuleResolver interface { // ResolveRule takes the given configuration emits a RuleProvider. If the // state of the package is such that the rule should not managed, return nil. ResolveRule(rc *Config, pkg Package, existing *rule.Rule) RuleProvider }
RuleResolver is an optional interface for a RuleInfo implementation. This is a mechanism for rule implementations to only modify an existing rule rather than having to create one from scratch.