本文整理匯總了Java中com.google.devtools.build.lib.syntax.SkylarkList.createImmutable方法的典型用法代碼示例。如果您正苦於以下問題:Java SkylarkList.createImmutable方法的具體用法?Java SkylarkList.createImmutable怎麽用?Java SkylarkList.createImmutable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.devtools.build.lib.syntax.SkylarkList
的用法示例。
在下文中一共展示了SkylarkList.createImmutable方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@SuppressWarnings("unused")
public SkylarkList<Transformation> invoke(Core self, SkylarkList<Transformation> transforms,
Location location)
throws EvalException {
ImmutableList.Builder<Transformation> builder = ImmutableList.builder();
for (Transformation t : transforms.getContents(Transformation.class, "transformations")) {
try {
builder.add(t.reverse());
} catch (NonReversibleValidationException e) {
throw new EvalException(location, e.getMessage());
}
}
return SkylarkList.createImmutable(builder.build().reverse());
}
示例2: transform
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@SkylarkCallable(
name = "run", doc = "Run a glob or a transform. For example:<br>"
+ "<code>files = ctx.run(glob(['**.java']))</code><br>or<br>"
+ "<code>ctx.run(core.move(\"foo\", \"bar\"))</code><br>or<br>",
parameters = {
@Param(name = "runnable", type = Object.class,
doc = "A glob or a transform (Transforms still not implemented)"),
})
public Object run(Object runnable) throws EvalException, IOException, ValidationException {
if (runnable instanceof Glob) {
PathMatcher pathMatcher = ((Glob) runnable).relativeTo(checkoutDir);
try (Stream<Path> stream = Files.walk(checkoutDir)) {
return SkylarkList.createImmutable(
stream
.filter(Files::isRegularFile)
.filter(pathMatcher::matches)
.map(p -> new CheckoutPath(checkoutDir.relativize(p), checkoutDir))
.collect(Collectors.toList()));
}
} else if (runnable instanceof Transformation) {
// Works like Sequence. We keep always the latest transform work to allow
// catching for two sequential replaces.
skylarkTransformWork = skylarkTransformWork.withUpdatedTreeState();
((Transformation) runnable).transform(skylarkTransformWork);
this.updateFrom(skylarkTransformWork);
return Runtime.NONE;
}
throw new EvalException(null, String.format(
"Only globs or transforms can be run, but '%s' is of type %s",
runnable, runnable.getClass()));
}
示例3: findLabelValues
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
private SkylarkList<String> findLabelValues(String label, boolean all) {
Map<String, ImmutableList<String>> coreLabels = getCoreLabels();
if (coreLabels.containsKey(label)) {
return SkylarkList.createImmutable(coreLabels.get(label));
}
ArrayList<String> result = new ArrayList<>();
ImmutableList<LabelFinder> msgLabel = getLabelInMessage(label);
if (!msgLabel.isEmpty()) {
result.addAll(Lists.transform(msgLabel, LabelFinder::getValue));
if (!all) {
return SkylarkList.createImmutable(result);
}
}
// Try to find the label in the current changes migrated. We prioritize current
// changes over resolvedReference. Since in iterative mode this would be more
// specific to the current migration.
for (Change<?> change : changes.getCurrent()) {
SkylarkList<String> val = change.getLabelsAllForSkylark().get(label);
if (val != null) {
result.addAll(val);
if (!all) {
return SkylarkList.createImmutable(result);
}
}
}
// Try to find the label in the resolved reference
String resolvedRefLabel = resolvedReference.associatedLabels().get(label);
if (resolvedRefLabel != null) {
result.add(resolvedRefLabel);
}
return SkylarkList.createImmutable(result);
}
示例4: files
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@SkylarkCallable(
name = "source_jars",
doc = "Returns a list of jar files containing all the uncompiled source files (including "
+ "those generated by annotations) from the target itself, i.e. NOT including the sources of "
+ "the transitive dependencies",
structField = true
)
public SkylarkList<Artifact> getSourceJars() {
//TODO(#4221) change return type to NestedSet<Artifact>
JavaSourceJarsProvider provider = providers.getProvider(JavaSourceJarsProvider.class);
ImmutableList<Artifact> sourceJars =
provider == null ? ImmutableList.of() : provider.getSourceJars();
return SkylarkList.createImmutable(sourceJars);
}
示例5: getSrcJarsSkylark
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@Nullable
@SkylarkCallable(
name = "source_jars",
doc = "A list of sources archive files.",
allowReturnNones = true,
structField = true
)
public SkylarkList<Artifact> getSrcJarsSkylark() {
return SkylarkList.createImmutable(srcJars);
}
示例6: tokenize
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@SkylarkCallable(doc = "Splits a shell command to a list of tokens.", documented = false)
public SkylarkList<String> tokenize(String optionString) throws FuncallException, EvalException {
checkMutable("tokenize");
List<String> options = new ArrayList<>();
try {
ShellUtils.tokenize(options, optionString);
} catch (TokenizationException e) {
throw new FuncallException(e.getMessage() + " while tokenizing '" + optionString + "'");
}
return SkylarkList.createImmutable(options);
}
示例7: Changes
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
public Changes(Iterable<? extends Change<?>> current, Iterable<? extends Change<?>> migrated) {
this.current = SkylarkList.createImmutable(current);
this.migrated = SkylarkList.createImmutable(migrated);
}
示例8: getSkylarkArgv
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
@Override
public SkylarkList<String> getSkylarkArgv() throws CommandLineExpansionException {
return SkylarkList.createImmutable(getArguments());
}
示例9: buildSplitAttributeInfo
import com.google.devtools.build.lib.syntax.SkylarkList; //導入方法依賴的package包/類
private static Info buildSplitAttributeInfo(
Collection<Attribute> attributes, RuleContext ruleContext) {
ImmutableMap.Builder<String, Object> splitAttrInfos = ImmutableMap.builder();
for (Attribute attr : attributes) {
if (attr.hasSplitConfigurationTransition()) {
Map<Optional<String>, ? extends List<? extends TransitiveInfoCollection>> splitPrereqs =
ruleContext.getSplitPrerequisites(attr.getName());
Map<Object, Object> splitPrereqsMap = new LinkedHashMap<>();
for (Entry<Optional<String>, ? extends List<? extends TransitiveInfoCollection>> splitPrereq
: splitPrereqs.entrySet()) {
Object value;
if (attr.getType() == BuildType.LABEL) {
Preconditions.checkState(splitPrereq.getValue().size() == 1);
value = splitPrereq.getValue().get(0);
} else {
// BuildType.LABEL_LIST
value = SkylarkList.createImmutable(splitPrereq.getValue());
}
if (splitPrereq.getKey().isPresent()) {
splitPrereqsMap.put(splitPrereq.getKey().get(), value);
} else {
// If the split transition is not in effect, then the key will be missing since there's
// nothing to key on because the dependencies aren't split and getSplitPrerequisites()
// behaves like getPrerequisites(). This also means there should be only one entry in
// the map. Use None in Skylark to represent this.
Preconditions.checkState(splitPrereqs.size() == 1);
splitPrereqsMap.put(Runtime.NONE, value);
}
}
splitAttrInfos.put(attr.getPublicName(), SkylarkDict.copyOf(null, splitPrereqsMap));
}
}
return NativeProvider.STRUCT.create(
splitAttrInfos.build(),
"No attribute '%s' in split_attr. Make sure that this attribute is defined with a "
+ "split configuration.");
}