NODE_TYPE
- The primary type of "node" in the graph over which a buck query
is run
in this environment. Although all objects returned by QueryEnvironment
implement
QueryTarget
, which is a marker interface for all possible "nodes" in the graph being
queried, most methods return objects that correspond to build rules. As such, NODE_TYPE
specifies the type used to represent build rules in this environment. Methods that
return objects of type NODE_TYPE
therefore provide stronger guarantees than those
that only guarantee QueryTarget
as the return type.public interface QueryEnvironment<NODE_TYPE>
The query language is documented at docs/command/query.soy
Modifier and Type | Interface and Description |
---|---|
static class |
QueryEnvironment.Argument<ENV_NODE_TYPE>
Value of an argument of a user-defined query function.
|
static class |
QueryEnvironment.ArgumentType
Type of an argument of a user-defined query function.
|
static interface |
QueryEnvironment.QueryFunction<OUTPUT_TYPE extends QueryTarget,ENV_NODE_TYPE>
A user-defined query function.
|
static interface |
QueryEnvironment.TargetEvaluator
A procedure for evaluating a target literal to
QueryTarget . |
Modifier and Type | Method and Description |
---|---|
void |
buildTransitiveClosure(Set<? extends QueryTarget> targetNodes,
int maxDepth)
Construct the dependency graph for a depth-bounded forward transitive closure of all nodes in
"targetNodes".
|
Set<Object> |
filterAttributeContents(NODE_TYPE target,
String attribute,
java.util.function.Predicate<Object> predicate)
Returns the objects in the `attribute` of the given `target` that satisfy `predicate`
|
default void |
forEachFwdDep(Iterable<NODE_TYPE> targets,
java.util.function.Consumer<NODE_TYPE> action)
Applies
action to each forward dependencies of the specified targets. |
Set<QueryFileTarget> |
getBuildFiles(Set<NODE_TYPE> targets)
Returns the build files that define the given targets.
|
Set<NODE_TYPE> |
getFileOwners(com.google.common.collect.ImmutableList<String> files)
Returns the targets that own one or more of the given files.
|
Iterable<QueryEnvironment.QueryFunction<? extends QueryTarget,NODE_TYPE>> |
getFunctions()
Returns the set of query functions implemented by this query environment.
|
Set<NODE_TYPE> |
getFwdDeps(Iterable<NODE_TYPE> targets)
Returns the direct forward dependencies of the specified targets.
|
Set<QueryFileTarget> |
getInputs(NODE_TYPE target) |
Set<NODE_TYPE> |
getReverseDeps(Iterable<NODE_TYPE> targets)
Returns the direct reverse dependencies of the specified targets.
|
QueryEnvironment.TargetEvaluator |
getTargetEvaluator()
Returns an evaluator for target patterns.
|
String |
getTargetKind(NODE_TYPE target) |
Set<? extends QueryTarget> |
getTargetsInAttribute(NODE_TYPE target,
String attribute)
Returns the existing targets in the value of `attribute` of the given `target`.
|
default Set<QueryTarget> |
getTargetsMatchingPattern(String pattern)
Returns the set of target nodes in the graph for the specified target pattern, in 'buck build'
syntax.
|
Set<NODE_TYPE> |
getTestsForTarget(NODE_TYPE target)
Returns the tests associated with the given target.
|
Set<NODE_TYPE> |
getTransitiveClosure(Set<NODE_TYPE> targets)
Returns the forward transitive closure of all of the targets in "targets".
|
default Set<NODE_TYPE> |
resolveTargetVariable(String name) |
QueryEnvironment.TargetEvaluator getTargetEvaluator()
default Set<QueryTarget> getTargetsMatchingPattern(String pattern) throws QueryException
QueryException
Set<NODE_TYPE> getFwdDeps(Iterable<NODE_TYPE> targets) throws QueryException
QueryException
default void forEachFwdDep(Iterable<NODE_TYPE> targets, java.util.function.Consumer<NODE_TYPE> action) throws QueryException
action
to each forward dependencies of the specified targets.
Might apply more than once to the same target, so action
should be idempotent.
QueryException
Set<NODE_TYPE> getReverseDeps(Iterable<NODE_TYPE> targets) throws QueryException
QueryException
Set<QueryFileTarget> getInputs(NODE_TYPE target) throws QueryException
QueryException
Set<NODE_TYPE> getTransitiveClosure(Set<NODE_TYPE> targets) throws QueryException
buildTransitiveClosure(java.util.Set<? extends com.facebook.buck.core.model.QueryTarget>, int)
has been called for the relevant subgraph.QueryException
void buildTransitiveClosure(Set<? extends QueryTarget> targetNodes, int maxDepth) throws QueryException
If a larger transitive closure was already built, returns it to improve incrementality, since all depth-constrained methods filter it after it is built anyway.
QueryException
String getTargetKind(NODE_TYPE target) throws QueryException
QueryException
Set<NODE_TYPE> getTestsForTarget(NODE_TYPE target) throws QueryException
QueryException
Set<QueryFileTarget> getBuildFiles(Set<NODE_TYPE> targets) throws QueryException
QueryException
Set<NODE_TYPE> getFileOwners(com.google.common.collect.ImmutableList<String> files) throws QueryException
QueryException
Set<? extends QueryTarget> getTargetsInAttribute(NODE_TYPE target, String attribute) throws QueryException
Note that unlike most methods in this interface, this method can return a heterogeneous
collection of objects that implement QueryTarget
.
QueryException
Set<Object> filterAttributeContents(NODE_TYPE target, String attribute, java.util.function.Predicate<Object> predicate) throws QueryException
QueryException
Iterable<QueryEnvironment.QueryFunction<? extends QueryTarget,NODE_TYPE>> getFunctions()
default Set<NODE_TYPE> resolveTargetVariable(String name)
QueryTarget
s expanded from the given variable name
.