Documentation ¶
Overview ¶
Package jadeplib finds a list of BUILD labels that provide the requested Java class names.
Index ¶
- func CreateRule(fileName string, namingRules []NamingRule, defaultRuleKind string) *bazel.Rule
- func GetKindForNewRule(filename string, classNames []ClassName) string
- func ImplicitImports(dict *future.Value) *future.Value
- func RulesConsumingFile(ctx context.Context, config Config, fileName string) ([]*bazel.Rule, error)
- func SelectDepsToAdd(in io.Reader, missingDepsMap map[*bazel.Rule]map[ClassName][]bazel.Label) (map[*bazel.Rule][]bazel.Label, error)
- type ClassName
- func ExcludeClassNames(blacklistRegexps []string, classNames []ClassName) []ClassName
- func MissingDeps(ctx context.Context, config Config, rulesToFix []*bazel.Rule, ...) (map[*bazel.Rule]map[ClassName][]bazel.Label, []ClassName, error)
- func UnfilteredMissingDeps(ctx context.Context, config Config, classNames []ClassName) (resolved map[ClassName][]bazel.Label, unresolved []ClassName)
- type Config
- type DepsRanker
- type NamingRule
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateRule ¶
func CreateRule(fileName string, namingRules []NamingRule, defaultRuleKind string) *bazel.Rule
CreateRule creates a new rule with srcs = [filename]. The kind of the new rule is determined by matching fileName against namingRules's FileNameMatcher, in sequence. If no naming rule matches, CreateRule creates a new rule of kind 'defaultRuleKind'. The name of the new rule is the file name (without extension). fileName is a file name relative to the workspace root (e.g., should be 'java/com/Foo.java', not 'Foo.java').
func GetKindForNewRule ¶
GetKindForNewRule determines if a rule that srcs a filename is a java_library rule or a java_test rule.
func ImplicitImports ¶
ImplicitImports returns the set of simple names that Java programs can use without importing, e.g. String, Object, Integer, etc. 'dict' is a future to a map[ClassName][]bazel.Label whose keys are built-in fully-qualified class names. Returns a sorted slice if the input is a sorted slice.
func RulesConsumingFile ¶
RulesConsumingFile returns the set of Java rules whose 'srcs' attribute contains 'fileName'. fileName must be a path relative to config.WorkspaceDir.
Types ¶
type ClassName ¶
type ClassName string
ClassName is a class name, e.g. com.google.Foo.
func ExcludeClassNames ¶
ExcludeClassNames filters class names based on blacklisted regular expressions from the user.
func MissingDeps ¶
func MissingDeps(ctx context.Context, config Config, rulesToFix []*bazel.Rule, classNames []ClassName) (map[*bazel.Rule]map[ClassName][]bazel.Label, []ClassName, error)
MissingDeps returns Labels that can be used to satisfy missing dependencies. For example, let F.java be the Java file the user is processing, and {F1, F2, ..., Fn} be the rules that have F.java in their srcs. Then MissingDeps returns for each Fi, the set of missing dependencies. A missing dependency is reported as a map ClassName -> []bazel.Label, which details which classnames can be satisfied by which dependencies. It also returns a list of classnames that were unable to be resolved.
func UnfilteredMissingDeps ¶
func UnfilteredMissingDeps(ctx context.Context, config Config, classNames []ClassName) (resolved map[ClassName][]bazel.Label, unresolved []ClassName)
UnfilteredMissingDeps returns Labels that can be used to satisfy missing dependencies. Unlike MissingDeps, this function doesn't filter the results according to rule kind, visiblity, tag, etc. The results are ranked according to config.DepsRanker. It also returns a list of classnames that were unable to be resolved.
type Config ¶
type Config struct { // WorkspaceDir is a path to the root of a Bazel workspace. WorkspaceDir string // Loader loads BUILD files. Loader pkgloading.Loader Resolvers []Resolver DepsRanker DepsRanker }
Config specifies the content roots and workspace root. The WorkspaceDir defines the users workspace.
type DepsRanker ¶
type DepsRanker interface { // Less is used in a call to sort.Slice() to rank dependencies before asking a user to choose one. // Less should position the dependency a user is most likely to choose, first. // In other words, the label that should appear first should satisfy Less(ctx, label, x) == true for all x. Less(ctx context.Context, label1, label2 bazel.Label) bool }
DepsRanker defines methods to rank dependencies so it's easier for users to choose the right option.
type NamingRule ¶
type NamingRule struct { // FileNameMatcher matches file names for which we should create a new rule of kind RuleKind. FileNameMatcher *regexp.Regexp // RuleKind is the kind of new rule that NewRule creates, e.g. "java_library". RuleKind string }
NamingRule is used by NewRule to create new Bazel rules.
type Resolver ¶
type Resolver interface { Name() string // consumingRules specifies the dependencies of each rule whose srcs include the file currently being processed. // Resolvers may use this information to short-circuit computations. Resolve(ctx context.Context, classNames []ClassName, consumingRules map[bazel.Label]map[bazel.Label]bool) (map[ClassName][]*bazel.Rule, error) }
Resolver defines methods to resolve class names to Bazel rules.