resolve

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoLabel = Label{}

NoLabel is the nil value of Label. It is not a valid label and may be returned when an error occurs.

Functions

func ImportPathToBazelRepoName

func ImportPathToBazelRepoName(importpath string) string

ImportPathToBazelRepoName converts a Go import path into a bazel repo name following the guidelines in http://bazel.io/docs/be/functions.html#workspace

func IsStandard added in v0.7.0

func IsStandard(imp string) bool

IsStandard returns whether a package is in the standard library.

Types

type Label

type Label struct {
	Repo, Pkg, Name string
	Relative        bool
}

A Label represents a label of a build target in Bazel.

func ParseLabel added in v0.7.1

func ParseLabel(s string) (Label, error)

ParseLabel reads a label from a string. See https://docs.bazel.build/versions/master/build-ref.html#lexi.

func (Label) Abs added in v0.7.1

func (l Label) Abs(repo, pkg string) Label

func (Label) String

func (l Label) String() string

type Labeler added in v0.5.4

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

Labeler generates Bazel labels for rules, based on their locations within the repository.

func NewLabeler added in v0.5.4

func NewLabeler(c *config.Config) *Labeler

func (*Labeler) BinaryLabel added in v0.5.4

func (l *Labeler) BinaryLabel(rel string) Label

func (*Labeler) GoProtoLabel added in v0.6.0

func (l *Labeler) GoProtoLabel(rel, name string) Label

func (*Labeler) LibraryLabel added in v0.5.4

func (l *Labeler) LibraryLabel(rel string) Label

func (*Labeler) ProtoLabel added in v0.6.0

func (l *Labeler) ProtoLabel(rel, name string) Label

func (*Labeler) TestLabel added in v0.5.4

func (l *Labeler) TestLabel(rel string, isXTest bool) Label

type Resolver added in v0.5.4

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

Resolver resolves import strings in source files (import paths in Go, import statements in protos) into Bazel labels.

func NewResolver added in v0.5.4

func NewResolver(c *config.Config, l *Labeler, ix *RuleIndex) *Resolver

func (*Resolver) ResolveRule added in v0.7.1

func (r *Resolver) ResolveRule(e bf.Expr, pkgRel string) bf.Expr

ResolveRule copies and modifies a generated rule e by replacing the import paths in the "_gazelle_imports" attribute with labels in a "deps" attribute. This may be safely called on expressions that aren't Go rules (the original expression will be returned). Any existing "deps" attribute is deleted, so it may be necessary to merge the result.

type RuleIndex added in v0.7.1

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

RuleIndex is a table of rules in a workspace, indexed by label and by import path. Used by Resolver to map import paths to labels.

func NewRuleIndex added in v0.7.1

func NewRuleIndex() *RuleIndex

func (*RuleIndex) AddGeneratedRules added in v0.7.1

func (ix *RuleIndex) AddGeneratedRules(c *config.Config, buildRel string, rules []bf.Expr)

AddGeneratedRules adds newly generated rules to the index. These may replace existing rules with the same label.

func (*RuleIndex) AddRulesFromFile added in v0.7.1

func (ix *RuleIndex) AddRulesFromFile(c *config.Config, oldFile *bf.File)

AddRulesFromFile adds existing rules to the index from oldFile (which must not be nil).

func (*RuleIndex) Finish added in v0.7.1

func (ix *RuleIndex) Finish()

Finish constructs the import index and performs any other necessary indexing actions after all rules have been added. This step is necessary because a rule may be indexed differently based on what rules are added later.

This function must be called after all AddRulesFromFile and AddGeneratedRules calls but before any findRuleByImport calls.

Directories

Path Synopsis
internal
gen_std_package_list
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names.
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names.

Jump to

Keyboard shortcuts

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