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, waitforEachFwdDep, getTargetsMatchingPattern, resolveTargetVariableprotected 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
QueryExceptionInterruptedExceptionpublic Set<QueryTarget> evaluateQuery(QueryExpression<QueryBuildTarget> expr) throws QueryException, InterruptedException
QueryException - if the evaluation failed.InterruptedExceptionpublic Set<QueryTarget> evaluateQuery(String query) throws QueryException, InterruptedException
QueryExceptionInterruptedExceptionpublic 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
QueryExceptionpublic com.google.common.collect.ImmutableSet<QueryBuildTarget> getFwdDeps(Iterable<QueryBuildTarget> targets) throws QueryException
QueryEnvironmentgetFwdDeps in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic Set<QueryBuildTarget> getReverseDeps(Iterable<QueryBuildTarget> targets) throws QueryException
QueryEnvironmentgetReverseDeps in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic Set<QueryFileTarget> getInputs(QueryBuildTarget target) throws QueryException
getInputs in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic com.google.common.collect.ImmutableSet<QueryBuildTarget> getTransitiveClosure(Set<QueryBuildTarget> targets) throws QueryException
QueryEnvironmentQueryEnvironment.buildTransitiveClosure(java.util.Set<? extends com.facebook.buck.core.model.QueryTarget>, int) has been called for the relevant subgraph.getTransitiveClosure in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic void buildTransitiveClosure(Set<? extends QueryTarget> targets, int maxDepth) throws QueryException
QueryEnvironmentIf 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>QueryExceptionpublic com.google.common.collect.ImmutableSet<QueryBuildTarget> getTestsForTarget(QueryBuildTarget target) throws QueryException
QueryEnvironmentgetTestsForTarget in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic com.google.common.collect.ImmutableSet<QueryFileTarget> getBuildFiles(Set<QueryBuildTarget> targets)
QueryEnvironmentgetBuildFiles in interface QueryEnvironment<QueryBuildTarget>public com.google.common.collect.ImmutableSet<QueryBuildTarget> getFileOwners(com.google.common.collect.ImmutableList<String> files)
QueryEnvironmentgetFileOwners in interface QueryEnvironment<QueryBuildTarget>public String getTargetKind(QueryBuildTarget target) throws QueryException
getTargetKind in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic com.google.common.collect.ImmutableSet<? extends QueryTarget> getTargetsInAttribute(QueryBuildTarget target, String attribute) throws QueryException
QueryEnvironmentNote that unlike most methods in this interface, this method can return a heterogeneous
collection of objects that implement QueryTarget.
getTargetsInAttribute in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic com.google.common.collect.ImmutableSet<Object> filterAttributeContents(QueryBuildTarget target, String attribute, java.util.function.Predicate<Object> predicate) throws QueryException
QueryEnvironmentfilterAttributeContents in interface QueryEnvironment<QueryBuildTarget>QueryExceptionpublic Iterable<QueryEnvironment.QueryFunction<? extends QueryTarget,QueryBuildTarget>> getFunctions()
QueryEnvironmentgetFunctions in interface QueryEnvironment<QueryBuildTarget>public QueryEnvironment.TargetEvaluator getTargetEvaluator()
QueryEnvironmentgetTargetEvaluator in interface QueryEnvironment<QueryBuildTarget>