@Override protected void preloadOrThrow(QueryExpression caller, Collection<String> patterns) throws QueryException, TargetParsingException { Map<String, SkyKey> keys = new HashMap<>(patterns.size()); for (String pattern : patterns) { try { keys.put( pattern, TargetPatternValue.key( pattern, TargetPatternEvaluator.DEFAULT_FILTERING_POLICY, parserPrefix)); } catch (TargetParsingException e) { reportBuildFileError(caller, e.getMessage()); } } // Get all the patterns in one batch call Map<SkyKey, SkyValue> existingPatterns = graph.getSuccessfulValues(keys.values()); for (String pattern : patterns) { SkyKey patternKey = keys.get(pattern); if (patternKey == null) { // Exception was thrown when creating key above. Skip. continue; } TargetParsingException targetParsingException = null; if (existingPatterns.containsKey(patternKey)) { // The graph already contains a value or exception for this target pattern, so we use it. TargetPatternValue value = (TargetPatternValue) existingPatterns.get(patternKey); if (value != null) { precomputedPatterns.put(pattern, value.getTargets().getTargets()); } else { // Because the graph was always initialized via a keep_going build, we know that the // exception stored here must be a TargetParsingException. Thus the comment in // SkyframeTargetPatternEvaluator#parseTargetPatternKeys describing the situation in which // the exception acceptance must be looser does not apply here. targetParsingException = (TargetParsingException) Preconditions.checkNotNull(graph.getException(patternKey), pattern); } } if (targetParsingException != null) { reportBuildFileError(caller, targetParsingException.getMessage()); } } }