public class BuckQueryEnvironment extends Object implements QueryEnvironment<QueryBuildTarget>
The query language is documented at docs/command/query.soy
QueryEnvironment.Argument<ENV_NODE_TYPE>, QueryEnvironment.ArgumentType, QueryEnvironment.QueryFunction<OUTPUT_TYPE extends QueryTarget,ENV_NODE_TYPE>
Modifier | Constructor and Description |
---|---|
protected |
BuckQueryEnvironment(Cell rootCell,
com.facebook.buck.cli.OwnersReport.Builder ownersReportBuilder,
Parser parser,
PerBuildState parserState,
com.facebook.buck.cli.TargetPatternEvaluator targetPatternEvaluator,
BuckEventBus eventBus,
TypeCoercerFactory typeCoercerFactory) |
Modifier and Type | Method and Description |
---|---|
void |
buildTransitiveClosure(Set<? extends QueryTarget> targets,
int maxDepth)
Construct the dependency graph for a depth-bounded forward transitive closure of all nodes in
"targetNodes".
|
Set<QueryTarget> |
evaluateQuery(QueryExpression<QueryBuildTarget> expr)
Evaluate the specified query expression in this environment.
|
Set<QueryTarget> |
evaluateQuery(String query) |
com.google.common.collect.ImmutableSet<Object> |
filterAttributeContents(QueryBuildTarget target,
String attribute,
java.util.function.Predicate<Object> predicate)
Returns the objects in the `attribute` of the given `target` that satisfy `predicate`
|
static BuckQueryEnvironment |
from(Cell rootCell,
com.facebook.buck.cli.OwnersReport.Builder ownersReportBuilder,
Parser parser,
PerBuildState parserState,
com.facebook.buck.cli.TargetPatternEvaluator targetPatternEvaluator,
BuckEventBus eventBus,
TypeCoercerFactory typeCoercerFactory) |
static BuckQueryEnvironment |
from(CommandRunnerParams params,
PerBuildState parserState,
ParsingContext parsingContext) |
com.google.common.collect.ImmutableSet<QueryFileTarget> |
getBuildFiles(Set<QueryBuildTarget> targets)
Returns the build files that define the given targets.
|
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
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,QueryBuildTarget>> |
getFunctions()
Returns the set of query functions implemented by this query environment.
|
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
getFwdDeps(Iterable<QueryBuildTarget> targets)
Returns the direct forward dependencies of the specified targets.
|
Set<QueryFileTarget> |
getInputs(QueryBuildTarget target) |
com.google.common.collect.ImmutableSet<TargetNode<?>> |
getNodesFromQueryTargets(Collection<QueryBuildTarget> input) |
PerBuildState |
getParserState() |
Set<QueryBuildTarget> |
getReverseDeps(Iterable<QueryBuildTarget> targets)
Returns the direct reverse dependencies of the specified targets.
|
QueryEnvironment.TargetEvaluator |
getTargetEvaluator()
Returns an evaluator for target patterns.
|
DirectedAcyclicGraph<TargetNode<?>> |
getTargetGraph() |
String |
getTargetKind(QueryBuildTarget target) |
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
getTargetsFromBuildTargets(Iterable<BuildTarget> buildTargets) |
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
getTargetsFromTargetNodes(Iterable<TargetNode<?>> targetNodes) |
com.google.common.collect.ImmutableSet<? extends QueryTarget> |
getTargetsInAttribute(QueryBuildTarget target,
String attribute)
Returns the existing targets in the value of `attribute` of the given `target`.
|
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
getTestsForTarget(QueryBuildTarget target)
Returns the tests associated with the given target.
|
com.google.common.collect.ImmutableSet<QueryBuildTarget> |
getTransitiveClosure(Set<QueryBuildTarget> targets)
Returns the forward transitive closure of all of the targets in "targets".
|
void |
preloadTargetPatterns(Iterable<String> patterns) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachFwdDep, getTargetsMatchingPattern, resolveTargetVariable
protected BuckQueryEnvironment(Cell rootCell, com.facebook.buck.cli.OwnersReport.Builder ownersReportBuilder, Parser parser, PerBuildState parserState, com.facebook.buck.cli.TargetPatternEvaluator targetPatternEvaluator, BuckEventBus eventBus, TypeCoercerFactory typeCoercerFactory)
public static BuckQueryEnvironment from(Cell rootCell, com.facebook.buck.cli.OwnersReport.Builder ownersReportBuilder, Parser parser, PerBuildState parserState, com.facebook.buck.cli.TargetPatternEvaluator targetPatternEvaluator, BuckEventBus eventBus, TypeCoercerFactory typeCoercerFactory)
public static BuckQueryEnvironment from(CommandRunnerParams params, PerBuildState parserState, ParsingContext parsingContext)
public DirectedAcyclicGraph<TargetNode<?>> getTargetGraph()
public PerBuildState getParserState()
public void preloadTargetPatterns(Iterable<String> patterns) throws QueryException, InterruptedException
QueryException
InterruptedException
public Set<QueryTarget> evaluateQuery(QueryExpression<QueryBuildTarget> expr) throws QueryException, InterruptedException
QueryException
- if the evaluation failed.InterruptedException
public Set<QueryTarget> evaluateQuery(String query) throws QueryException, InterruptedException
QueryException
InterruptedException
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getTargetsFromTargetNodes(Iterable<TargetNode<?>> targetNodes)
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getTargetsFromBuildTargets(Iterable<BuildTarget> buildTargets)
public com.google.common.collect.ImmutableSet<TargetNode<?>> getNodesFromQueryTargets(Collection<QueryBuildTarget> input) throws QueryException
QueryException
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getFwdDeps(Iterable<QueryBuildTarget> targets) throws QueryException
QueryEnvironment
getFwdDeps
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public Set<QueryBuildTarget> getReverseDeps(Iterable<QueryBuildTarget> targets) throws QueryException
QueryEnvironment
getReverseDeps
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public Set<QueryFileTarget> getInputs(QueryBuildTarget target) throws QueryException
getInputs
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getTransitiveClosure(Set<QueryBuildTarget> targets) throws QueryException
QueryEnvironment
QueryEnvironment.buildTransitiveClosure(java.util.Set<? extends com.facebook.buck.core.model.QueryTarget>, int)
has been called for the relevant subgraph.getTransitiveClosure
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public void buildTransitiveClosure(Set<? extends QueryTarget> targets, int maxDepth) throws QueryException
QueryEnvironment
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.
buildTransitiveClosure
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getTestsForTarget(QueryBuildTarget target) throws QueryException
QueryEnvironment
getTestsForTarget
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public com.google.common.collect.ImmutableSet<QueryFileTarget> getBuildFiles(Set<QueryBuildTarget> targets)
QueryEnvironment
getBuildFiles
in interface QueryEnvironment<QueryBuildTarget>
public com.google.common.collect.ImmutableSet<QueryBuildTarget> getFileOwners(com.google.common.collect.ImmutableList<String> files)
QueryEnvironment
getFileOwners
in interface QueryEnvironment<QueryBuildTarget>
public String getTargetKind(QueryBuildTarget target) throws QueryException
getTargetKind
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public com.google.common.collect.ImmutableSet<? extends QueryTarget> getTargetsInAttribute(QueryBuildTarget target, String attribute) throws QueryException
QueryEnvironment
Note that unlike most methods in this interface, this method can return a heterogeneous
collection of objects that implement QueryTarget
.
getTargetsInAttribute
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public com.google.common.collect.ImmutableSet<Object> filterAttributeContents(QueryBuildTarget target, String attribute, java.util.function.Predicate<Object> predicate) throws QueryException
QueryEnvironment
filterAttributeContents
in interface QueryEnvironment<QueryBuildTarget>
QueryException
public Iterable<QueryEnvironment.QueryFunction<? extends QueryTarget,QueryBuildTarget>> getFunctions()
QueryEnvironment
getFunctions
in interface QueryEnvironment<QueryBuildTarget>
public QueryEnvironment.TargetEvaluator getTargetEvaluator()
QueryEnvironment
getTargetEvaluator
in interface QueryEnvironment<QueryBuildTarget>