use of com.facebook.buck.parser.PerBuildState in project buck by facebook.
the class QueryCommand method runWithoutHelp.
@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
if (arguments.isEmpty()) {
params.getBuckEventBus().post(ConsoleEvent.severe("Must specify at least the query expression"));
return 1;
}
try (CommandThreadManager pool = new CommandThreadManager("Query", getConcurrencyLimit(params.getBuckConfig()));
PerBuildState parserState = new PerBuildState(params.getParser(), params.getBuckEventBus(), pool.getExecutor(), params.getCell(), getEnableParserProfiling(), SpeculativeParsing.of(true), /* ignoreBuckAutodepsFiles */
false)) {
BuckQueryEnvironment env = BuckQueryEnvironment.from(params, parserState, getEnableParserProfiling());
ListeningExecutorService executor = pool.getExecutor();
return formatAndRunQuery(params, env, executor);
} catch (QueryException | BuildFileParseException e) {
throw new HumanReadableException(e);
}
}
use of com.facebook.buck.parser.PerBuildState in project buck by facebook.
the class BuckQueryEnvironmentTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "query_command", tmp);
workspace.setUp();
Cell cell = new TestCellBuilder().setFilesystem(new ProjectFilesystem(workspace.getDestPath())).build();
TestConsole console = new TestConsole();
DefaultTypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
Parser parser = new Parser(new BroadcastEventListener(), cell.getBuckConfig().getView(ParserConfig.class), typeCoercerFactory, new ConstructorArgMarshaller(typeCoercerFactory));
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
parserState = new PerBuildState(parser, eventBus, executor, cell, /* enableProfiling */
false, SpeculativeParsing.of(true), /* ignoreBuckAutodepsFiles */
false);
TargetPatternEvaluator targetPatternEvaluator = new TargetPatternEvaluator(cell, FakeBuckConfig.builder().build(), parser, eventBus, /* enableProfiling */
false);
OwnersReport.Builder ownersReportBuilder = OwnersReport.builder(cell, parser, eventBus, console);
buckQueryEnvironment = BuckQueryEnvironment.from(cell, ownersReportBuilder, parserState, targetPatternEvaluator);
cellRoot = workspace.getDestPath();
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
Aggregations