Search in sources :

Example 1 with PerBuildState

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);
    }
}
Also used : QueryException(com.facebook.buck.query.QueryException) HumanReadableException(com.facebook.buck.util.HumanReadableException) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) BuildFileParseException(com.facebook.buck.json.BuildFileParseException) PerBuildState(com.facebook.buck.parser.PerBuildState)

Example 2 with PerBuildState

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());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) BroadcastEventListener(com.facebook.buck.event.listener.BroadcastEventListener) DefaultTypeCoercerFactory(com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Parser(com.facebook.buck.parser.Parser) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) ConstructorArgMarshaller(com.facebook.buck.rules.ConstructorArgMarshaller) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell) ParserConfig(com.facebook.buck.parser.ParserConfig) PerBuildState(com.facebook.buck.parser.PerBuildState) Before(org.junit.Before)

Aggregations

PerBuildState (com.facebook.buck.parser.PerBuildState)2 BuckEventBus (com.facebook.buck.event.BuckEventBus)1 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 BuildFileParseException (com.facebook.buck.json.BuildFileParseException)1 Parser (com.facebook.buck.parser.Parser)1 ParserConfig (com.facebook.buck.parser.ParserConfig)1 QueryException (com.facebook.buck.query.QueryException)1 Cell (com.facebook.buck.rules.Cell)1 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)1 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)1 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)1 TestConsole (com.facebook.buck.testutil.TestConsole)1 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)1 HumanReadableException (com.facebook.buck.util.HumanReadableException)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 Before (org.junit.Before)1