下面列出了com.google.common.collect.ImmutableSortedSet#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e, String timeZone) {
ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
if (!timeUnits.contains(TimeUnitRange.YEAR)) {
// Case when we have FLOOR or CEIL but no extract on YEAR.
// Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
// with timeUnit YEAR.
timeUnits = ImmutableSortedSet.<TimeUnitRange> naturalOrder().addAll(timeUnits).add(TimeUnitRange.YEAR)
.build();
}
final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
for (TimeUnitRange timeUnit : timeUnits) {
e = e.accept(new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits, timeZone));
}
return e;
}
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e,
String timeZone) {
ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
if (!timeUnits.contains(TimeUnitRange.YEAR)) {
// Case when we have FLOOR or CEIL but no extract on YEAR.
// Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
// with timeUnit YEAR.
timeUnits = ImmutableSortedSet.<TimeUnitRange>naturalOrder()
.addAll(timeUnits).add(TimeUnitRange.YEAR).build();
}
final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
for (TimeUnitRange timeUnit : timeUnits) {
e = e.accept(
new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits,
timeZone));
}
return e;
}
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e,
String timeZone) {
ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
if (!timeUnits.contains(TimeUnitRange.YEAR)) {
// Case when we have FLOOR or CEIL but no extract on YEAR.
// Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
// with timeUnit YEAR.
timeUnits = ImmutableSortedSet.<TimeUnitRange>naturalOrder()
.addAll(timeUnits).add(TimeUnitRange.YEAR).build();
}
final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
for (TimeUnitRange timeUnit : timeUnits) {
e = e.accept(
new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits,
timeZone));
}
return e;
}
/** @return Path of the topmost cell's path that roots all other cells */
public AbsPath getSuperRootPath() {
AbsPath cellRoot = getRootCell().getRoot();
ImmutableSortedSet<AbsPath> allRoots = getRootCell().getKnownRootsOfAllCells();
AbsPath path = cellRoot.getRoot();
// check if supercell is a root folder, like '/' or 'C:\'
if (allRoots.contains(path)) {
return path;
}
// There is an assumption that there is exactly one cell with a path that prefixes all other
// cell paths. So just try to find the cell with the shortest common path.
for (Path next : cellRoot.getPath()) {
path = path.resolve(next);
if (allRoots.contains(path)) {
return path;
}
}
throw new IllegalStateException(
"Unreachable: at least one path should be in getKnownRoots(), including root cell '"
+ cellRoot.toString()
+ "'; known roots = ["
+ allRoots.stream().map(Objects::toString).collect(Collectors.joining(", "))
+ "]");
}
private void checkDirectoriesAttributes(
RuleContext ruleContext, PathFragment outputRoot, PathFragment workingDirectory)
throws InterruptedException {
Environment env = ruleContext.getAnalysisEnvironment().getSkyframeEnv();
ImmutableSortedSet<String> notSymlinkedDirs =
BazelSkyframeExecutorConstants.EXTERNAL_PACKAGE_HELPER.getNotSymlinkedInExecrootDirectories(
env);
if (env.valuesMissing()) {
return;
}
// We can compare strings because notSymlinkedDirs contains normalized directory names
if (!notSymlinkedDirs.contains(outputRoot.getPathString())) {
ruleContext.attributeError(
"output_root",
String.format(
"Ninja output root directory '%s' must be declared"
+ " using global workspace function toplevel_output_directories().",
outputRoot.getPathString()));
}
if (!workingDirectory.isEmpty() && !workingDirectory.equals(outputRoot)) {
ruleContext.attributeError(
"working_directory",
String.format(
"Ninja working directory '%s' is restricted to be either empty (or not defined),"
+ " or be the same as output root '%s'.",
workingDirectory.getPathString(), outputRoot.getPathString()));
}
}
/** Computes the bundle name as configured, or falls back to a default name. */
default String computeBundleName(
ImmutableSortedSet<Flavor> flavors, Supplier<String> defaultName) {
for (Pair<Flavor, String> nameForFlavor : getBundleNameForFlavor()) {
if (flavors.contains(nameForFlavor.getFirst())) {
return nameForFlavor.getSecond();
}
}
return getBundleName().orElseGet(defaultName);
}
@SuppressWarnings("unchecked")
private ImmutableMap<String, Object> searchHitToDataMap(
SearchHit hit,
Map<String, Repository> repoMap, // null iff no permission validation required
int maxPreviewLines,
int maxMatchLines,
ImmutableSet<String> noHighlight) {
ImmutableMap.Builder<String, Object> hitData = new ImmutableMap.Builder<String, Object>();
Map<String, Object> hitSource = hit.getSource();
String type = hit.getType();
hitData.put("type", type);
String project = getStringFromMap(hitSource, "project");
hitData.put("project", project);
String repository = getStringFromMap(hitSource, "repository");
hitData.put("repository", repository);
// Validate permissions & build hit data map
String repoId = project + "^" + repository;
Repository repoObject;
if (repoMap == null) { // current user is system administrator
repoObject = repositoryServiceManager.getRepositoryService().getBySlug(
project, repository);
} else { // must validate against allowed repositories for non-administrators
repoObject = repoMap.get(repoId);
}
if (repoObject != null &&
repoObject.getProject().getKey().equals(project) &&
repoObject.getSlug().equals(repository)) {
// Generate refs array
ImmutableSortedSet<String> refSet;
try {
refSet = ImmutableSortedSet.copyOf((Iterable<String>) hitSource.get("refs"));
} catch (Exception e) {
log.warn("Invalid refs collection detected for element in {}/{}", project, repository, e);
return null;
}
if (refSet.isEmpty()) {
log.warn("Detected empty refs collection for element in {}/{}", project, repository);
return null;
}
hitData.put("refs", refSet);
// Human-readable labels
hitData
.put("projectname", repoObject.getProject().getName())
.put("repositoryname", repoObject.getName());
if (type.equals("commit")) {
hitData
.put("hash", getStringFromMap(hitSource, "hash"))
.put("subject", getStringFromMap(hitSource, "subject"))
.put("body", getStringFromMap(hitSource, "body"))
.put("commitDate", getDateStringFromMap(hitSource, "commitdate"))
.put("authorName", getStringFromMap(hitSource, "authorname"))
.put("authorEmail", getStringFromMap(hitSource, "authoremail"));
} else if (type.equals("file")) {
HighlightField highlightField = hit.getHighlightFields().get("contents");
String path = getStringFromMap(hitSource, "path");
String primaryRef = "refs/heads/master";
if (!refSet.contains(primaryRef)) {
primaryRef = refSet.iterator().next();
}
String contents = getStringFromMap(hitSource, "contents");
SourceSearch searchedContents = SourceSearch.search(
contents, highlightField, 1, maxPreviewLines, maxMatchLines);
String extension = getStringFromMap(hitSource, "extension");
hitData
.put("path", path)
.put("blob", getStringFromMap(hitSource, "blob"))
.put("primaryRef", primaryRef)
.put("sourceLines", searchedContents.getJoinedLines())
.put("sourceLineNums", searchedContents.getJoinedLineNums())
.put("isPreview", searchedContents.isPreview())
.put("shownLines", searchedContents.getLines().length)
.put("excessLines", searchedContents.getExcess())
.put("extension", extension)
.put("noHighlight", noHighlight.contains(extension));
}
} else {
return null;
}
return hitData.build();
}
private static boolean containsSwiftHeader(ImmutableSortedSet<Path> paths, String moduleName) {
return paths.contains(Paths.get(moduleName, moduleName + "-Swift.h"));
}