resolve

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 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 interface {
	LibraryLabel(rel string) Label
	TestLabel(rel string, isXTest bool) Label
	BinaryLabel(rel string) Label
	ProtoLabel(rel, name string) Label
	GoProtoLabel(rel, name string) Label
}

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

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. TODO(#859): imports are currently resolved by guessing a label based on the name. We should be smarter about this and build a table mapping import paths to labels that we can use to cross-reference.

func NewResolver added in v0.5.4

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

func (*Resolver) ResolveRule added in v0.7.1

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

ResolveRule modifies a generated rule e by replacing the import paths in the "_gazelle_imports" attribute with labels in a "deps" attribute. This may may safely called on expressions that aren't Go rules (nothing will happen).

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