Documentation ¶
Index ¶
- func GetActualKindName(kind string, args language.GenerateArgs) string
- func NewLanguage() language.Language
- func ParseCode(code []byte, path string) (*sitter.Node, error)
- type Configurer
- type FileParser
- type ParserOutput
- type Python
- type Resolver
- func (py *Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label
- func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec
- func (*Resolver) Name() string
- func (py *Resolver) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetActualKindName ¶
func GetActualKindName(kind string, args language.GenerateArgs) string
func NewLanguage ¶
NewLanguage initializes a new Python that satisfies the language.Language interface. This is the entrypoint for the extension initialization.
Types ¶
type Configurer ¶
type Configurer struct{}
Configurer satisfies the config.Configurer interface. It's the language-specific configuration extension.
func (*Configurer) CheckFlags ¶
CheckFlags validates the configuration after command line flags are parsed. This is called once with the root configuration when Gazelle starts. CheckFlags may set default values in flags or make implied changes.
func (*Configurer) Configure ¶
Configure modifies the configuration using directives and other information extracted from a build file. Configure is called in each directory.
c is the configuration for the current directory. It starts out as a copy of the configuration for the parent directory.
rel is the slash-separated relative path from the repository root to the current directory. It is "" for the root directory itself.
f is the build file for the current directory or nil if there is no existing build file.
func (*Configurer) KnownDirectives ¶
func (py *Configurer) KnownDirectives() []string
KnownDirectives returns a list of directive keys that this Configurer can interpret. Gazelle prints errors for directives that are not recoginized by any Configurer.
func (*Configurer) RegisterFlags ¶
RegisterFlags registers command-line flags used by the extension. This method is called once with the root configuration when Gazelle starts. RegisterFlags may set an initial values in Config.Exts. When flags are set, they should modify these values.
type FileParser ¶
type FileParser struct {
// contains filtered or unexported fields
}
func NewFileParser ¶
func NewFileParser() *FileParser
func (*FileParser) Parse ¶
func (p *FileParser) Parse(ctx context.Context) (*ParserOutput, error)
func (*FileParser) ParseFile ¶
func (p *FileParser) ParseFile(ctx context.Context, repoRoot, relPackagePath, filename string) (*ParserOutput, error)
func (*FileParser) SetCodeAndFile ¶
func (p *FileParser) SetCodeAndFile(code []byte, relPackagePath, filename string)
type ParserOutput ¶
type Python ¶
type Python struct { Configurer Resolver }
Python satisfies the language.Language interface. It is the Gazelle extension for Python rules.
func (*Python) Fix ¶
Fix repairs deprecated usage of language-specific rules in f. This is called before the file is indexed. Unless c.ShouldFix is true, fixes that delete or rename rules should not be performed.
func (*Python) GenerateRules ¶
func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult
GenerateRules extracts build metadata from source files in a directory. GenerateRules is called in each directory where an update is requested in depth-first post-order.
type Resolver ¶
type Resolver struct{}
Resolver satisfies the resolve.Resolver interface. It resolves dependencies in rules generated by this extension.
func (*Resolver) Embeds ¶
Embeds returns a list of labels of rules that the given rule embeds. If a rule is embedded by another importable rule of the same language, only the embedding rule will be indexed. The embedding rule will inherit the imports of the embedded rule.
func (*Resolver) Imports ¶
Imports returns a list of ImportSpecs that can be used to import the rule r. This is used to populate RuleIndex.
If nil is returned, the rule will not be indexed. If any non-nil slice is returned, including an empty slice, the rule will be indexed.
func (*Resolver) Name ¶
Name returns the name of the language. This is the prefix of the kinds of rules generated. E.g. py_library and py_binary.
func (*Resolver) Resolve ¶
func (py *Resolver) Resolve( c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, modulesRaw interface{}, from label.Label, )
Resolve translates imported libraries for a given rule into Bazel dependencies. Information about imported libraries is returned for each rule generated by language.GenerateRules in language.GenerateResult.Imports. Resolve generates a "deps" attribute (or the appropriate language-specific equivalent) for each import according to language-specific rules and heuristics.