@Override public ImmutableList<Map<String, Object>> getAllRawNodes( Cell cell, ProjectBuildFileParser parser, Path buildFile) throws BuildFileParseException, InterruptedException { Preconditions.checkState(buildFile.isAbsolute()); invalidateIfProjectBuildFileParserStateChanged(cell); try { return loadRawNodes(cell, buildFile, parser); } catch (UncheckedExecutionException | ExecutionException e) { throw propagate(e); } }
@Override public TargetNode<?> getTargetNode( final BuckEventBus eventBus, final Cell cell, final ProjectBuildFileParser parser, final BuildTarget target, final TargetNodeListener nodeListener) throws BuildFileParseException, InterruptedException { invalidateIfProjectBuildFileParserStateChanged(cell); try { return allTargetNodes.get( target, new Callable<TargetNode<?>>() { @Override public TargetNode<?> call() throws Exception { Path buildFile = cell.getAbsolutePathToBuildFile(target); Preconditions.checkState(buildFile.isAbsolute()); List<Map<String, Object>> rawNodes = loadRawNodes(cell, buildFile, parser); for (Map<String, Object> rawNode : rawNodes) { Object shortName = rawNode.get("name"); if (target.getShortName().equals(shortName)) { return createTargetNode(eventBus, cell, buildFile, target, rawNode, nodeListener); } } throw new HumanReadableException( NoSuchBuildTargetException.createForMissingBuildRule( target, BuildTargetPatternParser.forBaseName(target.getBaseName()), cell.getBuildFileName(), "Defined in file: " + buildFile)); } }); } catch (UncheckedExecutionException | ExecutionException e) { throw propagate(e); } }
@Override public ImmutableSet<TargetNode<?>> getAllTargetNodes( final BuckEventBus eventBus, final Cell cell, ProjectBuildFileParser parser, final Path buildFile, final TargetNodeListener nodeListener) throws BuildFileParseException, InterruptedException { Preconditions.checkState(buildFile.isAbsolute()); invalidateIfProjectBuildFileParserStateChanged(cell); try { List<Map<String, Object>> allRawNodes = loadRawNodes(cell, buildFile, parser); ImmutableSet.Builder<TargetNode<?>> nodes = ImmutableSet.builder(); for (final Map<String, Object> rawNode : allRawNodes) { UnflavoredBuildTarget unflavored = parseBuildTargetFromRawRule(cell.getRoot(), rawNode); final BuildTarget target = BuildTarget.of(unflavored); TargetNode<?> node = allTargetNodes.get( target, new Callable<TargetNode<?>>() { @Override public TargetNode<?> call() throws Exception { return createTargetNode( eventBus, cell, buildFile, target, rawNode, nodeListener); } }); nodes.add(node); } return nodes.build(); } catch (UncheckedExecutionException | ExecutionException e) { throw propagate(e); } }