starlark annot: delete Param.type and Param.noneable
They are redundant wrt allowedTypes, and create inconsistency/confusion.
BUG=168743413
PiperOrigin-RevId: 337936296
diff --git a/src/main/java/com/google/devtools/build/docgen/starlark/StarlarkParamDoc.java b/src/main/java/com/google/devtools/build/docgen/starlark/StarlarkParamDoc.java
index 48b2132..2eafd05 100644
--- a/src/main/java/com/google/devtools/build/docgen/starlark/StarlarkParamDoc.java
+++ b/src/main/java/com/google/devtools/build/docgen/starlark/StarlarkParamDoc.java
@@ -27,38 +27,29 @@
}
/**
- * Returns the string representing the type of this parameter with the link to the
- * documentation for the type if available.
+ * Returns the string representing the type of this parameter with the link to the documentation
+ * for the type if available.
*
- * <p>If the parameter type is Object, then returns the empty string. If the parameter
- * type is not a generic, then this method returns a string representing the type name
- * with a link to the documentation for the type if available. If the parameter type
- * is a generic, then this method returns a string "CONTAINER of TYPE".
+ * <p>If the parameter type is Object, then returns the empty string. If the parameter type is not
+ * a generic, then this method returns a string representing the type name with a link to the
+ * documentation for the type if available. If the parameter type is a generic, then this method
+ * returns a string "CONTAINER of TYPE" (with HTML link markup).
*/
public String getType() {
- if (param.type().equals(Object.class)) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < param.allowedTypes().length; i++) {
- ParamType paramType = param.allowedTypes()[i];
- // Use the paramType's generic class if provided, otherwise the param's generic class
- Class<?> generic =
- paramType.generic1() == Object.class ? param.generic1() : paramType.generic1();
- if (generic.equals(Object.class)) {
- sb.append(getTypeAnchor(paramType.type()));
- } else {
- sb.append(getTypeAnchor(paramType.type(), generic));
- }
- if (i < param.allowedTypes().length - 1) {
- sb.append("; or ");
- }
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < param.allowedTypes().length; i++) {
+ ParamType paramType = param.allowedTypes()[i];
+ // TODO(adonovan): make generic1 an array.
+ if (paramType.generic1() == Object.class) {
+ sb.append(getTypeAnchor(paramType.type()));
+ } else {
+ sb.append(getTypeAnchor(paramType.type(), paramType.generic1()));
}
- return sb.toString();
+ if (i < param.allowedTypes().length - 1) {
+ sb.append("; or ");
+ }
}
- if (param.generic1().equals(Object.class)) {
- return getTypeAnchor(param.type());
- } else {
- return getTypeAnchor(param.type(), param.generic1());
- }
+ return sb.toString();
}
public StarlarkMethodDoc getMethod() {
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index ba2b185..12c1620 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -531,10 +531,7 @@
+ "Label(\"@remapped//wiz:quux\")\n"
+ "</pre>",
parameters = {
- @Param(
- name = "relName",
- type = String.class,
- doc = "The label that will be resolved relative to this one.")
+ @Param(name = "relName", doc = "The label that will be resolved relative to this one.")
},
useStarlarkThread = true)
public Label getRelative(String relName, StarlarkThread thread) throws LabelSyntaxException {
diff --git a/src/main/java/com/google/devtools/build/lib/packages/StarlarkLibrary.java b/src/main/java/com/google/devtools/build/lib/packages/StarlarkLibrary.java
index 856ec0d..9b2bce2 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/StarlarkLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/StarlarkLibrary.java
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Set;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
@@ -100,11 +101,9 @@
parameters = {
@Param(
name = "x",
- type = Object.class,
defaultValue = "None",
positional = true,
named = false,
- noneable = true,
doc =
"A positional parameter distinct from other parameters for legacy support. "
+ "\n" //
@@ -118,7 +117,6 @@
// TODO(cparsons): Make 'order' keyword-only.
@Param(
name = "order",
- type = String.class,
defaultValue = "\"default\"",
doc =
"The traversal strategy for the new depset. See "
@@ -126,24 +124,22 @@
named = true),
@Param(
name = "direct",
- type = Object.class,
defaultValue = "None",
positional = false,
named = true,
- noneable = true,
doc = "A list of <i>direct</i> elements of a depset. "),
@Param(
name = "transitive",
named = true,
positional = false,
- type = Sequence.class,
- generic1 = Depset.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = Depset.class),
+ @ParamType(type = NoneType.class),
+ },
doc = "A list of depsets whose elements will become indirect elements of the depset.",
defaultValue = "None"),
@Param(
name = "items",
- type = Object.class,
defaultValue = "[]",
positional = false,
doc =
@@ -177,14 +173,12 @@
parameters = {
@Param(
name = "x",
- type = Dict.class,
positional = true,
doc =
"A dict that maps configuration conditions to values. Each key is a label string"
+ " that identifies a config_setting instance."),
@Param(
name = "no_match_error",
- type = String.class,
defaultValue = "''",
doc = "Optional custom error to report if no condition matches.",
named = true),
@@ -216,24 +210,21 @@
"Defines a set of related environments that can be tagged onto rules to prevent"
+ "incompatible rules from depending on each other.",
parameters = {
- @Param(
- name = "name",
- type = String.class,
- positional = false,
- named = true,
- doc = "The name of the rule."),
+ @Param(name = "name", positional = false, named = true, doc = "The name of the rule."),
// Both parameter below are lists of label designators
@Param(
name = "environments",
- type = Sequence.class,
- generic1 = Object.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = Label.class),
+ },
positional = false,
named = true,
doc = "A list of Labels for the environments to be grouped, from the same package."),
@Param(
name = "defaults",
- type = Sequence.class,
- generic1 = Object.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = Label.class),
+ },
positional = false,
named = true,
doc = "A list of Labels.")
@@ -279,8 +270,7 @@
parameters = {
@Param(
name = "license_strings",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
doc = "A list of strings, the names of the licenses used.")
},
// Not documented by docgen, as this is only available in BUILD files.
@@ -306,9 +296,7 @@
@StarlarkMethod(
name = "distribs",
doc = "Declare the distribution(s) for the code in the current package.",
- parameters = {
- @Param(name = "distribution_strings", type = Object.class, doc = "The distributions.")
- },
+ parameters = {@Param(name = "distribution_strings", doc = "The distributions.")},
// Not documented by docgen, as this is only available in BUILD files.
// TODO(cparsons): Devise a solution to document BUILD functions.
documented = false,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagProvider.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagProvider.java
index e820c51..4a5468b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagProvider.java
@@ -78,7 +78,7 @@
@StarlarkMethod(
name = "FeatureFlagInfo",
documented = false,
- parameters = {@Param(name = "value", named = true, type = String.class)},
+ parameters = {@Param(name = "value", named = true)},
selfCall = true)
public ConfigFeatureFlagProvider selfcall(String value) {
return create(value, Predicates.alwaysTrue());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/BootClassPathInfo.java b/src/main/java/com/google/devtools/build/lib/rules/java/BootClassPathInfo.java
index c1249cc..f6e9669 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/BootClassPathInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/BootClassPathInfo.java
@@ -26,9 +26,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.Starlark;
import net.starlark.java.eval.StarlarkThread;
@@ -57,24 +59,16 @@
doc = "The <code>BootClassPathInfo</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "bootclasspath",
- positional = false,
- named = true,
- type = Sequence.class,
- defaultValue = "[]"),
- @Param(
- name = "auxiliary",
- positional = false,
- named = true,
- type = Sequence.class,
- defaultValue = "[]"),
+ @Param(name = "bootclasspath", positional = false, named = true, defaultValue = "[]"),
+ @Param(name = "auxiliary", positional = false, named = true, defaultValue = "[]"),
@Param(
name = "system",
positional = false,
named = true,
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None"),
},
selfCall = true,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/MessageBundleInfo.java b/src/main/java/com/google/devtools/build/lib/rules/java/MessageBundleInfo.java
index df4ca74..7b2c07c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/MessageBundleInfo.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/MessageBundleInfo.java
@@ -57,7 +57,7 @@
doc = "The <code>MessageBundleInfo</code> constructor.",
documented = false,
parameters = {
- @Param(name = "messages", positional = false, named = true, type = Sequence.class),
+ @Param(name = "messages", positional = false, named = true),
},
selfCall = true,
useStarlarkThread = true)
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/CommandLineArgsApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/CommandLineArgsApi.java
index b6e6f87..361b86a 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/CommandLineArgsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/CommandLineArgsApi.java
@@ -21,6 +21,7 @@
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkCallable;
import net.starlark.java.eval.StarlarkThread;
@@ -135,11 +136,13 @@
+ "this method."),
@Param(
name = "format",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"A format string pattern, to be applied to the stringified version of <code>value"
+ "</code>.")
@@ -199,11 +202,13 @@
doc = "The list, tuple, or depset whose items will be appended."),
@Param(
name = "map_each",
- type = StarlarkCallable.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkCallable.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"A function that converts each item to zero or more strings, which may be further "
+ "processed before appending. If this param is not provided, the standard "
@@ -241,28 +246,31 @@
+ "not produce any visible output."),
@Param(
name = "format_each",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"An optional format string pattern, applied to each string returned by the "
+ "<code>map_each</code> function. "
+ "The format string must have exactly one '%s' placeholder."),
@Param(
name = "before_each",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"An optional string to append before each argument derived from "
+ "<code>values</code> is appended."),
@Param(
name = "omit_if_empty",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "True",
@@ -274,7 +282,6 @@
+ "other arguments."),
@Param(
name = "uniquify",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
@@ -286,7 +293,6 @@
+ "multiple items."),
@Param(
name = "expand_directories",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "True",
@@ -295,11 +301,13 @@
+ "of files. This happens before <code>map_each</code> is applied."),
@Param(
name = "terminate_with",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"An optional string to append after all other arguments. This string will not be "
+ "added if <code>omit_if_empty</code> is true (the default) and no other "
@@ -361,7 +369,6 @@
doc = "The list, tuple, or depset whose items will be joined."),
@Param(
name = "join_with",
- type = String.class,
named = true,
positional = false,
doc =
@@ -370,33 +377,38 @@
+ "<a href='string.html#join'><code>string.join()</code></a>."),
@Param(
name = "map_each",
- type = StarlarkCallable.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkCallable.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc = "Same as for <a href='#add_all.map_each'><code>add_all</code></a>."),
@Param(
name = "format_each",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc = "Same as for <a href='#add_all.format_each'><code>add_all</code></a>."),
@Param(
name = "format_joined",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"An optional format string pattern applied to the joined string. "
+ "The format string must have exactly one '%s' placeholder."),
@Param(
name = "omit_if_empty",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "True",
@@ -409,14 +421,12 @@
+ "string (which is the logical join of zero strings)."),
@Param(
name = "uniquify",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
doc = "Same as for <a href='#add_all.uniquify'><code>add_all</code></a>."),
@Param(
name = "expand_directories",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "True",
@@ -448,7 +458,6 @@
parameters = {
@Param(
name = "param_file_arg",
- type = String.class,
named = true,
doc =
"A format string with a single \"%s\". "
@@ -460,7 +469,6 @@
+ "contain \"--file=params.txt\"."),
@Param(
name = "use_always",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
@@ -477,7 +485,6 @@
parameters = {
@Param(
name = "format",
- type = String.class,
named = true,
doc =
"Must be one of:<ul>"
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DefaultInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DefaultInfoApi.java
index 4335554..9285ca8 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DefaultInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DefaultInfoApi.java
@@ -20,9 +20,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.StarlarkThread;
/** A provider that gives general information about a target's direct and transitive files. */
@@ -101,11 +103,13 @@
parameters = {
@Param(
name = "files",
- type = Depset.class,
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"A <a href='depset.html'><code>depset</code></a> of <a"
+ " href='File.html'><code>File</code></a> objects representing the default"
@@ -113,32 +117,38 @@
+ " line. By default it is all predeclared outputs."),
@Param(
name = "runfiles",
- type = RunfilesApi.class,
+ allowedTypes = {
+ @ParamType(type = RunfilesApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"runfiles descriptor describing the files that this target needs when run "
+ "(via the <code>run</code> command or as a tool dependency)."),
@Param(
name = "data_runfiles",
- type = RunfilesApi.class,
+ allowedTypes = {
+ @ParamType(type = RunfilesApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
DEPRECATED_RUNFILES_PARAMETER_WARNING
+ "runfiles descriptor describing the runfiles this target needs to run "
+ "when it is a dependency via the <code>data</code> attribute."),
@Param(
name = "default_runfiles",
- type = RunfilesApi.class,
+ allowedTypes = {
+ @ParamType(type = RunfilesApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
DEPRECATED_RUNFILES_PARAMETER_WARNING
+ "runfiles descriptor describing the runfiles this target needs to run "
@@ -146,11 +156,13 @@
+ "<code>data</code> attribute."),
@Param(
name = "executable",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
doc =
"If this rule is marked <a"
+ " href='globals.html#rule.executable'><code>executable</code></a> or <a"
@@ -163,7 +175,6 @@
useStarlarkThread = true)
@StarlarkConstructor
DefaultInfoApi constructor(
- // TODO(cparsons): Use stricter types when Runfiles.NONE is passed as null.
Object files,
Object runfiles,
Object dataRunfiles,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DirectoryExpander.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DirectoryExpander.java
index 074dfbf..3cd8d9c 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DirectoryExpander.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/DirectoryExpander.java
@@ -40,7 +40,6 @@
parameters = {
@Param(
name = "file",
- type = FileApi.class,
positional = true,
named = false,
doc = "The directory or file to expand."),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/OutputGroupInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/OutputGroupInfoApi.java
index 86fcd40..d64cc3b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/OutputGroupInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/OutputGroupInfoApi.java
@@ -49,7 +49,6 @@
extraKeywords =
@Param(
name = "kwargs",
- type = Dict.class,
defaultValue = "{}",
doc = "Dictionary of arguments."),
selfCall = true)
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/RunfilesApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/RunfilesApi.java
index 7749582..2096f42 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/RunfilesApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/RunfilesApi.java
@@ -61,7 +61,6 @@
name = "other",
positional = true,
named = false,
- type = RunfilesApi.class,
doc = "The runfiles object to merge into this."),
})
RunfilesApi merge(RunfilesApi other);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
index d35fdd2..f746f59 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
@@ -23,6 +23,7 @@
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
@@ -57,7 +58,6 @@
parameters = {
@Param(
name = "filename",
- type = String.class,
doc =
"If no 'sibling' provided, path of the new file, relative "
+ "to the current package. Otherwise a base name for a file "
@@ -67,8 +67,10 @@
doc =
"A file that lives in the same directory as the newly created file. "
+ "The file must be in the current package.",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None")
@@ -86,7 +88,6 @@
parameters = {
@Param(
name = "filename",
- type = String.class,
doc =
"If no 'sibling' provided, path of the new directory, relative "
+ "to the current package. Otherwise a base name for a file "
@@ -94,8 +95,10 @@
@Param(
name = "sibling",
doc = "A file that lives in the same directory as the newly declared directory.",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None")
@@ -115,7 +118,6 @@
parameters = {
@Param(
name = "filename",
- type = String.class,
doc =
"If no 'sibling' provided, path of the new symlink, relative "
+ "to the current package. Otherwise a base name for a file "
@@ -123,8 +125,10 @@
@Param(
name = "sibling",
doc = "A file that lives in the same directory as the newly declared symlink.",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None")
@@ -139,17 +143,15 @@
parameters = {
@Param(
name = "mnemonic",
- type = String.class,
named = true,
positional = false,
doc = "A one-word description of the action, for example, CppCompile or GoLink."),
@Param(
name = "inputs",
allowedTypes = {
- @ParamType(type = Sequence.class),
+ @ParamType(type = Sequence.class, generic1 = FileApi.class),
@ParamType(type = Depset.class),
},
- generic1 = FileApi.class,
named = true,
positional = false,
defaultValue = "[]",
@@ -175,24 +177,27 @@
parameters = {
@Param(
name = "output",
- type = FileApi.class,
named = true,
positional = false,
doc = "The output of this action."),
@Param(
name = "target_file",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
- noneable = true,
defaultValue = "None",
doc = "The File that the output symlink will point to."),
@Param(
name = "target_path",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
- noneable = true,
defaultValue = "None",
doc =
"(Experimental) The exact path that the output symlink will point to. No "
@@ -200,7 +205,6 @@
+ "requires setting <code>--experimental_allow_unresolved_symlinks</code>."),
@Param(
name = "is_executable",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
@@ -214,10 +218,12 @@
+ "dangling symlinks might not exist at build time.</p>"),
@Param(
name = "progress_message",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
- noneable = true,
defaultValue = "None",
doc = "Progress message to show to the user during the build.")
})
@@ -237,7 +243,7 @@
+ "the analysis phase. If the file is large and with a lot of static content, "
+ "consider using <a href=\"#expand_template\"><code>expand_template</code></a>.",
parameters = {
- @Param(name = "output", type = FileApi.class, doc = "The output file.", named = true),
+ @Param(name = "output", doc = "The output file.", named = true),
@Param(
name = "content",
allowedTypes = {
@@ -251,7 +257,6 @@
named = true),
@Param(
name = "is_executable",
- type = Boolean.class,
defaultValue = "False",
doc = "Whether the output file should be executable.",
named = true)
@@ -267,18 +272,18 @@
parameters = {
@Param(
name = "outputs",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = FileApi.class),
+ },
named = true,
positional = false,
doc = "List of the output files of the action."),
@Param(
name = "inputs",
allowedTypes = {
- @ParamType(type = Sequence.class),
+ @ParamType(type = Sequence.class, generic1 = FileApi.class),
@ParamType(type = Depset.class),
},
- generic1 = FileApi.class,
defaultValue = "[]",
named = true,
positional = false,
@@ -287,9 +292,9 @@
name = "unused_inputs_list",
allowedTypes = {
@ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
},
named = true,
- noneable = true,
defaultValue = "None",
positional = false,
doc =
@@ -324,8 +329,9 @@
+ "runfiles that are automatically made available to the action."),
@Param(
name = "arguments",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ },
defaultValue = "[]",
named = true,
positional = false,
@@ -335,16 +341,20 @@
+ "<a href=\"actions.html#args\"><code>actions.args()</code></a> objects."),
@Param(
name = "mnemonic",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = "A one-word description of the action, for example, CppCompile or GoLink."),
@Param(
name = "progress_message",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -353,23 +363,26 @@
+ "for example, \"Compiling foo.cc to create foo.o\"."),
@Param(
name = "use_default_shell_env",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = "Whether the action should use the built in shell environment or not."),
@Param(
name = "env",
- type = Dict.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = "Sets the dictionary of environment variables."),
@Param(
name = "execution_requirements",
- type = Dict.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -382,8 +395,10 @@
// This is technically experimental, so folks shouldn't be too attached,
// but consider renaming to be more accurate/opaque.
name = "input_manifests",
- type = Sequence.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -392,8 +407,10 @@
+ "they are typically generated by resolve_command."),
@Param(
name = "exec_group",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -429,18 +446,16 @@
parameters = {
@Param(
name = "outputs",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
named = true,
positional = false,
doc = "List of the output files of the action."),
@Param(
name = "inputs",
allowedTypes = {
- @ParamType(type = Sequence.class),
+ @ParamType(type = Sequence.class, generic1 = FileApi.class),
@ParamType(type = Depset.class),
},
- generic1 = FileApi.class,
defaultValue = "[]",
named = true,
positional = false,
@@ -448,10 +463,9 @@
@Param(
name = "tools",
allowedTypes = {
- @ParamType(type = Sequence.class),
+ @ParamType(type = Sequence.class, generic1 = FileApi.class),
@ParamType(type = Depset.class),
},
- generic1 = FileApi.class,
defaultValue = "unbound",
named = true,
positional = false,
@@ -461,9 +475,6 @@
+ "The list can contain Files or FilesToRunProvider instances."),
@Param(
name = "arguments",
- allowedTypes = {
- @ParamType(type = Sequence.class),
- },
defaultValue = "[]",
named = true,
positional = false,
@@ -483,8 +494,10 @@
+ "parameter may not be used."),
@Param(
name = "mnemonic",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -525,8 +538,10 @@
+ "genrules."),
@Param(
name = "progress_message",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -535,23 +550,26 @@
+ "for example, \"Compiling foo.cc to create foo.o\"."),
@Param(
name = "use_default_shell_env",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = "Whether the action should use the built in shell environment or not."),
@Param(
name = "env",
- type = Dict.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = "Sets the dictionary of environment variables."),
@Param(
name = "execution_requirements",
- type = Dict.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -564,8 +582,10 @@
// This is technically experimental, so folks shouldn't be too attached,
// but consider renaming to be more accurate/opaque.
name = "input_manifests",
- type = Sequence.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -574,8 +594,10 @@
+ "they are typically generated by resolve_command."),
@Param(
name = "exec_group",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -619,25 +641,21 @@
parameters = {
@Param(
name = "template",
- type = FileApi.class,
named = true,
positional = false,
doc = "The template file, which is a UTF-8 encoded text file."),
@Param(
name = "output",
- type = FileApi.class,
named = true,
positional = false,
doc = "The output file, which is a UTF-8 encoded text file."),
@Param(
name = "substitutions",
- type = Dict.class,
named = true,
positional = false,
doc = "Substitutions to make when expanding the template."),
@Param(
name = "is_executable",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkAttrModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkAttrModuleApi.java
index 5829b3e..3472b2f 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkAttrModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkAttrModuleApi.java
@@ -23,6 +23,7 @@
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkFunction;
import net.starlark.java.eval.StarlarkInt;
@@ -146,29 +147,25 @@
parameters = {
@Param(
name = DEFAULT_ARG,
- type = StarlarkInt.class,
defaultValue = "0",
doc = DEFAULT_DOC,
named = true,
positional = false),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = MANDATORY_DOC,
named = true,
positional = false),
@Param(
name = VALUES_ARG,
- type = Sequence.class,
- generic1 = StarlarkInt.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = StarlarkInt.class)},
defaultValue = "[]",
doc = VALUES_DOC,
named = true,
@@ -189,29 +186,27 @@
parameters = {
@Param(
name = DEFAULT_ARG,
- type = String.class,
defaultValue = "''",
doc = DEFAULT_DOC,
named = true,
positional = false),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = MANDATORY_DOC,
named = true,
positional = false),
@Param(
name = VALUES_ARG,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ },
defaultValue = "[]",
doc = VALUES_DOC,
named = true,
@@ -248,9 +243,9 @@
// I suspect it is a vestige of a "computed defaults" feature
// that was never fully exposed to Starlark (or was since
// withdrawn).
- @ParamType(type = StarlarkFunction.class)
+ @ParamType(type = StarlarkFunction.class),
+ @ParamType(type = NoneType.class),
},
- noneable = true,
defaultValue = "None",
named = true,
positional = false,
@@ -261,14 +256,12 @@
+ "<code>attr.label(default = \"//a:b\")</code>."),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = EXECUTABLE_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -278,45 +271,40 @@
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc = ALLOW_FILES_DOC),
@Param(
name = ALLOW_SINGLE_FILE_ARG,
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc =
"This is similar to <code>allow_files</code>, with the restriction that the label "
+ "must correspond to a single <a href=\"File.html\">File</a>. "
+ "Access it through <code>ctx.file.<attribute_name></code>."),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = MANDATORY_DOC),
@Param(
name = PROVIDERS_ARG,
- type = Sequence.class,
defaultValue = "[]",
named = true,
positional = false,
doc = PROVIDERS_DOC),
@Param(
name = ALLOW_RULES_ARG,
- type = Sequence.class,
- generic1 = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = ALLOW_RULES_DOC),
@Param(
name = CONFIGURATION_ARG,
- type = Object.class,
- noneable = true,
defaultValue = "None",
named = true,
positional = false,
@@ -329,8 +317,7 @@
+ "unless it really helps clarify your intentions."),
@Param(
name = ASPECTS_ARG,
- type = Sequence.class,
- generic1 = StarlarkAspectApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = StarlarkAspectApi.class)},
defaultValue = "[]",
named = true,
positional = false,
@@ -355,33 +342,16 @@
name = "string_list",
doc = "Creates a schema for a list-of-strings attribute.",
parameters = {
- @Param(
- name = MANDATORY_ARG,
- type = Boolean.class,
- defaultValue = "False",
- doc = MANDATORY_DOC,
- named = true),
- @Param(
- name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
- defaultValue = "True",
- doc = ALLOW_EMPTY_DOC,
- named = true),
+ @Param(name = MANDATORY_ARG, defaultValue = "False", doc = MANDATORY_DOC, named = true),
+ @Param(name = ALLOW_EMPTY_ARG, defaultValue = "True", doc = ALLOW_EMPTY_DOC, named = true),
@Param(
name = DEFAULT_ARG,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
doc = DEFAULT_DOC,
named = true,
positional = false),
- @Param(
- name = DOC_ARG,
- type = String.class,
- defaultValue = "''",
- doc = DOC_DOC,
- named = true,
- positional = false)
+ @Param(name = DOC_ARG, defaultValue = "''", doc = DOC_DOC, named = true, positional = false)
},
useStarlarkThread = true)
Descriptor stringListAttribute(
@@ -398,33 +368,16 @@
"Creates a schema for a list-of-integers attribute. Each element must be in the signed"
+ " 32-bit range.",
parameters = {
- @Param(
- name = MANDATORY_ARG,
- type = Boolean.class,
- defaultValue = "False",
- doc = MANDATORY_DOC,
- named = true),
- @Param(
- name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
- defaultValue = "True",
- doc = ALLOW_EMPTY_DOC,
- named = true),
+ @Param(name = MANDATORY_ARG, defaultValue = "False", doc = MANDATORY_DOC, named = true),
+ @Param(name = ALLOW_EMPTY_ARG, defaultValue = "True", doc = ALLOW_EMPTY_DOC, named = true),
@Param(
name = DEFAULT_ARG,
- type = Sequence.class,
- generic1 = StarlarkInt.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = StarlarkInt.class)},
defaultValue = "[]",
doc = DEFAULT_DOC,
named = true,
positional = false),
- @Param(
- name = DOC_ARG,
- type = String.class,
- defaultValue = "''",
- doc = DOC_DOC,
- named = true,
- positional = false)
+ @Param(name = DOC_ARG, defaultValue = "''", doc = DOC_DOC, named = true, positional = false)
},
useStarlarkThread = true)
Descriptor intListAttribute(
@@ -441,12 +394,7 @@
"Creates a schema for a list-of-labels attribute. This is a dependency attribute."
+ DEPENDENCY_ATTR_TEXT,
parameters = {
- @Param(
- name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
- defaultValue = "True",
- doc = ALLOW_EMPTY_DOC,
- named = true),
+ @Param(name = ALLOW_EMPTY_ARG, defaultValue = "True", doc = ALLOW_EMPTY_DOC, named = true),
@Param(
name = DEFAULT_ARG,
allowedTypes = {
@@ -463,61 +411,59 @@
+ "<code>attr.label_list(default = [\"//a:b\", \"//a:c\"])</code>."),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
- name = ALLOW_FILES_ARG, // bool or FileType filter
+ name = ALLOW_FILES_ARG,
+ allowedTypes = {
+ @ParamType(type = Boolean.class),
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc = ALLOW_FILES_DOC),
@Param(
name = ALLOW_RULES_ARG,
- type = Sequence.class,
- generic1 = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = ALLOW_RULES_DOC),
@Param(
name = PROVIDERS_ARG,
- type = Sequence.class,
defaultValue = "[]",
named = true,
positional = false,
doc = PROVIDERS_DOC),
@Param(
name = FLAGS_ARG,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
named = true,
positional = false,
doc = FLAGS_DOC),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = MANDATORY_DOC),
@Param(
name = CONFIGURATION_ARG,
- type = Object.class,
- noneable = true,
defaultValue = "None",
named = true,
positional = false,
doc = CONFIGURATION_DOC),
@Param(
name = ASPECTS_ARG,
- type = Sequence.class,
- generic1 = StarlarkAspectApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = StarlarkAspectApi.class)},
defaultValue = "[]",
named = true,
positional = false,
@@ -545,12 +491,7 @@
+ "the values are strings. This is a dependency attribute."
+ DEPENDENCY_ATTR_TEXT,
parameters = {
- @Param(
- name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
- defaultValue = "True",
- doc = ALLOW_EMPTY_DOC,
- named = true),
+ @Param(name = ALLOW_EMPTY_ARG, defaultValue = "True", doc = ALLOW_EMPTY_DOC, named = true),
@Param(
name = DEFAULT_ARG,
allowedTypes = {
@@ -568,61 +509,59 @@
+ "{\"//a:b\": \"value\", \"//a:c\": \"string\"})</code>."),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
- name = ALLOW_FILES_ARG, // bool or FileType filter
+ name = ALLOW_FILES_ARG,
+ allowedTypes = {
+ @ParamType(type = Boolean.class),
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc = ALLOW_FILES_DOC),
@Param(
name = ALLOW_RULES_ARG,
- type = Sequence.class,
- generic1 = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
doc = ALLOW_RULES_DOC),
@Param(
name = PROVIDERS_ARG,
- type = Sequence.class,
defaultValue = "[]",
named = true,
positional = false,
doc = PROVIDERS_DOC),
@Param(
name = FLAGS_ARG,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
named = true,
positional = false,
doc = FLAGS_DOC),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = MANDATORY_DOC),
@Param(
name = CONFIGURATION_ARG,
- type = Object.class,
- noneable = true,
defaultValue = "None",
named = true,
positional = false,
doc = CONFIGURATION_DOC),
@Param(
name = ASPECTS_ARG,
- type = Sequence.class,
- generic1 = StarlarkAspectApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = StarlarkAspectApi.class)},
defaultValue = "[]",
named = true,
positional = false,
@@ -649,21 +588,18 @@
parameters = {
@Param(
name = DEFAULT_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
doc = DEFAULT_DOC),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -680,14 +616,12 @@
parameters = {
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -703,20 +637,17 @@
parameters = {
@Param(
name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
defaultValue = "True",
doc = ALLOW_EMPTY_DOC,
named = true),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -735,27 +666,23 @@
parameters = {
@Param(
name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
defaultValue = "True",
doc = ALLOW_EMPTY_DOC,
named = true),
@Param(
name = DEFAULT_ARG,
- type = Dict.class,
named = true,
positional = false,
defaultValue = "{}",
doc = DEFAULT_DOC),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
@@ -778,27 +705,23 @@
parameters = {
@Param(
name = ALLOW_EMPTY_ARG,
- type = Boolean.class,
defaultValue = "True",
doc = ALLOW_EMPTY_DOC,
named = true),
@Param(
name = DEFAULT_ARG,
- type = Dict.class,
defaultValue = "{}",
named = true,
positional = false,
doc = DEFAULT_DOC),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -822,20 +745,17 @@
@Param(
name = DEFAULT_ARG,
defaultValue = "None",
- noneable = true,
named = true,
positional = false,
doc = DEFAULT_DOC),
@Param(
name = DOC_ARG,
- type = String.class,
defaultValue = "''",
doc = DOC_DOC,
named = true,
positional = false),
@Param(
name = MANDATORY_ARG,
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkBuildApiGlobals.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkBuildApiGlobals.java
index 3e98616..5bd7caa 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkBuildApiGlobals.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkBuildApiGlobals.java
@@ -43,12 +43,10 @@
parameters = {
@Param(
name = "fragment",
- type = String.class,
named = true,
doc = "The name of a configuration fragment which contains the late-bound value."),
@Param(
name = "name",
- type = String.class,
named = true,
doc = "The name of the value to obtain from the configuration fragment."),
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkCommandLineApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkCommandLineApi.java
index 3bba574..5ffc917 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkCommandLineApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkCommandLineApi.java
@@ -35,12 +35,8 @@
"Deprecated. Creates a single command line argument joining the paths of a set "
+ "of files on the separator string.",
parameters = {
- @Param(name = "separator", type = String.class, doc = "the separator string to join on."),
- @Param(
- name = "files",
- type = Depset.class,
- generic1 = FileApi.class,
- doc = "the files to concatenate.")
+ @Param(name = "separator", doc = "the separator string to join on."),
+ @Param(name = "files", doc = "the files to concatenate.")
})
String joinPaths(String separator, Depset files) throws EvalException;
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkConfigApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkConfigApi.java
index d2d7ddd..d227442 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkConfigApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkConfigApi.java
@@ -17,8 +17,10 @@
import com.google.devtools.build.docgen.annot.DocCategory;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.StarlarkValue;
/**
@@ -55,7 +57,6 @@
parameters = {
@Param(
name = FLAG_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = FLAG_ARG_DOC,
named = true,
@@ -69,7 +70,6 @@
parameters = {
@Param(
name = FLAG_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = FLAG_ARG_DOC,
named = true,
@@ -83,7 +83,6 @@
parameters = {
@Param(
name = FLAG_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = FLAG_ARG_DOC,
named = true,
@@ -97,7 +96,6 @@
parameters = {
@Param(
name = FLAG_ARG,
- type = Boolean.class,
defaultValue = "False",
doc = FLAG_ARG_DOC,
named = true,
@@ -122,9 +120,11 @@
parameters = {
@Param(
name = "exec_group",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
doc =
"The name of the exec group whose execution platform this transition will use. If"
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java
index c242578..c3a2470 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkNativeModuleApi.java
@@ -16,6 +16,7 @@
import com.google.devtools.build.docgen.annot.DocCategory;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
@@ -53,15 +54,13 @@
parameters = {
@Param(
name = "include",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
named = true,
doc = "The list of glob patterns to include."),
@Param(
name = "exclude",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
named = true,
doc = "The list of glob patterns to exclude."),
@@ -73,7 +72,6 @@
doc = "A flag whether to exclude directories or not."),
@Param(
name = "allow_empty",
- type = Object.class,
defaultValue = "unbound",
named = true,
doc =
@@ -116,7 +114,7 @@
+ " order-dependent. Also, beware that it differs subtly from the two"
+ " other conversions of rule attribute values from internal form to Starlark: one"
+ " used by computed defaults, the other used by <code>ctx.attr.foo</code>.",
- parameters = {@Param(name = "name", type = String.class, doc = "The name of the target.")},
+ parameters = {@Param(name = "name", doc = "The name of the target.")},
useStarlarkThread = true)
Object existingRule(String name, StarlarkThread thread)
throws EvalException, InterruptedException;
@@ -141,22 +139,21 @@
parameters = {
@Param(
name = "name",
- type = String.class,
named = true,
positional = false,
doc = "The unique name for this rule."),
@Param(
name = "packages",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ },
defaultValue = "[]",
named = true,
positional = false,
doc = "A complete enumeration of packages in this group."),
@Param(
name = "includes",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
named = true,
positional = false,
@@ -175,16 +172,16 @@
parameters = {
@Param(
name = "srcs",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc = "The list of files to export."),
- // TODO(bazel-team): make it possible to express the precise type ListOf(LabelDesignator)
@Param(
name = "visibility",
- type = Sequence.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
- noneable = true,
named = true,
doc =
"A visibility declaration can to be specified. The files will be visible to the "
@@ -192,9 +189,10 @@
+ "to every package."),
@Param(
name = "licenses",
- type = Sequence.class,
- generic1 = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
defaultValue = "None",
doc = "Licenses to be specified.")
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
index 4a1aac6..1a1d8cc 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleContextApi.java
@@ -33,6 +33,7 @@
import net.starlark.java.eval.ClassObject;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
@@ -252,9 +253,11 @@
parameters = {
@Param(
name = "target",
- type = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = TransitiveInfoCollectionApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
- noneable = true,
named = true,
doc = "A Target specifying a rule. If not provided, defaults to the current rule.")
})
@@ -326,7 +329,6 @@
name = "constraintValue",
positional = true,
named = false,
- type = ConstraintValueInfoApi.class,
doc = "The constraint value to check the target platform against.")
})
boolean targetPlatformHasConstraint(ConstraintValueT constraintValue);
@@ -351,7 +353,6 @@
name = "option",
positional = true,
named = false,
- type = String.class,
doc = "The string to split."),
})
Sequence<String> tokenize(String optionString) throws EvalException;
@@ -369,19 +370,17 @@
name = "expression",
positional = true,
named = false,
- type = String.class,
doc = "The string expression to expand."),
@Param(
name = "files",
positional = true,
named = false,
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
doc = "The list of files."),
@Param(
name = "label_resolver",
positional = true,
named = false,
- type = Label.class,
doc = "The label resolver."),
})
String expand(
@@ -440,17 +439,14 @@
name = "check_placeholders",
documented = false,
parameters = {
- @Param(
- name = "template",
- positional = true,
- named = false,
- type = String.class,
- doc = "The template."),
+ @Param(name = "template", positional = true, named = false, doc = "The template."),
@Param(
name = "allowed_placeholders",
positional = true,
named = false,
- type = Sequence.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ },
doc = "The allowed placeholders."),
})
boolean checkPlaceholders(String template, Sequence<?> allowedPlaceholders) // <String>
@@ -477,20 +473,17 @@
name = "attribute_name",
positional = true,
named = false,
- type = String.class,
doc = "The attribute name. Used for error reporting."),
@Param(
name = "command",
positional = true,
named = false,
- type = String.class,
doc =
"The expression to expand. It can contain references to " + "\"Make variables\"."),
@Param(
name = "additional_substitutions",
positional = true,
named = false,
- type = Dict.class,
doc = "Additional substitutions to make beyond the default make variables."),
})
String expandMakeVariables(
@@ -543,11 +536,12 @@
+ " for <code>genrule</code>). In other cases, it is often better to manipulate"
+ " labels directly.",
parameters = {
- @Param(name = "input", type = String.class, doc = "String to be expanded."),
+ @Param(name = "input", doc = "String to be expanded."),
@Param(
name = "targets",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
defaultValue = "[]",
named = true,
doc = "List of targets for additional lookup information."),
@@ -563,8 +557,7 @@
parameters = {
@Param(
name = "files",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
named = true,
defaultValue = "[]",
doc = "The list of files to be added to the runfiles."),
@@ -573,9 +566,10 @@
// Also, allow empty set for init
@Param(
name = "transitive_files",
- type = Depset.class,
- generic1 = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
doc =
@@ -584,7 +578,6 @@
+ "default)."),
@Param(
name = "collect_data",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -594,7 +587,6 @@
+ "runfiles from the dependencies in srcs, data and deps attributes."),
@Param(
name = "collect_default",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -604,7 +596,6 @@
+ "runfiles from the dependencies in srcs, data and deps attributes."),
@Param(
name = "symlinks",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc =
@@ -613,7 +604,6 @@
+ "the rules guide."),
@Param(
name = "root_symlinks",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc =
@@ -644,22 +634,22 @@
parameters = {
@Param(
name = "command",
- type = String.class, // string
defaultValue = "''",
named = true,
positional = false,
doc = "Command to resolve."),
@Param(
name = "attribute",
- type = String.class, // string
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
- noneable = true,
named = true,
positional = false,
doc = "Name of the associated attribute for which to issue an error, or None."),
@Param(
name = "expand_locations",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -668,8 +658,10 @@
+ " href=\"#expand_location\">ctx.expand_location()</a> for more details."),
@Param(
name = "make_variables",
- type = Dict.class, // dict(string, string)
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class), // <String, String>
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -677,14 +669,14 @@
@Param(
name = "tools",
defaultValue = "[]",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class),
+ },
named = true,
positional = false,
doc = "List of tools (list of targets)."),
@Param(
name = "label_dict",
- type = Dict.class,
defaultValue = "{}",
named = true,
positional = false,
@@ -693,7 +685,6 @@
+ "(a dict of Label : list of Files)."),
@Param(
name = "execution_requirements",
- type = Dict.class,
defaultValue = "{}",
named = true,
positional = false,
@@ -727,8 +718,9 @@
@Param(
name = "tools",
defaultValue = "[]",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
named = true,
positional = false,
doc = "List of tools (list of targets)."),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleFunctionsApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleFunctionsApi.java
index 3247caa..949a1ee 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleFunctionsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkRuleFunctionsApi.java
@@ -65,7 +65,6 @@
parameters = {
@Param(
name = "doc",
- type = String.class,
named = true,
defaultValue = "''",
doc =
@@ -83,9 +82,9 @@
+ " })</pre></ul>All fields are optional.",
allowedTypes = {
@ParamType(type = Sequence.class, generic1 = String.class),
- @ParamType(type = Dict.class)
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
},
- noneable = true,
named = true,
positional = false,
defaultValue = "None")
@@ -105,7 +104,6 @@
parameters = {
@Param(
name = "implementation",
- type = StarlarkFunction.class,
named = true,
doc =
"the Starlark function implementing this rule, must have exactly one parameter: "
@@ -115,7 +113,6 @@
+ "outputs."),
@Param(
name = "test",
- type = Boolean.class,
named = true,
defaultValue = "False",
doc =
@@ -128,9 +125,11 @@
+ "for more information."),
@Param(
name = "attrs",
- type = Dict.class,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
doc =
"dictionary to declare all the attributes of the rule. It maps from an attribute "
@@ -151,7 +150,6 @@
@ParamType(type = StarlarkFunction.class) // a function defined in Starlark
},
named = true,
- noneable = true,
defaultValue = "None",
valueWhenDisabled = "None",
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_NO_RULE_OUTPUTS_PARAM,
@@ -201,7 +199,6 @@
+ " <code>ctx.outputs.bin</code>."),
@Param(
name = "executable",
- type = Boolean.class,
named = true,
defaultValue = "False",
doc =
@@ -211,7 +208,6 @@
+ "for more information."),
@Param(
name = "output_to_genfiles",
- type = Boolean.class,
named = true,
defaultValue = "False",
doc =
@@ -220,25 +216,22 @@
+ "(e.g. when generating header files for C++), do not set this flag."),
@Param(
name = "fragments",
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"List of names of configuration fragments that the rule requires "
+ "in target configuration."),
@Param(
name = "host_fragments",
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"List of names of configuration fragments that the rule requires "
+ "in host configuration."),
@Param(
name = "_skylark_testable",
- type = Boolean.class,
named = true,
defaultValue = "False",
doc =
@@ -252,9 +245,8 @@
+ "Starlark rules. This flag may be removed in the future."),
@Param(
name = TOOLCHAINS_PARAM,
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"If set, the set of toolchains this rule requires. Toolchains will be "
@@ -262,7 +254,6 @@
+ "implementation via <code>ctx.toolchain</code>."),
@Param(
name = "incompatible_use_toolchain_transition",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -271,7 +262,6 @@
+ " set."),
@Param(
name = "doc",
- type = String.class,
named = true,
defaultValue = "''",
doc =
@@ -279,15 +269,13 @@
+ "tools."),
@Param(
name = "provides",
- type = Sequence.class,
named = true,
positional = false,
defaultValue = "[]",
doc = PROVIDES_DOC),
@Param(
name = EXEC_COMPATIBLE_WITH_PARAM,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
@@ -296,9 +284,6 @@
+ "this rule type."),
@Param(
name = "analysis_test",
- allowedTypes = {
- @ParamType(type = Boolean.class),
- },
named = true,
positional = false,
defaultValue = "False",
@@ -318,8 +303,10 @@
+ " href='AnalysisTestResultInfo.html'>AnalysisTestResultInfo</a>.</li></ul>"),
@Param(
name = "build_setting",
- type = BuildSettingApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = BuildSettingApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
@@ -332,8 +319,6 @@
+ "added to this rule, with a type corresponding to the value passed in here."),
@Param(
name = "cfg",
- type = Object.class,
- noneable = true,
defaultValue = "None",
named = true,
positional = false,
@@ -342,9 +327,11 @@
+ "apply to its own configuration before analysis."),
@Param(
name = "exec_groups",
- type = Dict.class,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
positional = false,
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_EXEC_GROUPS,
@@ -388,7 +375,6 @@
parameters = {
@Param(
name = "implementation",
- type = StarlarkFunction.class,
named = true,
doc =
"A Starlark function that implements this aspect, with exactly two parameters: "
@@ -399,9 +385,8 @@
+ "analysis phase for each application of an aspect to a target."),
@Param(
name = "attr_aspects",
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"List of attribute names. The aspect propagates along dependencies specified in "
@@ -411,9 +396,11 @@
+ "target."),
@Param(
name = "attrs",
- type = Dict.class,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
doc =
"A dictionary declaring all the attributes of the aspect. It maps from an "
@@ -431,7 +418,6 @@
+ "name, type, and valid values according to the restriction."),
@Param(
name = "required_aspect_providers",
- type = Sequence.class,
named = true,
defaultValue = "[]",
doc =
@@ -452,35 +438,27 @@
+ "see <code>other_aspect</code> if and only if <code>other_aspect</code> "
+ "provides <code>FooInfo</code> *or* <code>BarInfo</code> *or* both "
+ "<code>BazInfo</code> *and* <code>QuxInfo</code>."),
- @Param(
- name = "provides",
- type = Sequence.class,
- named = true,
- defaultValue = "[]",
- doc = PROVIDES_DOC),
+ @Param(name = "provides", named = true, defaultValue = "[]", doc = PROVIDES_DOC),
@Param(
name = "fragments",
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"List of names of configuration fragments that the aspect requires "
+ "in target configuration."),
@Param(
name = "host_fragments",
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"List of names of configuration fragments that the aspect requires "
+ "in host configuration."),
@Param(
name = TOOLCHAINS_PARAM,
- type = Sequence.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
- generic1 = String.class,
defaultValue = "[]",
doc =
"If set, the set of toolchains this rule requires. Toolchains will be "
@@ -488,7 +466,6 @@
+ "implementation via <code>ctx.toolchain</code>."),
@Param(
name = "incompatible_use_toolchain_transition",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -497,7 +474,6 @@
+ " set."),
@Param(
name = "doc",
- type = String.class,
named = true,
defaultValue = "''",
doc =
@@ -505,7 +481,6 @@
+ "tools."),
@Param(
name = "apply_to_generating_rules",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
@@ -544,10 +519,9 @@
+ "attributes. The argument must refer to an absolute label. "
+ "Example: <br><pre class=language-python>Label(\"//tools:default\")</pre>",
parameters = {
- @Param(name = "label_string", type = String.class, doc = "the label string."),
+ @Param(name = "label_string", doc = "the label string."),
@Param(
name = "relative_to_caller_repository",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -574,16 +548,14 @@
parameters = {
@Param(
name = TOOLCHAINS_PARAM,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
doc = "<i>Experimental</i> The set of toolchains this execution group requires."),
@Param(
name = EXEC_COMPATIBLE_WITH_PARAM,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/TemplateVariableInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/TemplateVariableInfoApi.java
index 43c7ac7..eef5fe3 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/TemplateVariableInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/TemplateVariableInfoApi.java
@@ -59,7 +59,7 @@
doc = "The <code>TemplateVariableInfo</code> constructor.",
documented = false,
parameters = {
- @Param(name = "vars", positional = true, named = true, type = Dict.class),
+ @Param(name = "vars", positional = true, named = true),
},
selfCall = true,
useStarlarkThread = true)
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/WorkspaceGlobalsApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/WorkspaceGlobalsApi.java
index 60ce569..982bd55 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/WorkspaceGlobalsApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/WorkspaceGlobalsApi.java
@@ -18,6 +18,7 @@
import com.google.devtools.build.docgen.annot.DocumentMethods;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
@@ -58,7 +59,6 @@
parameters = {
@Param(
name = "name",
- type = String.class,
doc =
"the name of the workspace. Names must start with a letter and can only contain "
+ "letters, numbers, and underscores.",
@@ -66,8 +66,6 @@
positional = false),
@Param(
name = "managed_directories",
- type = Dict.class,
- generic1 = String.class,
named = true,
positional = false,
defaultValue = "{}",
@@ -104,8 +102,7 @@
parameters = {
@Param(
name = "paths",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
doc = "",
named = true,
positional = false)
@@ -125,8 +122,7 @@
extraPositionals =
@Param(
name = "platform_labels",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
doc = "The labels of the platforms to register."),
useStarlarkThread = true)
NoneType registerExecutionPlatforms(Sequence<?> platformLabels, StarlarkThread thread)
@@ -144,8 +140,7 @@
extraPositionals =
@Param(
name = "toolchain_labels",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
doc = "The labels of the toolchains to register."),
useStarlarkThread = true)
NoneType registerToolchains(Sequence<?> toolchainLabels, StarlarkThread thread)
@@ -162,16 +157,17 @@
parameters = {
@Param(
name = "name",
- type = String.class,
named = true,
positional = false,
doc = "The label under '//external' to serve as the alias name"),
@Param(
name = "actual",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
positional = false,
- noneable = true,
defaultValue = "None",
doc = "The real label to be aliased")
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidApplicationResourceInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidApplicationResourceInfoApi.java
index aebdb58..6f0a5a4 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidApplicationResourceInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidApplicationResourceInfoApi.java
@@ -18,9 +18,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
/** Supplies a resource apk file (".ap_") and related info. */
@StarlarkBuiltin(
@@ -121,46 +123,60 @@
parameters = {
@Param(
name = "resource_apk",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = ""),
@Param(
name = "resource_java_src_jar",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = ""),
@Param(
name = "resource_java_class_jar",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = ""),
- @Param(name = "manifest", type = FileApi.class, named = true, doc = ""),
+ @Param(name = "manifest", named = true, doc = ""),
@Param(
name = "resource_proguard_config",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = ""),
@Param(
name = "main_dex_proguard_config",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = ""),
@Param(
name = "r_txt",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = "",
defaultValue = "None"),
@Param(
name = "resources_zip",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = "",
defaultValue = "None"),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidAssetsInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidAssetsInfoApi.java
index cad04f9..462f5cd 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidAssetsInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidAssetsInfoApi.java
@@ -23,9 +23,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
/** Provides information about transitive Android assets. */
@StarlarkBuiltin(
@@ -116,50 +118,50 @@
name = "label",
doc = "The label of the target.",
positional = true,
- named = false,
- type = Label.class),
+ named = false),
@Param(
name = "validation_result",
doc = "An artifact of the validation result.",
positional = true,
named = true,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "direct_parsed_assets",
doc = "A depset of all the parsed assets in the target.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = ParsedAndroidAssetsApi.class),
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = ParsedAndroidAssetsApi.class)
+ }),
@Param(
name = "transitive_parsed_assets",
doc = "A depset of all the parsed assets in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = ParsedAndroidAssetsApi.class),
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = ParsedAndroidAssetsApi.class)
+ }),
@Param(
name = "transitive_assets",
doc = "A depset of all the assets in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_symbols",
doc = "A depset of all the symbols in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_compiled_symbols",
doc = "A depset of all the compiled symbols in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBinaryDataInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBinaryDataInfoApi.java
index 8073c53..5aa6758 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBinaryDataInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBinaryDataInfoApi.java
@@ -73,36 +73,15 @@
doc = "The <code>AndroidBinaryDataInfoApi</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "resource_apk",
- doc = "resource_apk",
- positional = false,
- named = true,
- type = FileApi.class),
+ @Param(name = "resource_apk", doc = "resource_apk", positional = false, named = true),
@Param(
name = "resource_proguard_config",
doc = "resource_proguard_config",
positional = false,
- named = true,
- type = FileApi.class),
- @Param(
- name = "resources_info",
- doc = "resources_info",
- positional = false,
- named = true,
- type = AndroidResourcesInfoApi.class),
- @Param(
- name = "assets_info",
- doc = "assets_info",
- positional = false,
- named = true,
- type = AndroidAssetsInfoApi.class),
- @Param(
- name = "manifest_info",
- doc = "manifest_info",
- positional = false,
- named = true,
- type = AndroidManifestInfoApi.class),
+ named = true),
+ @Param(name = "resources_info", doc = "resources_info", positional = false, named = true),
+ @Param(name = "assets_info", doc = "assets_info", positional = false, named = true),
+ @Param(name = "manifest_info", doc = "manifest_info", positional = false, named = true),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidCcLinkParamsProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidCcLinkParamsProviderApi.java
index d6a6743..5038513 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidCcLinkParamsProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidCcLinkParamsProviderApi.java
@@ -58,12 +58,7 @@
doc = "The <code>AndroidCcLinkParamsInfo</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "store",
- doc = "The CcInfo provider.",
- positional = true,
- named = false,
- type = CcInfoApi.class),
+ @Param(name = "store", doc = "The CcInfo provider.", positional = true, named = false),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDataProcessingApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDataProcessingApi.java
index 4e0e963..c11233d 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDataProcessingApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDataProcessingApi.java
@@ -20,10 +20,12 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.TransitiveInfoCollectionApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
@@ -56,15 +58,15 @@
@Param(
name = "deps",
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidAssetsInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidAssetsInfoApi.class)
+ },
positional = false,
named = true,
doc = "Dependencies to inherit assets from."),
@Param(
name = "neverlink",
defaultValue = "False",
- type = Boolean.class,
positional = false,
named = true,
doc =
@@ -90,28 +92,28 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "deps",
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidResourcesInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidResourcesInfoApi.class)
+ },
positional = false,
named = true,
doc = "Dependencies to inherit resources from."),
@Param(
name = "assets",
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidAssetsInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidAssetsInfoApi.class),
+ },
positional = false,
named = true,
doc = "Dependencies to inherit assets from."),
@Param(
name = "neverlink",
defaultValue = "False",
- type = Boolean.class,
positional = false,
named = true,
doc =
@@ -120,8 +122,6 @@
@Param(
name = "custom_package",
positional = false,
- type = String.class,
- noneable = false,
named = true,
doc = "The Android application package to stamp the manifest with."),
},
@@ -147,22 +147,25 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "manifest",
positional = false,
defaultValue = "None",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc = "The manifest to stamp. If not passed, a dummy manifest will be generated."),
@Param(
name = "custom_package",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"The Android application package to stamp the manifest with. If not provided, the"
@@ -173,7 +176,6 @@
name = "exports_manifest",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If passed as True, this manifest will be exported to and"
@@ -193,15 +195,15 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "assets",
positional = false,
defaultValue = "None",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Targets containing raw assets for this target. If passed, 'assets_dir' must also"
@@ -210,8 +212,10 @@
name = "assets_dir",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Directory the assets are contained in. Must be passed if and only if 'assets' is"
@@ -220,8 +224,9 @@
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidAssetsInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidAssetsInfoApi.class)
+ },
named = true,
doc =
"Providers containing assets from dependencies. These assets will be merged"
@@ -230,7 +235,6 @@
name = "neverlink",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If passed as True, these assets will not be inherited by"
@@ -257,13 +261,11 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "manifest",
positional = true,
named = false,
- type = AndroidManifestInfoApi.class,
doc =
"The provider of this target's manifest. This provider is produced by, "
+ "for example, stamp_android_manifest."),
@@ -271,16 +273,16 @@
name = "resources",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = FileProviderApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileProviderApi.class)},
named = true,
doc = "Providers of this target's resources."),
@Param(
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidResourcesInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidResourcesInfoApi.class),
+ },
named = true,
doc =
"Targets containing raw resources from dependencies. These resources will be merged"
@@ -289,7 +291,6 @@
name = "neverlink",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If passed as True, these resources will not be inherited by"
@@ -298,7 +299,6 @@
name = "enable_data_binding",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If True, processes data binding expressions in layout"
@@ -331,13 +331,11 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "manifest",
positional = true,
named = false,
- type = AndroidManifestInfoApi.class,
doc =
"The provider of this target's manifest. This provider is produced by, "
+ "for example, stamp_android_manifest."),
@@ -345,16 +343,16 @@
name = "resources",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = FileProviderApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileProviderApi.class)},
named = true,
doc = "Providers of this target's resources."),
@Param(
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = AndroidResourcesInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidResourcesInfoApi.class)
+ },
named = true,
doc =
"Targets containing raw resources from dependencies. These resources will be merged"
@@ -363,7 +361,6 @@
name = "neverlink",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If passed as True, these resources will not be inherited by"
@@ -372,7 +369,6 @@
name = "enable_data_binding",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If True, processes data binding expressions in layout"
@@ -404,13 +400,11 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "resource_info",
positional = true,
named = false,
- type = AndroidResourcesInfoApi.class,
doc =
"The provider containing processed resources for this target, produced, "
+ "for example, by merge_resources."),
@@ -418,7 +412,6 @@
name = "asset_info",
positional = true,
named = false,
- type = AndroidAssetsInfoApi.class,
doc =
"The provider containing processed assets for this target, produced, "
+ "for example, by merge_assets."),
@@ -426,12 +419,10 @@
name = "library_class_jar",
positional = true,
named = false,
- type = FileApi.class,
doc = "The library class jar."),
@Param(
name = "local_proguard_specs",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
positional = false,
named = true,
@@ -440,15 +431,15 @@
+ " inherited in the top-level target."),
@Param(
name = "deps",
- type = Sequence.class,
- generic1 = AndroidLibraryAarInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = AndroidLibraryAarInfoApi.class)
+ },
defaultValue = "[]",
positional = false,
named = true,
doc = "Dependant AAR providers used to build this AAR."),
@Param(
name = "neverlink",
- type = Boolean.class,
defaultValue = "False",
positional = false,
named = true,
@@ -478,30 +469,15 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
- @Param(
- name = "resource",
- positional = true,
- named = false,
- type = FileApi.class,
- doc = "The resouce file."),
- @Param(
- name = "assets",
- positional = true,
- named = false,
- type = FileApi.class,
- doc = "The assets file."),
- @Param(
- name = "manifest",
- positional = true,
- named = false,
- type = FileApi.class,
- doc = "The manifest file."),
+ @Param(name = "resource", positional = true, named = false, doc = "The resource file."),
+ @Param(name = "assets", positional = true, named = false, doc = "The assets file."),
+ @Param(name = "manifest", positional = true, named = false, doc = "The manifest file."),
@Param(
name = "deps",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
named = true,
positional = false,
defaultValue = "[]",
@@ -524,15 +500,16 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "manifest",
positional = false,
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
- noneable = true,
doc =
"If passed, the manifest to use for this target. Otherwise, a dummy manifest will"
+ " be generated."),
@@ -540,17 +517,17 @@
name = "resources",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = FileProviderApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileProviderApi.class)},
named = true,
doc = "Providers of this target's resources."),
@Param(
name = "assets",
positional = false,
defaultValue = "None",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Targets containing raw assets for this target. If passed, 'assets_dir' must also"
@@ -559,8 +536,10 @@
name = "assets_dir",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Directory the assets are contained in. Must be passed if and only if 'assets' is"
@@ -569,8 +548,10 @@
name = "custom_package",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"The Android application package to stamp the manifest with. If not provided, the"
@@ -581,7 +562,6 @@
name = "aapt_version",
positional = false,
defaultValue = "'auto'",
- type = String.class,
named = true,
doc =
"The version of aapt to use. Defaults to 'auto'. 'aapt' and 'aapt2' are also"
@@ -590,8 +570,7 @@
name = "manifest_values",
positional = false,
defaultValue = "{}",
- type = Dict.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Dict.class, generic1 = String.class)},
named = true,
doc =
"A dictionary of values to be overridden in the manifest. You must expand any"
@@ -600,8 +579,9 @@
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
named = true,
doc =
"Dependency targets. Providers will be extracted from these dependencies for each"
@@ -610,16 +590,14 @@
name = "nocompress_extensions",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc = "A list of file extensions to leave uncompressed in the resource apk."),
@Param(
name = "resource_configuration_filters",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc =
"A list of resource configuration filters, such as 'en' that will limit the"
@@ -628,8 +606,7 @@
name = "densities",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc =
"Densities to filter for when building the apk. A corresponding compatible-screens"
@@ -662,14 +639,15 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "shrink_resources",
positional = false,
- noneable = true,
defaultValue = "None",
- type = Boolean.class,
+ allowedTypes = {
+ @ParamType(type = Boolean.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Whether to shrink resources. Defaults to the value used in Android"
@@ -678,8 +656,7 @@
name = "resource_configuration_filters",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc =
"A list of resource configuration filters, such as 'en' that will limit the"
@@ -688,8 +665,7 @@
name = "densities",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc =
"Densities to filter for when building the apk. A corresponding compatible-screens"
@@ -699,8 +675,7 @@
name = "nocompress_extensions",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
doc =
"A list of file extension to leave uncompressed in apk. Templates must be"
@@ -725,23 +700,22 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "resources",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = FileProviderApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileProviderApi.class)},
named = true,
doc = "Providers of this target's resources."),
@Param(
name = "assets",
positional = false,
defaultValue = "None",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Targets containing raw assets for this target. If passed, 'assets_dir' must also"
@@ -750,8 +724,10 @@
name = "assets_dir",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"Directory the assets are contained in. Must be passed if and only if 'assets' is"
@@ -759,10 +735,12 @@
@Param(
name = "manifest",
positional = false,
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
- noneable = true,
doc =
"If passed, the manifest to use for this target. Otherwise, a dummy manifest will"
+ " be generated."),
@@ -770,8 +748,10 @@
name = "custom_package",
positional = false,
defaultValue = "None",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
doc =
"The Android application package to stamp the manifest with. If not provided, the"
@@ -782,8 +762,7 @@
name = "manifest_values",
positional = false,
defaultValue = "{}",
- type = Dict.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Dict.class, generic1 = String.class)},
named = true,
doc =
"A dictionary of values to be overridden in the manifest. You must expand any"
@@ -792,15 +771,15 @@
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
named = true,
doc =
"Dependency targets. Providers will be extracted from these dependencies for each"
+ " type of data."),
@Param(
name = "manifest_merger",
- type = String.class,
defaultValue = "'auto'",
positional = false,
named = true,
@@ -809,8 +788,10 @@
+ " also supported."),
@Param(
name = "binary_settings",
- type = AndroidBinaryDataSettingsApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = AndroidBinaryDataSettingsApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
positional = false,
named = true,
@@ -821,14 +802,12 @@
name = "crunch_png",
positional = false,
defaultValue = "True",
- type = Boolean.class,
named = true,
doc = "Whether PNG crunching should be done. Defaults to True."),
@Param(
name = "enable_data_binding",
positional = false,
defaultValue = "False",
- type = Boolean.class,
named = true,
doc =
"Defaults to False. If True, processes data binding expressions in layout"
@@ -860,30 +839,24 @@
name = "ctx",
positional = true,
named = false,
- type = AndroidDataContextApi.class,
doc = "The Android data context object for this target."),
@Param(
name = "binary_data_info",
positional = true,
named = false,
- type = AndroidBinaryDataInfoApi.class,
doc = "The Info about the binary to shrink, as produced by process_binary_data."),
@Param(
name = "proguard_output_jar",
positional = true,
named = false,
- type = FileApi.class,
doc = "The proguard jar output file."),
@Param(
name = "proguard_mapping",
positional = true,
named = false,
- type = FileApi.class,
doc = "The proguard mapping output file."),
@Param(
name = "binary_settings",
- type = AndroidBinaryDataSettingsApi.class,
- noneable = true,
defaultValue = "None",
positional = false,
named = true,
@@ -894,16 +867,18 @@
name = "deps",
positional = false,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
named = true,
doc =
"Dependency targets. Providers will be extracted from these dependencies for each"
+ " type of data."),
@Param(
name = "proguard_specs",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
defaultValue = "[]",
positional = false,
named = true,
@@ -912,8 +887,9 @@
+ " inherited in the top-level target."),
@Param(
name = "extra_proguard_specs,",
- type = Sequence.class,
- generic1 = TransitiveInfoCollectionApi.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = TransitiveInfoCollectionApi.class)
+ },
defaultValue = "[]",
positional = false,
named = true,
@@ -946,8 +922,7 @@
name = "validated_res",
doc = "The validated Android resources.",
positional = true,
- named = false,
- type = ValidatedAndroidDataApi.class)
+ named = false)
})
FileT resourcesFromValidatedRes(ValidatedAndroidDataT resources);
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java
index f15f423..0062791 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java
@@ -49,7 +49,6 @@
parameters = {
@Param(
name = "type",
- type = String.class,
named = true,
doc =
"The type of device broker that is appropriate to use to interact with "
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDex2OatInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDex2OatInfoApi.java
index 05d370f..0a87925 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDex2OatInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDex2OatInfoApi.java
@@ -49,12 +49,11 @@
doc = "The <code>AndroidDex2OatInfo</code> constructor.",
documented = false,
parameters = {
- @Param(name = "enabled", positional = false, named = true, type = Boolean.class),
+ @Param(name = "enabled", positional = false, named = true),
@Param(
name = "execute_dex2oat_on_host",
positional = false,
named = true,
- type = Boolean.class,
defaultValue = "False"),
@Param(
name = "sandbox_for_pregenerating_oat_files_for_tests",
@@ -64,13 +63,11 @@
@ParamType(type = NoneType.class),
@ParamType(type = FilesToRunProviderApi.class),
},
- noneable = true,
defaultValue = "None"),
@Param(
name = "framework",
positional = false,
named = true,
- noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = FileApi.class),
@@ -80,7 +77,6 @@
name = "dalvik_cache",
positional = false,
named = true,
- noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = FileApi.class),
@@ -90,7 +86,6 @@
name = "device_props",
positional = false,
named = true,
- noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = FileApi.class),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidFeatureFlagSetProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidFeatureFlagSetProviderApi.java
index f061fff..f9bd33b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidFeatureFlagSetProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidFeatureFlagSetProviderApi.java
@@ -60,12 +60,7 @@
doc = "The <code>AndroidFeatureFlagSetProvider</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "flags",
- doc = "Map of flags",
- positional = true,
- named = false,
- type = Dict.class),
+ @Param(name = "flags", doc = "Map of flags", positional = true, named = false),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdeInfoProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdeInfoProviderApi.java
index 0acaef0..0d3a3a9 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdeInfoProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdeInfoProviderApi.java
@@ -23,10 +23,12 @@
import com.google.devtools.build.lib.starlarkbuildapi.java.OutputJarApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
/**
@@ -191,98 +193,114 @@
doc = "A string of the Java package.",
positional = true,
named = false,
- noneable = true,
- type = String.class),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "manifest",
doc = "An artifact of the Android manifest.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "generated_manifest",
doc = "An artifact of the generated Android manifest.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "idl_import_root",
doc = "A string of the idl import root.",
positional = true,
named = false,
- noneable = true,
- type = String.class),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "idl_srcs",
doc = "A list of artifacts of the idl srcs.",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "idl_generated_java_files",
doc = "A list of artifacts of the idl generated java files.",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "idl_source_jar",
doc = "An artifact of the source Jar with the idl generated java files.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "idl_class_jar",
doc = "An artifact of the class Jar with the compiled idl generated java files.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "defines_android_resources",
doc = "A boolean if target specifies Android resources.",
positional = true,
- named = false,
- type = Boolean.class),
+ named = false),
@Param(
name = "resource_jar",
doc = "An artifact of the Jar containing Android resources.",
positional = true,
named = false,
- noneable = true,
- type = OutputJarApi.class),
+ allowedTypes = {
+ @ParamType(type = OutputJarApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "resource_apk",
doc = "An artifact of the Apk containing Android resources.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "signed_apk",
doc = "An artifact of the signed Apk.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "aar",
doc = "An artifact of the Android archive.",
positional = true,
named = false,
- noneable = true,
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "apks_under_test",
doc = "A list of artifacts of the apks under test",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "native_libs",
doc =
@@ -290,8 +308,7 @@
+ "libs.",
positional = true,
named = false,
- type = Dict.class,
- generic1 = String.class)
+ allowedTypes = {@ParamType(type = Dict.class, generic1 = String.class)})
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdlProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdlProviderApi.java
index 9e82f4f..0f21429 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdlProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidIdlProviderApi.java
@@ -20,6 +20,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -92,15 +93,13 @@
doc = "A depset of strings of all the idl import roots in the transitive closure.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = String.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = String.class)}),
@Param(
name = "transitive_idl_imports",
doc = "A depset of artifacts of all the idl imports in the transitive closure.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_idl_jars",
doc =
@@ -108,8 +107,7 @@
+ "transitive closure.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_idl_preprocessed",
doc =
@@ -117,8 +115,7 @@
+ "closure.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidInstrumentationInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidInstrumentationInfoApi.java
index 1a3ada2..b2a7112 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidInstrumentationInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidInstrumentationInfoApi.java
@@ -62,7 +62,6 @@
parameters = {
@Param(
name = "target",
- type = ApkInfoApi.class,
named = true,
doc = "The target ApkInfo of the instrumentation test.")
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryAarInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryAarInfoApi.java
index ef103a3..cd77bee 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryAarInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryAarInfoApi.java
@@ -68,30 +68,18 @@
doc = "The <code>AndroidLibraryAarInfoApi</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "aar",
- doc = "resource_apk",
- positional = false,
- named = true,
- type = FileApi.class),
- @Param(
- name = "manifest",
- doc = "manifest",
- positional = false,
- named = true,
- type = FileApi.class),
+ @Param(name = "aar", doc = "resource_apk", positional = false, named = true),
+ @Param(name = "manifest", doc = "manifest", positional = false, named = true),
@Param(
name = "aars_from_deps",
doc = "List of AndroidLibraryAarInfo",
positional = false,
- named = true,
- type = Sequence.class),
+ named = true),
@Param(
name = "defines_local_resources",
doc = "defines_local_resources",
positional = false,
- named = true,
- type = Boolean.class),
+ named = true),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryResourceClassJarProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryResourceClassJarProviderApi.java
index 6ad4dce..346f513 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryResourceClassJarProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidLibraryResourceClassJarProviderApi.java
@@ -20,6 +20,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -60,8 +61,7 @@
doc = "Resource class jars.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidManifestInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidManifestInfoApi.java
index b591b94..91c97db 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidManifestInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidManifestInfoApi.java
@@ -66,14 +66,13 @@
doc = "The <code>AndroidManifestInfo</code> constructor.",
documented = false,
parameters = {
- @Param(name = "manifest", positional = true, named = true, type = FileApi.class),
- @Param(name = "package", positional = true, named = true, type = String.class),
+ @Param(name = "manifest", positional = true, named = true),
+ @Param(name = "package", positional = true, named = true),
@Param(
name = "exports_manifest",
positional = true,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
},
selfCall = true)
AndroidManifestInfoApi<FileT> androidManifestInfo(
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidNativeLibsInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidNativeLibsInfoApi.java
index 3926abf..bcfd314 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidNativeLibsInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidNativeLibsInfoApi.java
@@ -19,6 +19,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -61,8 +62,7 @@
parameters = {
@Param(
name = "native_libs",
- type = Depset.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)},
named = true,
doc = "The native libraries produced by the rule."),
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidPreDexJarProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidPreDexJarProviderApi.java
index b23c63d..0bc44d0 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidPreDexJarProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidPreDexJarProviderApi.java
@@ -59,8 +59,7 @@
name = "pre_dex_jar",
doc = "The jar to be dexed.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidProguardInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidProguardInfoApi.java
index c8f1b4d..42d750b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidProguardInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidProguardInfoApi.java
@@ -19,6 +19,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -61,8 +62,7 @@
doc = "A list of local proguard specs.",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = FileApi.class)
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)})
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidResourcesInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidResourcesInfoApi.java
index 3322c8a..6846e15 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidResourcesInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidResourcesInfoApi.java
@@ -21,6 +21,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -128,18 +129,9 @@
doc = "The <code>AndroidResourcesInfo</code> constructor.",
documented = false,
parameters = {
- @Param(
- name = "label",
- doc = "A label of the target.",
- positional = true,
- named = false,
- type = Label.class),
- @Param(
- name = "manifest",
- positional = true,
- named = true,
- type = AndroidManifestInfoApi.class),
- @Param(name = "r_txt", positional = true, named = true, type = FileApi.class),
+ @Param(name = "label", doc = "A label of the target.", positional = true, named = false),
+ @Param(name = "manifest", positional = true, named = true),
+ @Param(name = "r_txt", positional = true, named = true),
@Param(
name = "transitive_android_resources",
doc =
@@ -147,43 +139,41 @@
+ "closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = ValidatedAndroidDataApi.class),
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = ValidatedAndroidDataApi.class)
+ }),
@Param(
name = "direct_android_resources",
doc = "A depset of ValidatedAndroidData of Android Resources for the target.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = ValidatedAndroidDataApi.class),
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = ValidatedAndroidDataApi.class)
+ }),
@Param(
name = "transitive_resources",
doc = "A depset of Artifacts of Android Resource files in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_manifests",
doc = "A depset of Artifacts of Android Manifests in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_aapt2_r_txt",
doc = "A depset of Artifacts of Android AAPT2 R.txt files in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_symbols_bin",
doc = "A depset of Artifacts of Android symbols files in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
name = "transitive_compiled_symbols",
doc =
@@ -191,25 +181,22 @@
+ "closure.",
positional = true,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
@Param(
// TODO(b/119560471): remove.
name = "transitive_static_lib",
doc = "A depset of Artifacts of static lib files in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- defaultValue = "unbound",
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)},
+ defaultValue = "unbound"),
@Param(
name = "transitive_r_txt",
doc = "A depset of Artifacts of Android AAPT R.txt files in the transitive closure.",
positional = true,
named = true,
- type = Depset.class,
- defaultValue = "unbound", // needed to allow removing any earlier parameters.
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)},
+ defaultValue = "unbound"), // needed to allow removing any earlier parameters.
// TODO(b/132383435): remove this
@Param(
name = "validation_artifacts",
@@ -217,8 +204,7 @@
doc = "A depset of opaque files to trigger resource validation.",
positional = false,
named = true,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidSdkProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidSdkProviderApi.java
index ce9859b..bd96b40 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidSdkProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidSdkProviderApi.java
@@ -21,10 +21,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.TransitiveInfoCollectionApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
-import net.starlark.java.eval.StarlarkValue;
+import net.starlark.java.eval.NoneType;
/**
* Configured targets implementing this provider can contribute Android Sdk information to the
@@ -142,124 +143,114 @@
name = "build_tools_version",
doc = "A string of the build tools version.",
positional = true,
- named = false,
- type = String.class),
+ named = false),
@Param(
name = "framework_aidl",
doc = "An artifact of the AIDL framework.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "aidl_lib",
doc = "A transitive info collection of the AIDL lib.",
positional = true,
named = false,
- type = TransitiveInfoCollectionApi.class,
- noneable = true),
+ allowedTypes = {
+ @ParamType(type = TransitiveInfoCollectionApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "android_jar",
doc = "An artifact of the Android Jar.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "sourceProperties",
doc = "An artifact of the AIDL lib.",
positional = true,
named = false,
- type = FileApi.class,
- noneable = true),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "shrinked_android_jar",
doc = "An artifact of the shrunk Android Jar.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "main_dex_classes",
doc = "An artifact of the main dex classes.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "adb",
doc = "A files to run provider of ADB.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "dx",
doc = "A files to run provider of Dx.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "main_dex_list_creator",
doc = "A files to run provider of the main dex list creator.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "aidl",
doc = "A files to run provider of AIDL.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "aapt",
doc = "A files to run provider of AAPT.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "aapt2",
doc = "A files to run provider of AAPT2.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "apk_builder",
doc = "A files to run provider of the Apk builder.",
positional = true,
named = false,
- type = FilesToRunProviderApi.class,
- noneable = true),
+ allowedTypes = {
+ @ParamType(type = FilesToRunProviderApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "apk_signer",
doc = "A files to run provider of the Apk signer.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "proguard",
doc = "A files to run provider of Proguard.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "zipalign",
doc = "A files to run provider of Zipalign.",
positional = true,
- named = false,
- type = FilesToRunProviderApi.class),
+ named = false),
@Param(
name = "system",
doc = "",
- noneable = true,
defaultValue = "None",
positional = true,
- named = false,
- type = StarlarkValue.class),
+ named = false),
},
selfCall = true)
@StarlarkConstructor
AndroidSdkProviderApi<FileT, FilesToRunProviderT, TransT> createInfo(
String buildToolsVersion,
FileT frameworkAidl,
- /*noneable*/ Object aidlLib,
+ Object aidlLib,
FileT androidJar,
- /*noneable*/ Object sourceProperties,
+ Object sourceProperties,
FileT shrinkedAndroidJar,
FileT mainDexClasses,
FilesToRunProviderT adb,
@@ -268,11 +259,11 @@
FilesToRunProviderT aidl,
FilesToRunProviderT aapt,
FilesToRunProviderT aapt2,
- /*noneable*/ Object apkBuilder,
+ Object apkBuilder,
FilesToRunProviderT apkSigner,
FilesToRunProviderT proguard,
FilesToRunProviderT zipalign,
- /*noneable*/ Object system)
+ Object system)
throws EvalException;
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
index e6fa3de..ac44ba3 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
@@ -35,7 +35,7 @@
@StarlarkMethod(
name = "create_device_broker_info",
documented = false,
- parameters = {@Param(name = "type", type = String.class)})
+ parameters = {@Param(name = "type")})
AndroidDeviceBrokerInfoApi createDeviceBrokerInfo(String deviceBrokerType);
@StarlarkMethod(
@@ -52,8 +52,7 @@
name = "resource",
doc = "The android resource file.",
positional = true,
- named = false,
- type = FileApi.class)
+ named = false)
})
String getSourceDirectoryRelativePathFromResource(FileT resource);
@@ -78,8 +77,7 @@
"A JavaInfo that will be used as an implicit export for sourceless deps exports"
+ " compatibility.",
positional = true,
- named = false,
- type = JavaInfoApi.class)
+ named = false)
})
JavaInfoT enableImplicitSourcelessDepsExportsCompatibility(JavaInfoT javaInfo);
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/DataBindingV2ProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/DataBindingV2ProviderApi.java
index bb63fa3..0d26d7f 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/DataBindingV2ProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/DataBindingV2ProviderApi.java
@@ -21,9 +21,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkValue;
@@ -135,57 +137,69 @@
doc = "The setter_stores.bin files .",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "class_info_file",
doc = "The class_info files for this rule.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "br_file",
doc = "The br file for this rule.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "label",
doc = "The label of the current rule.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = String.class),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "java_package",
doc = "The java package of the current rule.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = String.class),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "databinding_v2_providers_in_deps",
doc = "The DatabindingV2Provider instances from dependencies.",
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = DataBindingV2ProviderApi.class),
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = DataBindingV2ProviderApi.class)
+ }),
@Param(
name = "databinding_v2_providers_in_exports",
doc = "The DatabindingV2Provider instances from exports.",
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
- generic1 = DataBindingV2ProviderApi.class),
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = DataBindingV2ProviderApi.class)
+ }),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/ProguardMappingProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/ProguardMappingProviderApi.java
index cd5cd99..e5135a1 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/ProguardMappingProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/ProguardMappingProviderApi.java
@@ -58,8 +58,7 @@
name = "proguard_mapping",
doc = "An artifact of the proguard mapping.",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/UsesDataBindingProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/UsesDataBindingProviderApi.java
index c40c4db..b49d2b0 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/UsesDataBindingProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/UsesDataBindingProviderApi.java
@@ -19,6 +19,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -65,8 +66,7 @@
doc = "A list of artifacts of the metadata outputs.",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleCommonApi.java
index 2245b13..024fd12 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleCommonApi.java
@@ -25,10 +25,12 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import com.google.devtools.build.lib.starlarkbuildapi.platform.ConstraintValueInfoApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkInt;
import net.starlark.java.eval.StarlarkThread;
@@ -207,7 +209,6 @@
name = "xcode_config",
positional = true,
named = false,
- type = XcodeConfigInfoApi.class,
doc = "A provider containing information about the xcode configuration."),
})
ImmutableMap<String, String> getAppleHostSystemEnv(XcodeConfigInfoApiT xcodeConfig);
@@ -224,13 +225,11 @@
name = "xcode_config",
positional = true,
named = false,
- type = XcodeConfigInfoApi.class,
doc = "A provider containing information about the xcode configuration."),
@Param(
name = "platform",
positional = true,
named = false,
- type = ApplePlatformApi.class,
doc = "The apple platform."),
})
ImmutableMap<String, String> getTargetAppleEnvironment(
@@ -263,7 +262,6 @@
parameters = {
@Param(
name = "uses_swift",
- type = Boolean.class,
defaultValue = "False",
named = true,
positional = false,
@@ -272,7 +270,6 @@
extraKeywords =
@Param(
name = "kwargs",
- type = Dict.class,
defaultValue = "{}",
doc = "Dictionary of arguments."),
useStarlarkThread = true)
@@ -286,15 +283,16 @@
parameters = {
@Param(
name = "binary",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc = "The dylib binary artifact of the dynamic framework."),
@Param(
name = "objc",
- type = ObjcProviderApi.class,
named = true,
positional = false,
doc =
@@ -302,10 +300,11 @@
+ "dependencies linked into the binary."),
@Param(
name = "framework_dirs",
- type = Depset.class,
- generic1 = String.class,
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc =
@@ -313,10 +312,11 @@
+ "framework."),
@Param(
name = "framework_files",
- type = Depset.class,
- generic1 = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc =
@@ -340,31 +340,23 @@
+ "<p>This API is <b>highly experimental</b> and subject to change at any time. Do "
+ "not depend on the stability of this function at this time.",
parameters = {
- @Param(
- name = "ctx",
- type = StarlarkRuleContextApi.class,
- named = true,
- positional = false,
- doc = "The Starlark rule context."),
+ @Param(name = "ctx", named = true, positional = false, doc = "The Starlark rule context."),
@Param(
name = "extra_linkopts",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
doc = "Extra linkopts to be passed to the linker action."),
@Param(
name = "extra_link_inputs",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
named = true,
positional = false,
defaultValue = "[]",
doc = "Extra files to pass to the linker action."),
@Param(
name = "stamp",
- type = StarlarkInt.class,
named = true,
positional = false,
defaultValue = "-1",
@@ -389,10 +381,7 @@
name = "dotted_version",
doc = "Creates a new <a href=\"DottedVersion.html\">DottedVersion</a> instance.",
parameters = {
- @Param(
- name = "version",
- type = String.class,
- doc = "The string representation of the DottedVersion.")
+ @Param(name = "version", doc = "The string representation of the DottedVersion.")
})
DottedVersionApi<?> dottedVersion(String version) throws EvalException;
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleConfigurationApi.java
index 64b2300..7c7c072 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleConfigurationApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleConfigurationApi.java
@@ -65,7 +65,6 @@
name = "platform_type",
positional = true,
named = false,
- type = ApplePlatformTypeApi.class,
doc = "The apple platform type.")
})
ApplePlatformApi getMultiArchPlatform(ApplePlatformTypeApiT platformType);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleStaticLibraryInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleStaticLibraryInfoApi.java
index e039616..463ea256 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleStaticLibraryInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleStaticLibraryInfoApi.java
@@ -64,13 +64,11 @@
parameters = {
@Param(
name = "archive",
- type = FileApi.class,
named = true,
positional = false,
doc = "Multi-architecture archive (.a) representing a static library"),
@Param(
name = "objc",
- type = ObjcProviderApi.class,
named = true,
positional = false,
doc =
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleToolchainApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleToolchainApi.java
index c60aba5..318f3e0 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleToolchainApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/AppleToolchainApi.java
@@ -44,7 +44,6 @@
name = "configuration",
positional = true,
named = false,
- type = AppleConfigurationApi.class,
doc = "The apple configuration fragment.")
})
String platformFrameworkDirFromConfig(AppleConfigurationApiT configuration);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/DottedVersionApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/DottedVersionApi.java
index b8a35db..27449d3 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/DottedVersionApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/DottedVersionApi.java
@@ -39,12 +39,7 @@
"Compares based on most signifigant (first) not-matching version component. "
+ "So, for example, 1.2.3 < 1.2.4",
parameters = {
- @Param(
- name = "other",
- positional = true,
- named = false,
- type = DottedVersionApi.class,
- doc = "The other dotted version.")
+ @Param(name = "other", positional = true, named = false, doc = "The other dotted version.")
})
int compareTo_starlark(SelfT other);
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcConfigurationApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcConfigurationApi.java
index 646cd80..93a9222 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcConfigurationApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/ObjcConfigurationApi.java
@@ -53,7 +53,6 @@
name = "platform_type",
positional = true,
named = false,
- type = ApplePlatformTypeApi.class,
doc = "The apple platform type."),
})
String getSimulatorDeviceForPlatformType(ApplePlatformTypeApiT platformType);
@@ -67,7 +66,6 @@
name = "platform_type",
positional = true,
named = false,
- type = ApplePlatformTypeApi.class,
doc = "The apple platform type."),
})
DottedVersionApi<?> getSimulatorVersionForPlatformType(ApplePlatformTypeApiT platformType);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java
index 822bfc8..546fe0e 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/apple/XcodeConfigInfoApi.java
@@ -55,7 +55,6 @@
name = "platform_type",
positional = true,
named = false,
- type = ApplePlatformTypeApi.class,
doc = "The apple platform type."),
})
DottedVersionApi<?> getMinimumOsForPlatformType(ApplePlatformTypeApiT platformType);
@@ -66,12 +65,7 @@
"The version of the platform SDK that will be used to build targets for the given "
+ "platform.",
parameters = {
- @Param(
- name = "platform",
- positional = true,
- named = false,
- type = ApplePlatformApi.class,
- doc = "The apple platform."),
+ @Param(name = "platform", positional = true, named = false, doc = "The apple platform."),
})
DottedVersionApi<?> getSdkVersionForPlatform(ApplePlatformApiT platform);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigFeatureFlagProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigFeatureFlagProviderApi.java
index 1919101..b5ffb81 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigFeatureFlagProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigFeatureFlagProviderApi.java
@@ -37,10 +37,7 @@
name = "is_valid_value",
doc = "The value of the flag in the configuration used by the flag rule.",
parameters = {
- @Param(
- name = "value",
- type = String.class,
- doc = "String, the value to check for validity for this flag."),
+ @Param(name = "value", doc = "String, the value to check for validity for this flag."),
})
boolean isValidValue(String value);
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigGlobalLibraryApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigGlobalLibraryApi.java
index ecd1820..d230eb9 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigGlobalLibraryApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/config/ConfigGlobalLibraryApi.java
@@ -17,6 +17,7 @@
import com.google.devtools.build.docgen.annot.DocumentMethods;
import com.google.devtools.build.docgen.annot.StarlarkConstructor;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
@@ -51,7 +52,6 @@
parameters = {
@Param(
name = "implementation",
- type = StarlarkCallable.class,
positional = false,
named = true,
// TODO(cparsons): The settings dict should take actual Label objects as keys and not
@@ -76,8 +76,7 @@
+ "split transition."),
@Param(
name = "inputs",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
positional = false,
named = true,
doc =
@@ -86,8 +85,7 @@
+ "parameter."),
@Param(
name = "outputs",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
positional = false,
named = true,
doc =
@@ -119,7 +117,6 @@
parameters = {
@Param(
name = "settings",
- type = Dict.class,
positional = false,
named = true,
doc =
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/core/StructApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/core/StructApi.java
index bbc43be..29e529e 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/core/StructApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/core/StructApi.java
@@ -97,11 +97,7 @@
+ "<pre class=\"language-python\">s = struct(x = 2, y = 3)\n"
+ "return s.x + getattr(s, \"y\") # returns 5</pre>",
extraKeywords =
- @Param(
- name = "kwargs",
- type = Dict.class,
- defaultValue = "{}",
- doc = "Dictionary of arguments."),
+ @Param(name = "kwargs", defaultValue = "{}", doc = "Dictionary of arguments."),
useStarlarkThread = true,
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/BazelCcModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/BazelCcModuleApi.java
index cab2f1d..c62e5e3 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/BazelCcModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/BazelCcModuleApi.java
@@ -73,7 +73,6 @@
parameters = {
@Param(
name = "actions",
- type = StarlarkActionFactoryApi.class,
positional = false,
named = true,
doc = "<code>actions</code> object."),
@@ -81,21 +80,18 @@
name = "feature_configuration",
doc = "<code>feature_configuration</code> to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "cc_toolchain",
doc = "<code>CcToolchainInfo</code> provider to be used.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "srcs",
doc = "The list of source files to be compiled.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "public_hdrs",
doc =
@@ -103,8 +99,7 @@
+ "rules transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "private_hdrs",
doc =
@@ -112,8 +107,7 @@
+ " dependent rules.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "includes",
doc =
@@ -121,8 +115,7 @@
+ "Usually passed with -I. Propagated to dependents transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "quote_includes",
doc =
@@ -132,8 +125,7 @@
+ "transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "system_includes",
doc =
@@ -143,8 +135,7 @@
+ "transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "framework_includes",
doc =
@@ -153,8 +144,7 @@
+ "dependents transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "defines",
doc =
@@ -162,8 +152,7 @@
+ " to dependents transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "local_defines",
doc =
@@ -171,8 +160,7 @@
+ " propagated to dependents transitively.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "include_prefix",
doc =
@@ -183,8 +171,7 @@
+ "prefix is added.",
positional = false,
named = true,
- defaultValue = "''",
- type = String.class),
+ defaultValue = "''"),
@Param(
name = "strip_include_prefix",
doc =
@@ -196,51 +183,44 @@
+ " added after this prefix is stripped.",
positional = false,
named = true,
- defaultValue = "''",
- type = String.class),
+ defaultValue = "''"),
@Param(
name = "user_compile_flags",
doc = "Additional list of compilation options.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "compilation_contexts",
doc = "Headers from dependencies used for compilation.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "name",
doc =
"This is used for naming the output artifacts of actions created by this "
+ "method.",
positional = false,
- named = true,
- type = String.class),
+ named = true),
@Param(
name = "disallow_pic_outputs",
doc = "Whether PIC outputs should be created.",
positional = false,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
@Param(
name = "disallow_nopic_outputs",
doc = "Whether NOPIC outputs should be created.",
positional = false,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
@Param(
name = "additional_inputs",
doc = "List of additional files needed for compilation of srcs",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
})
Tuple<Object> compile(
StarlarkActionFactoryT starlarkActionFactoryApi,
@@ -273,7 +253,6 @@
parameters = {
@Param(
name = "actions",
- type = StarlarkActionFactoryApi.class,
positional = false,
named = true,
doc = "<code>actions</code> object."),
@@ -281,21 +260,18 @@
name = "feature_configuration",
doc = "<code>feature_configuration</code> to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "cc_toolchain",
doc = "<code>CcToolchainInfo</code> provider to be used.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "compilation_outputs",
doc = "Compilation outputs containing object files to link.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {
@ParamType(type = CcCompilationOutputsApi.class),
@ParamType(type = NoneType.class)
@@ -305,8 +281,7 @@
doc = "Additional list of linker options.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "linking_contexts",
doc =
@@ -314,37 +289,32 @@
+ "generated by this rule.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "name",
doc =
"This is used for naming the output artifacts of actions created by this "
+ "method.",
positional = false,
- named = true,
- type = String.class),
+ named = true),
@Param(
name = "language",
doc = "Only C++ supported for now. Do not use this parameter.",
positional = false,
named = true,
- defaultValue = "'c++'",
- type = String.class),
+ defaultValue = "'c++'"),
@Param(
name = "output_type",
doc = "Can be either 'executable' or 'dynamic_library'.",
positional = false,
named = true,
- defaultValue = "'executable'",
- type = String.class),
+ defaultValue = "'executable'"),
@Param(
name = "link_deps_statically",
doc = " True to link dependencies statically, False dynamically.",
positional = false,
named = true,
- defaultValue = "True",
- type = Boolean.class),
+ defaultValue = "True"),
@Param(
name = "stamp",
doc =
@@ -355,22 +325,22 @@
+ "unset (or set to 0) when generating the executable output for test rules.",
positional = false,
named = true,
- defaultValue = "0",
- type = StarlarkInt.class),
+ defaultValue = "0"),
@Param(
name = "additional_inputs",
doc = "For additional inputs to the linking action, e.g.: linking scripts.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "grep_includes",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- allowedTypes = {@ParamType(type = FileApi.class), @ParamType(type = NoneType.class)}),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
})
LinkingOutputsT link(
StarlarkActionFactoryT starlarkActionFactoryApi,
@@ -398,17 +368,21 @@
doc = "List of object files.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- allowedTypes = {@ParamType(type = Depset.class), @ParamType(type = NoneType.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "pic_objects",
doc = "List of pic object files.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- allowedTypes = {@ParamType(type = Depset.class), @ParamType(type = NoneType.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
})
CompilationOutputsT createCompilationOutputsFromStarlark(
Object objectsObject, Object picObjectsObject) throws EvalException;
@@ -417,12 +391,7 @@
name = "merge_compilation_outputs",
doc = "Merge compilation outputs.",
parameters = {
- @Param(
- name = "compilation_outputs",
- positional = false,
- named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ @Param(name = "compilation_outputs", positional = false, named = true, defaultValue = "[]"),
})
CompilationOutputsT mergeCcCompilationOutputsFromStarlark(
Sequence<?> compilationOutputs) // <CompilationOutputsT> expected
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcInfoApi.java
index 074b7e0..f08e5fb 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcInfoApi.java
@@ -68,7 +68,6 @@
doc = "The <code>CompilationContext</code>.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = CcCompilationContextApi.class),
@@ -79,7 +78,6 @@
doc = "The <code>LinkingContext</code>.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = CcLinkingContextApi.class),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcModuleApi.java
index 9cd50a8..4c85d0c 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcModuleApi.java
@@ -80,30 +80,29 @@
name = "ctx",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = StarlarkRuleContextApi.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkRuleContextApi.class),
+ @ParamType(type = NoneType.class),
+ },
doc = "The rule context."),
@Param(
name = "cc_toolchain",
doc = "cc_toolchain for which we configure features.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "requested_features",
doc = "List of features to be enabled.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "unsupported_features",
doc = "List of features that are unsupported by the current rule.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
})
FeatureConfigurationT configureFeatures(
Object ruleContextOrNone,
@@ -120,8 +119,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "action_name",
doc =
@@ -142,8 +140,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "action_name",
doc =
@@ -165,8 +162,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "feature_name",
doc = "Name of the feature.",
@@ -183,8 +179,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "action_name",
doc = "Name of the action_config.",
@@ -205,8 +200,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "action_name",
doc =
@@ -220,8 +214,7 @@
name = "variables",
doc = "Build variables to be used for template expansions.",
named = true,
- positional = false,
- type = CcToolchainVariablesApi.class),
+ positional = false),
})
Sequence<String> getCommandLine(
FeatureConfigurationT featureConfiguration,
@@ -237,8 +230,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "action_name",
doc =
@@ -252,8 +244,7 @@
name = "variables",
doc = "Build variables to be used for template expansion.",
positional = false,
- named = true,
- type = CcToolchainVariablesApi.class),
+ named = true),
})
Dict<String, String> getEnvironmentVariable(
FeatureConfigurationT featureConfiguration,
@@ -269,14 +260,12 @@
name = "cc_toolchain",
doc = "cc_toolchain for which we are creating build variables.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "source_file",
doc =
@@ -286,8 +275,7 @@
+ "the toolchain author to properly specify and position compiler flags.",
named = true,
positional = false,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
@Param(
name = "output_file",
doc =
@@ -297,18 +285,16 @@
+ "the toolchain author to properly specify and position compiler flags.",
named = true,
positional = false,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
@Param(
name = "user_compile_flags",
doc = "List of additional compilation flags (copts).",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
@ParamType(type = NoneType.class),
- @ParamType(type = Sequence.class),
}),
@Param(
name = "include_directories",
@@ -316,64 +302,80 @@
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "quote_include_directories",
doc = "Depset of quote include directories.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "system_include_directories",
doc = "Depset of system include directories.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "framework_include_directories",
doc = "Depset of framework include directories.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "preprocessor_defines",
doc = "Depset of preprocessor defines.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "thinlto_index",
doc = "LTO index file path.",
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = String.class)}),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "thinlto_input_bitcode_file",
doc = "Bitcode file that is input to LTO backend.",
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = String.class)}),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "thinlto_output_object_file",
doc = "Object file that is output by LTO backend.",
named = true,
positional = false,
defaultValue = "None",
- noneable = true,
- allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = String.class)}),
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "use_pic",
doc = "When true the compilation will generate position independent code.",
@@ -414,21 +416,18 @@
name = "cc_toolchain",
doc = "cc_toolchain for which we are creating build variables.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "library_search_directories",
doc = "Depset of directories where linker will look for libraries at link time.",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "runtime_library_search_directories",
@@ -436,7 +435,6 @@
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
name = "user_link_flags",
@@ -444,29 +442,25 @@
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@Param(
name = "output_file",
doc = "Optional output file path.",
named = true,
positional = false,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
@Param(
name = "param_file",
doc = "Optional param file path.",
named = true,
positional = false,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
@Param(
name = "def_file",
doc = "Optional .def file path.",
named = true,
positional = false,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
// TODO(b/65151735): Remove once we migrate crosstools to features
@Param(
name = "is_using_linker",
@@ -537,7 +531,6 @@
parameters = {
@Param(
name = "actions",
- type = StarlarkActionFactoryApi.class,
positional = false,
named = true,
doc = "<code>actions</code> object."),
@@ -545,30 +538,32 @@
name = "feature_configuration",
doc = "<code>feature_configuration</code> to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "cc_toolchain",
doc = "<code>CcToolchainInfo</code> provider to be used.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "static_library",
doc = "<code>File</code> of static library to be linked.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "pic_static_library",
doc = "<code>File</code> of pic static library to be linked.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "dynamic_library",
doc =
@@ -576,33 +571,35 @@
+ "and used for linking if <code>interface_library</code> is not passed.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "interface_library",
doc = "<code>File</code> of interface library to be linked.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
- type = FileApi.class),
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ }),
@Param(
name = "pic_objects",
doc = "Experimental, do not use",
positional = false,
named = true,
defaultValue = "unbound",
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "objects",
doc = "Experimental, do not use",
positional = false,
named = true,
defaultValue = "unbound",
- type = Sequence.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)}),
@Param(
name = "alwayslink",
doc = "Whether to link the static library/objects in the --whole_archive block.",
@@ -616,7 +613,9 @@
+ "Empty string to use the default.",
positional = false,
named = true,
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ },
defaultValue = "''"),
@Param(
name = "interface_library_symlink_path",
@@ -625,7 +624,6 @@
+ "Empty string to use the default.",
positional = false,
named = true,
- type = String.class,
defaultValue = "''"),
})
LibraryToLinkT createLibraryLinkerInput(
@@ -653,14 +651,12 @@
name = "owner",
doc = "The label of the target that produced all files used in this input.",
positional = false,
- named = true,
- type = Label.class),
+ named = true),
@Param(
name = "libraries",
doc = "List of <code>LibraryToLink</code>.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
@@ -668,7 +664,6 @@
doc = "List of user link flags passed as strings.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
@@ -676,7 +671,6 @@
doc = "For additional inputs to the linking action, e.g.: linking scripts.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
})
@@ -702,7 +696,6 @@
parameters = {
@Param(
name = "actions",
- type = StarlarkActionFactoryApi.class,
positional = false,
named = true,
doc = "<code>actions</code> object."),
@@ -720,7 +713,6 @@
doc = "Depset of <code>LinkerInput</code>.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Depset.class)}),
@Param(
@@ -729,7 +721,6 @@
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
- noneable = true,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@@ -739,7 +730,6 @@
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
- noneable = true,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@@ -749,7 +739,6 @@
positional = false,
named = true,
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_REQUIRE_LINKER_INPUT_CC_API,
- noneable = true,
defaultValue = "None",
valueWhenDisabled = "None",
allowedTypes = {@ParamType(type = NoneType.class), @ParamType(type = Sequence.class)}),
@@ -773,8 +762,7 @@
+ "the direct fields in the returned provider.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "cc_infos",
doc =
@@ -782,8 +770,7 @@
+ "by the direct fields in the returned provider.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class)
+ defaultValue = "[]")
})
CcInfoApi<FileT> mergeCcInfos(
Sequence<?> directCcInfos, // <CcInfoApi> expected
@@ -799,8 +786,7 @@
doc = "Set of headers needed to compile this target",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "system_includes",
doc =
@@ -809,8 +795,7 @@
+ "root or absolute. Usually passed with -isystem",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "includes",
doc =
@@ -818,8 +803,7 @@
+ "Usually passed with -I",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "quote_includes",
doc =
@@ -828,15 +812,13 @@
+ "root or absolute. Usually passed with -iquote",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "framework_includes",
doc = "Set of framework search paths for header files (Apple platform only)",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "defines",
doc =
@@ -844,8 +826,7 @@
+ " transitively to dependents.",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
@Param(
name = "local_defines",
doc =
@@ -853,8 +834,7 @@
+ " propagated transitively to dependents.",
positional = false,
named = true,
- defaultValue = "unbound",
- type = Object.class),
+ defaultValue = "unbound"),
})
CompilationContextT createCcCompilationContext(
Object headers,
@@ -876,8 +856,7 @@
name = "cc_toolchain",
doc = "C++ toolchain provider to be used.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class)
+ named = true)
})
String legacyCcFlagsMakeVariable(CcToolchainProviderT ccToolchain);
@@ -889,7 +868,6 @@
name = "ctx",
positional = false,
named = true,
- type = StarlarkRuleContextApi.class,
doc = "The rule context."),
},
doc = "Returns true if the --incompatible_enable_cc_toolchain_resolution flag is enabled.")
@@ -903,14 +881,12 @@
name = "ctx",
positional = false,
named = true,
- type = StarlarkRuleContextApi.class,
doc = "The rule context."),
@Param(
name = "features",
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L336\">features</a>."),
@@ -919,7 +895,6 @@
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L461\">action_configs</a>."),
@@ -928,7 +903,6 @@
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L516\">artifact_name_patterns</a>."),
@@ -937,7 +911,6 @@
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"<p>Built-in include directories for C++ compilation. These should be the exact "
+ "paths used by the compiler, and are generally relative to the exec root.</p>"
@@ -952,7 +925,6 @@
@Param(
name = "toolchain_identifier",
positional = false,
- type = String.class,
named = true,
doc =
"<p>The unique identifier of the toolchain within the crosstool release. It must "
@@ -961,43 +933,36 @@
@Param(
name = "host_system_name",
positional = false,
- type = String.class,
named = true,
doc = "The system name which is required by the toolchain to run."),
@Param(
name = "target_system_name",
positional = false,
- type = String.class,
named = true,
doc = "The GNU System Name."),
@Param(
name = "target_cpu",
positional = false,
- type = String.class,
named = true,
doc = "The target architecture string."),
@Param(
name = "target_libc",
positional = false,
- type = String.class,
named = true,
doc = "The libc version string (e.g. \"glibc-2.2.2\")."),
@Param(
name = "compiler",
positional = false,
- type = String.class,
named = true,
doc = "The compiler version string (e.g. \"gcc-4.1.1\")."),
@Param(
name = "abi_version",
positional = false,
- type = String.class,
named = true,
doc = "The abi in use, which is a gcc version. E.g.: \"gcc-3.4\""),
@Param(
name = "abi_libc_version",
positional = false,
- type = String.class,
named = true,
doc = "The glibc version used by the abi we're using."),
@Param(
@@ -1005,7 +970,6 @@
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L400\">tool_paths</a>."),
@@ -1014,14 +978,12 @@
positional = false,
named = true,
defaultValue = "[]",
- type = Sequence.class,
doc =
"A list of <a href=\"https://github.com/bazelbuild/bazel/blob/master/tools/cpp/"
+ "cc_toolchain_config_lib.bzl#L86\">make_variables</a>."),
@Param(
name = "builtin_sysroot",
positional = false,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
named = true,
@@ -1031,7 +993,6 @@
@Param(
name = "cc_target_os",
positional = false,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)},
named = true,
@@ -1068,7 +1029,6 @@
parameters = {
@Param(
name = "actions",
- type = StarlarkActionFactoryApi.class,
positional = false,
named = true,
doc = "<code>actions</code> object."),
@@ -1076,27 +1036,23 @@
name = "feature_configuration",
doc = "<code>feature_configuration</code> to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
+ named = true),
@Param(
name = "cc_toolchain",
doc = "<code>CcToolchainInfo</code> provider to be used.",
positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ named = true),
@Param(
name = "compilation_outputs",
doc = "Compilation outputs containing object files to link.",
positional = false,
- named = true,
- type = CcCompilationOutputsApi.class),
+ named = true),
@Param(
name = "user_link_flags",
doc = "Additional list of linking options.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "linking_contexts",
doc =
@@ -1104,56 +1060,48 @@
+ "artifact of the link() call, be it a binary or a library.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "name",
doc =
"This is used for naming the output artifacts of actions created by this "
+ "method.",
positional = false,
- named = true,
- type = String.class),
+ named = true),
@Param(
name = "language",
doc = "Only C++ supported for now. Do not use this parameter.",
positional = false,
named = true,
- defaultValue = "'c++'",
- type = String.class),
+ defaultValue = "'c++'"),
@Param(
name = "alwayslink",
doc = "Whether this library should always be linked.",
positional = false,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
@Param(
name = "additional_inputs",
doc = "For additional inputs to the linking action, e.g.: linking scripts.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "disallow_static_libraries",
doc = "Whether static libraries should be created.",
positional = false,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
@Param(
name = "disallow_dynamic_library",
doc = "Whether a dynamic library should be created.",
positional = false,
named = true,
- defaultValue = "False",
- type = Boolean.class),
+ defaultValue = "False"),
@Param(
name = "grep_includes",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = FileApi.class), @ParamType(type = NoneType.class)}),
})
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcToolchainProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcToolchainProviderApi.java
index c04747b..680544e 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcToolchainProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/CcToolchainProviderApi.java
@@ -43,8 +43,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class)
+ named = true)
})
boolean usePicForDynamicLibrariesFromStarlark(FeatureConfigurationT featureConfigurationApi);
@@ -75,8 +74,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class)
+ named = true)
})
public Depset getStaticRuntimeLibForStarlark(FeatureConfigurationT featureConfiguration)
throws EvalException;
@@ -94,8 +92,7 @@
name = "feature_configuration",
doc = "Feature configuration to be queried.",
positional = false,
- named = true,
- type = FeatureConfigurationApi.class)
+ named = true)
})
public Depset getDynamicRuntimeLibForStarlark(FeatureConfigurationT featureConfiguration)
throws EvalException;
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/DebugPackageInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/DebugPackageInfoApi.java
index 8612838..f626853 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/DebugPackageInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/DebugPackageInfoApi.java
@@ -75,29 +75,22 @@
name = "target_label",
doc = "The label for the *_binary target",
positional = false,
- named = true,
- noneable = false,
- allowedTypes = {@ParamType(type = Label.class)}),
+ named = true),
@Param(
name = "stripped_file",
doc = "The stripped file (the explicit \".stripped\" target)",
positional = false,
- named = true,
- noneable = false,
- allowedTypes = {@ParamType(type = FileApi.class)}),
+ named = true),
@Param(
name = "unstripped_file",
doc = "The unstripped file (the default executable target).",
positional = false,
- named = true,
- noneable = false,
- allowedTypes = {@ParamType(type = FileApi.class)}),
+ named = true),
@Param(
name = "dwp_file",
doc = "The .dwp file (for fission builds) or null if --fission=no.",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = FileApi.class), @ParamType(type = NoneType.class)})
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoCcLinkParamsInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoCcLinkParamsInfoApi.java
index 572e8a8..d5f6a5e 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoCcLinkParamsInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoCcLinkParamsInfoApi.java
@@ -45,8 +45,7 @@
name = "linking_context",
doc = "The CC linking context.",
positional = false,
- named = true,
- type = CcLinkingContextApi.class),
+ named = true),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoWrapCcHelperApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoWrapCcHelperApi.java
index 53aaf7e..6150d1b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoWrapCcHelperApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/GoWrapCcHelperApi.java
@@ -72,7 +72,7 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
+ @Param(name = "ctx", positional = false, named = true),
})
// TODO(b/113797843): Not written in Starlark because of GoRunfilesProvider.
public RunfilesApi starlarkGetGoRunfiles(StarlarkRuleContextT starlarkRuleContext)
@@ -83,7 +83,7 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "go", positional = false, named = true, type = GoConfigurationApi.class),
+ @Param(name = "go", positional = false, named = true),
})
// TODO(b/113797843): Not written in Starlark because of GoCompilationHelper.
public int getArchIntSize(GoConfigurationT goConfig);
@@ -93,21 +93,20 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "export", positional = false, named = true, type = FileApi.class),
- @Param(name = "pkg", positional = false, named = true, type = FileApi.class),
- @Param(name = "gopkg", positional = false, named = true, type = FileApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "export", positional = false, named = true),
+ @Param(name = "pkg", positional = false, named = true),
+ @Param(name = "gopkg", positional = false, named = true),
@Param(
name = "wrap_context",
positional = false,
named = true,
defaultValue = "None",
- noneable = true,
allowedTypes = {
@ParamType(type = NoneType.class),
@ParamType(type = GoContextInfoApi.class)
}),
- @Param(name = "cc_info", positional = false, named = true, type = CcInfoApi.class),
+ @Param(name = "cc_info", positional = false, named = true),
})
public GoContextInfoT starlarkCollectTransitiveGoContextGopkg(
StarlarkRuleContextT starlarkRuleContext,
@@ -122,8 +121,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "cc_info", positional = false, named = true, type = CcInfoApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_info", positional = false, named = true),
})
// TODO(b/113797843): GoWrapCcInfo is not written in Starlark because several native rules use it.
public GoWrapCcInfoApi<FileT> getGoWrapCcInfo(
@@ -135,12 +134,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "linking_context",
- positional = false,
- named = true,
- type = CcLinkingContextApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "linking_context", positional = false, named = true),
})
public GoCcLinkParamsInfoApi getGoCcLinkParamsProvider(
StarlarkRuleContextT ruleContext, CcLinkingContextT ccLinkingContext)
@@ -151,14 +146,10 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "cc_toolchain",
- positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
- @Param(name = "srcs", positional = false, named = true, type = Sequence.class),
- @Param(name = "deps", positional = false, named = true, type = Sequence.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_toolchain", positional = false, named = true),
+ @Param(name = "srcs", positional = false, named = true),
+ @Param(name = "deps", positional = false, named = true),
})
public Tuple<FileT> createGoCompileActions(
StarlarkRuleContextT starlarkRuleContext,
@@ -172,14 +163,10 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "cc_toolchain",
- positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
- @Param(name = "srcs", positional = false, named = true, type = Sequence.class),
- @Param(name = "deps", positional = false, named = true, type = Sequence.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_toolchain", positional = false, named = true),
+ @Param(name = "srcs", positional = false, named = true),
+ @Param(name = "deps", positional = false, named = true),
})
public Tuple<FileT> createGoCompileActionsGopkg(
StarlarkRuleContextT starlarkRuleContext,
@@ -193,10 +180,10 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "gopkg", positional = false, named = true, type = FileApi.class),
- @Param(name = "export", positional = false, named = true, type = FileApi.class),
- @Param(name = "swig_out_go", positional = false, named = true, type = FileApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "gopkg", positional = false, named = true),
+ @Param(name = "export", positional = false, named = true),
+ @Param(name = "swig_out_go", positional = false, named = true),
})
public GoPackageInfoApi createTransitiveGopackageInfo(
StarlarkRuleContextT starlarkRuleContext, FileT starlarkGopkg, FileT export, FileT swigOutGo);
@@ -206,8 +193,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "gopkg", positional = false, named = true, type = FileApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "gopkg", positional = false, named = true),
})
public Depset /*<FileT>*/ getGopackageFilesForStarlark(
StarlarkRuleContextT starlarkRuleContext, FileT starlarkGopkg);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/PyWrapCcHelperApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/PyWrapCcHelperApi.java
index 05b5a9b..d3b354d 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/PyWrapCcHelperApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/PyWrapCcHelperApi.java
@@ -63,7 +63,7 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
+ @Param(name = "ctx", positional = false, named = true),
})
// TODO(plf): PyExtension is not in Starlark.
public Sequence<String> getPyExtensionLinkopts(StarlarkRuleContextT starlarkRuleContext)
@@ -74,8 +74,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "py_file", positional = false, named = true, type = FileApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "py_file", positional = false, named = true),
})
// TODO(plf): Not written in Starlark because of PyCommon.
public Depset getTransitivePythonSources(StarlarkRuleContextT starlarkRuleContext, FileT pyFile)
@@ -86,8 +86,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "files_to_build", positional = false, named = true, type = Depset.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "files_to_build", positional = false, named = true),
})
// TODO(plf): Not written in Starlark because of PythonRunfilesProvider.
public RunfilesApi getPythonRunfiles(
@@ -99,8 +99,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "cc_info", positional = false, named = true, type = CcInfoApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_info", positional = false, named = true),
})
// TODO(plf): PyWrapCcInfo is not written in Starlark because several native rules use it.
public PyWrapCcInfoApi<FileT> getPyWrapCcInfo(
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/WrapCcHelperApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/WrapCcHelperApi.java
index fe854e8..b6e8986 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/WrapCcHelperApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/cpp/WrapCcHelperApi.java
@@ -52,12 +52,8 @@
documented = false,
doc = "",
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "cc_toolchain",
- positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_toolchain", positional = false, named = true),
})
public FeatureConfigurationT starlarkGetFeatureConfiguration(
starlarkRuleContextT starlarkRuleContext, CcToolchainProviderT ccToolchain)
@@ -67,7 +63,7 @@
name = "collect_transitive_swig_includes",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
+ @Param(name = "ctx", positional = false, named = true),
})
public Depset starlarkCollectTransitiveSwigIncludes(starlarkRuleContextT starlarkRuleContext);
@@ -75,25 +71,13 @@
name = "create_compile_actions",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "feature_configuration",
- positional = false,
- named = true,
- type = FeatureConfigurationApi.class),
- @Param(
- name = "cc_toolchain",
- positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
- @Param(name = "cc_file", positional = false, named = true, type = FileApi.class),
- @Param(name = "header_file", positional = false, named = true, type = FileApi.class),
- @Param(
- name = "dep_compilation_contexts",
- positional = false,
- named = true,
- type = Sequence.class),
- @Param(name = "target_copts", positional = false, named = true, type = Sequence.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "feature_configuration", positional = false, named = true),
+ @Param(name = "cc_toolchain", positional = false, named = true),
+ @Param(name = "cc_file", positional = false, named = true),
+ @Param(name = "header_file", positional = false, named = true),
+ @Param(name = "dep_compilation_contexts", positional = false, named = true),
+ @Param(name = "target_copts", positional = false, named = true),
})
public CompilationInfoT starlarkCreateCompileActions(
starlarkRuleContextT starlarkRuleContext,
@@ -110,7 +94,7 @@
documented = false,
doc = "",
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
+ @Param(name = "ctx", positional = false, named = true),
})
public String starlarkGetMangledTargetName(starlarkRuleContextT starlarkRuleContext)
throws EvalException, InterruptedException;
@@ -120,8 +104,8 @@
doc = "",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(name = "swig_includes", positional = false, named = true, type = Depset.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "swig_includes", positional = false, named = true),
})
// TODO(plf): Not written in Starlark because of PythonRunfilesProvider.
public WrapCcIncludeProviderT getWrapCcIncludeProvider(
@@ -132,50 +116,34 @@
name = "register_swig_action",
documented = false,
parameters = {
- @Param(name = "ctx", positional = false, named = true, type = StarlarkRuleContextApi.class),
- @Param(
- name = "cc_toolchain",
- positional = false,
- named = true,
- type = CcToolchainProviderApi.class),
- @Param(
- name = "feature_configuration",
- positional = false,
- named = true,
- noneable = false,
- type = FeatureConfigurationApi.class),
- @Param(
- name = "wrapper_compilation_context",
- positional = false,
- named = true,
- type = CcCompilationContextApi.class),
- @Param(name = "swig_includes", positional = false, named = true, type = Depset.class),
- @Param(name = "swig_source", positional = false, named = true, type = FileApi.class),
- @Param(name = "sub_parameters", positional = false, named = true, type = Sequence.class),
- @Param(name = "cc_file", positional = false, named = true, type = FileApi.class),
- @Param(name = "header_file", positional = false, named = true, type = FileApi.class),
- @Param(name = "output_files", positional = false, named = true, type = Sequence.class),
+ @Param(name = "ctx", positional = false, named = true),
+ @Param(name = "cc_toolchain", positional = false, named = true),
+ @Param(name = "feature_configuration", positional = false, named = true),
+ @Param(name = "wrapper_compilation_context", positional = false, named = true),
+ @Param(name = "swig_includes", positional = false, named = true),
+ @Param(name = "swig_source", positional = false, named = true),
+ @Param(name = "sub_parameters", positional = false, named = true),
+ @Param(name = "cc_file", positional = false, named = true),
+ @Param(name = "header_file", positional = false, named = true),
+ @Param(name = "output_files", positional = false, named = true),
@Param(
name = "out_dir",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)}),
@Param(
name = "java_dir",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {@ParamType(type = String.class), @ParamType(type = NoneType.class)}),
- @Param(name = "auxiliary_inputs", positional = false, named = true, type = Depset.class),
- @Param(name = "swig_attribute_name", positional = false, named = true, type = String.class),
+ @Param(name = "auxiliary_inputs", positional = false, named = true),
+ @Param(name = "swig_attribute_name", positional = false, named = true),
@Param(
name = "zip_tool",
positional = false,
named = true,
- noneable = true,
defaultValue = "None",
allowedTypes = {
@ParamType(type = FilesToRunProviderApi.class),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/GeneratedExtensionRegistryProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/GeneratedExtensionRegistryProviderApi.java
index e7e85e1..8b56ee2 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/GeneratedExtensionRegistryProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/GeneratedExtensionRegistryProviderApi.java
@@ -21,6 +21,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -62,33 +63,28 @@
name = "generatingRuleLabel",
doc = "Rule label for which this registry was built",
positional = true,
- named = false,
- type = Label.class),
+ named = false),
@Param(
name = "isLite",
doc = "If this registry was generated for lite or full runtime",
positional = true,
- named = false,
- type = Boolean.class),
+ named = false),
@Param(
name = "classJar",
doc = "Class jar generated by the registry",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "srcJar",
doc = "Source jar generated by the registry",
positional = true,
- named = false,
- type = FileApi.class),
+ named = false),
@Param(
name = "inputs",
doc = "Proto jars used to generate the registry",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCcLinkParamsProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCcLinkParamsProviderApi.java
index d190f4c..6fe6329 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCcLinkParamsProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCcLinkParamsProviderApi.java
@@ -66,12 +66,7 @@
documented = true,
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS,
parameters = {
- @Param(
- name = "store",
- doc = "The CcInfo provider.",
- positional = true,
- named = false,
- type = CcInfoApi.class),
+ @Param(name = "store", doc = "The CcInfo provider.", positional = true, named = false),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java
index 5c8aabb..953d25f 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaCommonApi.java
@@ -28,6 +28,7 @@
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
@@ -59,18 +60,12 @@
+ "a provider that represents the results of the compilation and can be added to "
+ "the set of providers emitted by this rule.",
parameters = {
- @Param(
- name = "ctx",
- positional = true,
- named = false,
- type = StarlarkRuleContextApi.class,
- doc = "The rule context."),
+ @Param(name = "ctx", positional = true, named = false, doc = "The rule context."),
@Param(
name = "source_jars",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc =
"A list of the jars to be compiled. At least one of source_jars or source_files"
@@ -79,43 +74,41 @@
name = "source_files",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc =
"A list of the Java source files to be compiled. At least one of source_jars or "
+ "source_files should be specified."),
- @Param(name = "output", positional = false, named = true, type = FileApi.class),
+ @Param(name = "output", positional = false, named = true),
@Param(
name = "output_source_jar",
positional = false,
named = true,
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "The output source jar. Optional. Defaults to `{output_jar}-src.jar` if unset."),
@Param(
name = "javac_opts",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
defaultValue = "[]",
doc = "A list of the desired javac options. Optional."),
@Param(
name = "deps",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
defaultValue = "[]",
doc = "A list of dependencies. Optional."),
@Param(
name = "experimental_local_compile_time_deps",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
defaultValue = "[]",
doc =
"Compile-time dependencies of the compilation that should be omitted from the"
@@ -126,32 +119,28 @@
name = "exports",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
defaultValue = "[]",
doc = "A list of exports. Optional."),
@Param(
name = "plugins",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
defaultValue = "[]",
doc = "A list of plugins. Optional."),
@Param(
name = "exported_plugins",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
defaultValue = "[]",
doc = "A list of exported plugins. Optional."),
@Param(
name = "annotation_processor_additional_inputs",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc =
"A list of inputs that the Java compilation action will take in addition to the "
@@ -160,8 +149,7 @@
name = "annotation_processor_additional_outputs",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc =
"A list of outputs that the Java compilation action will output in addition to "
@@ -171,7 +159,6 @@
defaultValue = "'ERROR'",
positional = false,
named = true,
- type = String.class,
doc =
"A string that specifies how to handle strict deps. Possible values: 'OFF', "
+ "'ERROR', 'WARN' and 'DEFAULT'. For more details see "
@@ -181,17 +168,14 @@
name = "java_toolchain",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaToolchainStarlarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to be used for this compilation. Mandatory."),
@Param(
name = "host_javabase",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaRuntimeInfoApi.class)},
doc =
"Deprecated: You can drop this parameter (host_javabase is provided with "
+ "java_toolchain)",
- noneable = true,
defaultValue = "None",
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_JAVA_COMMON_PARAMETERS,
valueWhenDisabled = "None"),
@@ -199,22 +183,15 @@
name = "sourcepath",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]"),
@Param(
name = "resources",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]"),
- @Param(
- name = "neverlink",
- positional = false,
- named = true,
- type = Boolean.class,
- defaultValue = "False")
+ @Param(name = "neverlink", positional = false, named = true, defaultValue = "False")
},
useStarlarkThread = true)
JavaInfoT createJavaCompileAction(
@@ -249,23 +226,16 @@
+ "<code><a class=\"anchor\" href=\"JavaInfo.html\">"
+ "JavaInfo</a>#compile_jar</code>.",
parameters = {
- @Param(
- name = "actions",
- named = true,
- type = StarlarkActionFactoryApi.class,
- doc = "ctx.actions"),
- @Param(
- name = "jar",
- positional = false,
- named = true,
- type = FileApi.class,
- doc = "The jar to run ijar on."),
+ @Param(name = "actions", named = true, doc = "ctx.actions"),
+ @Param(name = "jar", positional = false, named = true, doc = "The jar to run ijar on."),
@Param(
name = "target_label",
positional = false,
named = true,
- type = Label.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Label.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc =
"A target label to stamp the jar with. Used for <code>add_dep</code> support. "
@@ -275,7 +245,6 @@
name = "java_toolchain",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaToolchainStarlarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to used to find the ijar tool."),
})
FileApi runIjar(
@@ -296,19 +265,16 @@
@Param(
name = "actions",
named = true,
- type = StarlarkActionFactoryApi.class,
doc = "ctx.actions"),
@Param(
name = "jar",
positional = false,
named = true,
- type = FileApi.class,
doc = "The jar to run stamp_jar on."),
@Param(
name = "target_label",
positional = false,
named = true,
- type = Label.class,
doc =
"A target label to stamp the jar with. Used for <code>add_dep</code> support. "
+ "Typically, you would pass <code>ctx.label</code> to stamp the jar "
@@ -317,7 +283,6 @@
name = "java_toolchain",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaToolchainStarlarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to used to find the stamp_jar tool."),
})
FileApi stampJar(
@@ -333,17 +298,15 @@
+ "JavaInfo</a>#source_jar</code></p>."
+ "At least one of parameters output_jar or output_source_jar is required.",
parameters = {
- @Param(
- name = "actions",
- named = true,
- type = StarlarkActionFactoryApi.class,
- doc = "ctx.actions"),
+ @Param(name = "actions", named = true, doc = "ctx.actions"),
@Param(
name = "output_jar",
positional = false,
named = true,
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc =
"Deprecated: The output jar of the rule. Used to name the resulting source jar. "
@@ -355,41 +318,38 @@
name = "output_source_jar",
positional = false,
named = true,
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "The output source jar."),
@Param(
name = "sources",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc = "A list of Java source files to be packed into the source jar."),
@Param(
name = "source_jars",
positional = false,
named = true,
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
defaultValue = "[]",
doc = "A list of source jars to be packed into the source jar."),
@Param(
name = "java_toolchain",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaToolchainStarlarkApiProviderApi.class)},
doc = "A JavaToolchainInfo to used to find the ijar tool."),
@Param(
name = "host_javabase",
positional = false,
named = true,
- allowedTypes = {@ParamType(type = JavaRuntimeInfoApi.class)},
doc =
"Deprecated: You can drop this parameter (host_javabase is provided with "
+ "java_toolchain)",
- noneable = true,
defaultValue = "None",
disableWithFlag = BuildLanguageOptions.INCOMPATIBLE_JAVA_COMMON_PARAMETERS,
valueWhenDisabled = "None"),
@@ -431,8 +391,7 @@
name = "providers",
positional = true,
named = false,
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
doc = "The list of providers to merge."),
})
JavaInfoT mergeJavaProviders(Sequence<?> providers /* <JavaInfoT> expected. */)
@@ -444,12 +403,7 @@
"Returns a new Java provider whose direct-jars part is the union of both the direct and"
+ " indirect jars of the given Java provider.",
parameters = {
- @Param(
- name = "java_info",
- positional = true,
- named = false,
- type = JavaInfoApi.class,
- doc = "The java info."),
+ @Param(name = "java_info", positional = true, named = false, doc = "The java info."),
})
JavaInfoT makeNonStrict(JavaInfoT javaInfo);
@@ -473,12 +427,7 @@
name = "is_java_toolchain_resolution_enabled_do_not_use",
documented = false,
parameters = {
- @Param(
- name = "ctx",
- positional = false,
- named = true,
- type = StarlarkRuleContextApi.class,
- doc = "The rule context."),
+ @Param(name = "ctx", positional = false, named = true, doc = "The rule context."),
},
doc = "Returns true if --incompatible_use_toolchain_resolution_for_java_rules is enabled.")
boolean isJavaToolchainResolutionEnabled(starlarkRuleContextT ruleContext) throws EvalException;
@@ -498,12 +447,10 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to enhance."),
@Param(
name = "constraints",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
@@ -521,7 +468,6 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to get constraints from."),
},
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API)
@@ -539,7 +485,6 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to process.")
},
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API)
@@ -553,44 +498,47 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to enhance."),
@Param(
name = "enabled",
- type = Boolean.class,
named = true,
positional = false,
defaultValue = "False",
doc = "Returns true if the rule uses annotation processing."),
@Param(
name = "processor_classnames",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = String.class)},
named = true,
positional = false,
defaultValue = "[]",
doc = "Class names of annotation processors applied to this rule."),
@Param(
name = "processor_classpath",
- type = Depset.class,
+ allowedTypes = {
+ @ParamType(type = Depset.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc = "Class names of annotation processors applied to this rule."),
@Param(
name = "class_jar",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc = "Jar file that is the result of annotation processing for this rule, or None."),
@Param(
name = "source_jar",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
positional = false,
defaultValue = "None",
doc = "Source archive resulting from annotation processing of this rule, or None."),
@@ -613,7 +561,6 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to query."),
},
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API)
@@ -627,12 +574,10 @@
name = "java_info",
positional = true,
named = false,
- type = JavaInfoApi.class,
doc = "The JavaInfo to clone."),
@Param(
name = "compile_time_jdeps",
- type = Sequence.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = FileApi.class)},
named = true,
positional = false,
defaultValue = "[]",
@@ -647,12 +592,7 @@
name = "java_toolchain_label",
doc = "Returns the toolchain's label.",
parameters = {
- @Param(
- name = "java_toolchain",
- positional = true,
- named = false,
- type = JavaToolchainStarlarkApiProviderApi.class,
- doc = "The toolchain."),
+ @Param(name = "java_toolchain", positional = true, named = false, doc = "The toolchain."),
},
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API)
Label getJavaToolchainLabel(JavaToolchainStarlarkApiProviderApi toolchain) throws EvalException;
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaInfoApi.java
index 83fd013..13ffb25 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaInfoApi.java
@@ -21,9 +21,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
@@ -162,16 +164,17 @@
parameters = {
@Param(
name = "output_jar",
- type = FileApi.class,
named = true,
doc =
"The jar that was created as a result of a compilation "
+ "(e.g. javac, scalac, etc)."),
@Param(
name = "compile_jar",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
doc =
"A jar that is added as the compile-time dependency in lieu of "
@@ -184,9 +187,11 @@
+ "you can simply pass <code>output_jar</code>."),
@Param(
name = "source_jar",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- noneable = true,
defaultValue = "None",
doc =
"The source jar that was used to create the output jar. "
@@ -194,28 +199,24 @@
+ "pack_sources</a></code> to produce this source jar."),
@Param(
name = "neverlink",
- type = Boolean.class,
named = true,
defaultValue = "False",
doc = "If true only use this library for compilation and not at runtime."),
@Param(
name = "deps",
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
named = true,
defaultValue = "[]",
doc = "Compile time dependencies that were used to create the output jar."),
@Param(
name = "runtime_deps",
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
named = true,
defaultValue = "[]",
doc = "Runtime dependencies that are needed for this library."),
@Param(
name = "exports",
- type = Sequence.class,
- generic1 = JavaInfoApi.class,
+ allowedTypes = {@ParamType(type = Sequence.class, generic1 = JavaInfoApi.class)},
named = true,
defaultValue = "[]",
doc =
@@ -224,10 +225,12 @@
+ "master/be/java.html#java_library.exports\">java_library.exports</a>."),
@Param(
name = "jdeps",
- type = FileApi.class,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
defaultValue = "None",
- noneable = true,
doc =
"jdeps information for the rule output (if available). This should be a binary"
+ " proto encoded using the deps.proto protobuf included with Bazel. If"
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaNativeLibraryInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaNativeLibraryInfoApi.java
index 501ad5a..7719fd9 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaNativeLibraryInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaNativeLibraryInfoApi.java
@@ -23,6 +23,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import com.google.devtools.build.lib.starlarkbuildapi.cpp.LibraryToLinkApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -72,8 +73,7 @@
doc = "The transitive set of LibraryToLink providers.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = LibraryToLinkApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = LibraryToLinkApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaProtoCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaProtoCommonApi.java
index f0bf9c7..946d333 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaProtoCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaProtoCommonApi.java
@@ -38,30 +38,11 @@
// This function is experimental for now.
documented = false,
parameters = {
- @Param(
- name = "ctx",
- positional = true,
- named = false,
- type = StarlarkRuleContextApi.class,
- doc = "The rule context."),
- @Param(
- name = "target",
- positional = true,
- named = false,
- type = TransitiveInfoCollectionApi.class,
- doc = "The target."),
- @Param(name = "src_jar", positional = false, named = true, type = FileApi.class),
- @Param(
- name = "proto_toolchain_attr",
- positional = false,
- named = true,
- type = String.class),
- @Param(
- name = "flavour",
- positional = false,
- named = true,
- type = String.class,
- defaultValue = "'java'")
+ @Param(name = "ctx", positional = true, named = false, doc = "The rule context."),
+ @Param(name = "target", positional = true, named = false, doc = "The target."),
+ @Param(name = "src_jar", positional = false, named = true),
+ @Param(name = "proto_toolchain_attr", positional = false, named = true),
+ @Param(name = "flavour", positional = false, named = true, defaultValue = "'java'"),
})
void createProtoCompileAction(
StarlarkRuleContextT starlarkRuleContext,
@@ -82,7 +63,6 @@
name = "target",
positional = true,
named = false,
- type = TransitiveInfoCollectionApi.class,
doc = "The proto_library target."),
})
boolean hasProtoSources(TransitiveInfoCollectionT target);
@@ -92,13 +72,8 @@
// This function is experimental for now.
documented = false,
parameters = {
- @Param(
- name = "ctx",
- positional = true,
- named = false,
- type = StarlarkRuleContextApi.class,
- doc = "The rule context."),
- @Param(name = "proto_toolchain_attr", positional = false, named = true, type = String.class)
+ @Param(name = "ctx", positional = true, named = false, doc = "The rule context."),
+ @Param(name = "proto_toolchain_attr", positional = false, named = true)
})
JavaInfoApi<FileT> getRuntimeToolchainProvider(
StarlarkRuleContextT starlarkRuleContext, String protoToolchainAttr) throws EvalException;
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/ProguardSpecProviderApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/ProguardSpecProviderApi.java
index c136e75..1134b08 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/ProguardSpecProviderApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/ProguardSpecProviderApi.java
@@ -20,6 +20,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -49,8 +50,7 @@
doc = "Transitive proguard specs.",
positional = true,
named = false,
- type = Depset.class,
- generic1 = FileApi.class),
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)}),
},
selfCall = true)
@StarlarkConstructor
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/javascript/JsModuleInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/javascript/JsModuleInfoApi.java
index 98457c5..a277d30 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/javascript/JsModuleInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/javascript/JsModuleInfoApi.java
@@ -22,6 +22,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -67,36 +68,33 @@
name = "label",
doc = "The label of the target which created this object",
positional = false,
- named = true,
- type = Label.class),
+ named = true),
@Param(
name = "wrapper",
doc = "A string in which the output should be embedded.",
positional = false,
- named = true,
- type = String.class),
+ named = true),
@Param(
name = "full_pinto_sources",
doc =
"PintoSourcesContextProvider for this module and the transitive closure of"
+ " dependencies.",
positional = false,
- named = true,
- type = Object.class),
+ named = true),
@Param(
name = "direct_pinto_sources",
doc = "PintoSourcesContextProvider for only this module.",
positional = false,
- named = true,
- type = Object.class),
+ named = true),
@Param(
name = "direct_module_dependencies",
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = JsModuleInfoApi.class),
+ },
doc = "A list of direct module dependencies of this module.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class,
- generic1 = JsModuleInfoApi.class),
+ defaultValue = "[]"),
},
selfCall = true,
enableOnlyWithFlag = BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API)
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/ConstraintCollectionApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/ConstraintCollectionApi.java
index f6aab08..be267d9 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/ConstraintCollectionApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/ConstraintCollectionApi.java
@@ -50,7 +50,6 @@
parameters = {
@Param(
name = "constraint",
- type = ConstraintSettingInfoApi.class,
named = true,
doc = "The constraint setting to fetch the value for.")
},
@@ -64,7 +63,6 @@
parameters = {
@Param(
name = "constraint",
- type = ConstraintSettingInfoApi.class,
named = true,
doc = "The constraint setting to check.")
},
@@ -77,7 +75,6 @@
parameters = {
@Param(
name = "constraint_value",
- type = ConstraintValueInfoApi.class,
named = true,
doc = "The constraint value to check.")
},
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/PlatformInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/PlatformInfoApi.java
index f592b7c..2b9e687 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/PlatformInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/platform/PlatformInfoApi.java
@@ -22,10 +22,12 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
import java.util.Map;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkThread;
@@ -92,33 +94,37 @@
parameters = {
@Param(
name = "label",
- type = Label.class,
named = true,
positional = false,
doc = "The label for this platform."),
@Param(
name = "parent",
- type = PlatformInfoApi.class,
+ allowedTypes = {
+ @ParamType(type = PlatformInfoApi.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc = "The parent of this platform."),
@Param(
name = "constraint_values",
- type = Sequence.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = ConstraintValueInfoApi.class),
+ },
defaultValue = "[]",
- generic1 = ConstraintValueInfoApi.class,
named = true,
positional = false,
doc = "The constraint values for the platform"),
@Param(
name = "exec_properties",
- type = Dict.class,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
named = true,
positional = false,
- noneable = true,
doc = "The exec properties for the platform.")
},
selfCall = true,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyInfoApi.java
index 9169da7..54d3300 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyInfoApi.java
@@ -20,6 +20,7 @@
import com.google.devtools.build.lib.starlarkbuildapi.FileApi;
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
@@ -86,36 +87,31 @@
parameters = {
@Param(
name = "transitive_sources",
- type = Depset.class,
- generic1 = FileApi.class,
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = FileApi.class)},
positional = false,
named = true,
doc = "The value for the new object's <code>transitive_sources</code> field."),
@Param(
name = "uses_shared_libraries",
- type = Boolean.class,
positional = false,
named = true,
defaultValue = "False",
doc = "The value for the new object's <code>uses_shared_libraries</code> field."),
@Param(
name = "imports",
- type = Depset.class,
- generic1 = String.class,
+ allowedTypes = {@ParamType(type = Depset.class, generic1 = String.class)},
positional = false,
named = true,
defaultValue = "unbound",
doc = "The value for the new object's <code>imports</code> field."),
@Param(
name = "has_py2_only_sources",
- type = Boolean.class,
positional = false,
named = true,
defaultValue = "False",
doc = "The value for the new object's <code>has_py2_only_sources</code> field."),
@Param(
name = "has_py3_only_sources",
- type = Boolean.class,
positional = false,
named = true,
defaultValue = "False",
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
index 4c6b6b0..090588b 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyRuntimeInfoApi.java
@@ -21,9 +21,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.StarlarkThread;
import net.starlark.java.eval.StarlarkValue;
@@ -96,8 +98,10 @@
parameters = {
@Param(
name = "interpreter_path",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None",
@@ -106,8 +110,10 @@
+ "a value for this argument if you pass in <code>interpreter</code>."),
@Param(
name = "interpreter",
- type = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None",
@@ -116,9 +122,10 @@
+ "a value for this argument if you pass in <code>interpreter_path</code>."),
@Param(
name = "files",
- type = Depset.class,
- generic1 = FileApi.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Depset.class, generic1 = FileApi.class),
+ @ParamType(type = NoneType.class),
+ },
positional = false,
named = true,
defaultValue = "None",
@@ -129,7 +136,6 @@
+ "<code>files</code> becomes an empty <code>depset</code> instead."),
@Param(
name = "python_version",
- type = String.class,
positional = false,
named = true,
doc = "The value for the new object's <code>python_version</code> field."),
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryModuleApi.java
index cc482ac..cb9268c 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryModuleApi.java
@@ -17,9 +17,11 @@
import com.google.devtools.build.docgen.annot.DocumentMethods;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkCallable;
import net.starlark.java.eval.StarlarkThread;
@@ -39,7 +41,6 @@
parameters = {
@Param(
name = "implementation",
- type = StarlarkCallable.class,
named = true,
doc =
"the function that implements this rule. Must have a single parameter,"
@@ -48,8 +49,10 @@
+ " rule."),
@Param(
name = "attrs",
- type = Dict.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = Dict.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc =
"dictionary to declare all the attributes of the rule. It maps from an attribute "
@@ -62,7 +65,6 @@
positional = false),
@Param(
name = "local",
- type = Boolean.class,
defaultValue = "False",
doc =
"Indicate that this rule fetches everything from the local system and should be "
@@ -71,8 +73,9 @@
positional = false),
@Param(
name = "environ",
- type = Sequence.class,
- generic1 = String.class,
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ },
defaultValue = "[]",
doc =
"Provides a list of environment variable that this repository rule depends on. If "
@@ -82,14 +85,12 @@
positional = false),
@Param(
name = "configure",
- type = Boolean.class,
defaultValue = "False",
doc = "Indicate that the repository inspects the system for configuration purpose",
named = true,
positional = false),
@Param(
name = "remotable",
- type = Boolean.class,
defaultValue = "False",
doc = "Compatible with remote execution",
named = true,
@@ -98,7 +99,6 @@
valueWhenDisabled = "False"),
@Param(
name = "doc",
- type = String.class,
defaultValue = "''",
doc =
"A description of the repository rule that can be extracted by documentation "
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryPathApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryPathApi.java
index 62e5453..baea500 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryPathApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/RepositoryPathApi.java
@@ -56,7 +56,6 @@
name = "child_path",
positional = true,
named = false,
- type = String.class,
doc = "The path to append to this path."),
})
RepositoryPathApi<?> getChild(String childPath);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/StarlarkRepositoryContextApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/StarlarkRepositoryContextApi.java
index 109f2ca..b362cfb 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/StarlarkRepositoryContextApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/repository/StarlarkRepositoryContextApi.java
@@ -126,20 +126,17 @@
doc = "path of the file to create, relative to the repository directory."),
@Param(
name = "content",
- type = String.class,
named = true,
defaultValue = "''",
doc = "the content of the file to create, empty by default."),
@Param(
name = "executable",
named = true,
- type = Boolean.class,
defaultValue = "True",
doc = "set the executable flag on the created file, true by default."),
@Param(
name = "legacy_utf8",
named = true,
- type = Boolean.class,
defaultValue = "True",
doc =
"encode file content to UTF-8, true by default. Future versions will change"
@@ -177,13 +174,11 @@
doc = "path to the template file."),
@Param(
name = "substitutions",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc = "substitutions to make when expanding the template."),
@Param(
name = "executable",
- type = Boolean.class,
defaultValue = "True",
named = true,
doc = "set the executable flag on the created file, true by default."),
@@ -231,7 +226,6 @@
parameters = {
@Param(
name = "arguments",
- type = Sequence.class,
doc =
"List of arguments, the first element should be the path to the program to "
+ "execute."),
@@ -242,19 +236,16 @@
doc = "maximum duration of the command in seconds (default is 600 seconds)."),
@Param(
name = "environment",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc = "force some environment variables to be set to be passed to the process."),
@Param(
name = "quiet",
- type = Boolean.class,
defaultValue = "True",
named = true,
doc = "If stdout and stderr should be printed to the terminal."),
@Param(
name = "working_directory",
- type = String.class,
defaultValue = "\"\"",
named = true,
doc =
@@ -328,11 +319,7 @@
allowReturnNones = true,
useStarlarkThread = true,
parameters = {
- @Param(
- name = "program",
- type = String.class,
- named = false,
- doc = "Program to find in the path."),
+ @Param(name = "program", named = false, doc = "Program to find in the path."),
})
RepositoryPathApi<?> which(String program, StarlarkThread thread) throws EvalException;
@@ -364,7 +351,6 @@
doc = "path to the output file, relative to the repository directory."),
@Param(
name = "sha256",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -375,13 +361,11 @@
+ " easier but should be set before shipping."),
@Param(
name = "executable",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc = "set the executable flag on the created file, false by default."),
@Param(
name = "allow_fail",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -389,7 +373,6 @@
+ " instead of raising an error for failed downloads"),
@Param(
name = "canonical_id",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -397,13 +380,11 @@
+ " with the same canonical id"),
@Param(
name = "auth",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc = "An optional dict specifying authentication information for some of the URLs."),
@Param(
name = "integrity",
- type = String.class,
defaultValue = "''",
named = true,
positional = false,
@@ -456,7 +437,6 @@
+ " relative to the repository directory."),
@Param(
name = "stripPrefix",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -499,7 +479,6 @@
+ " relative to the repository directory."),
@Param(
name = "sha256",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -514,7 +493,6 @@
+ " cache."),
@Param(
name = "type",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -525,7 +503,6 @@
+ " \"jar\", \"war\", \"tar.gz\", \"tgz\", \"tar.bz2\", or \"tar.xz\" here."),
@Param(
name = "stripPrefix",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -536,7 +513,6 @@
+ " files."),
@Param(
name = "allow_fail",
- type = Boolean.class,
defaultValue = "False",
named = true,
doc =
@@ -544,7 +520,6 @@
+ " instead of raising an error for failed downloads"),
@Param(
name = "canonical_id",
- type = String.class,
defaultValue = "''",
named = true,
doc =
@@ -552,13 +527,11 @@
+ " with the same canonical id"),
@Param(
name = "auth",
- type = Dict.class,
defaultValue = "{}",
named = true,
doc = "An optional dict specifying authentication information for some of the URLs."),
@Param(
name = "integrity",
- type = String.class,
defaultValue = "''",
named = true,
positional = false,
@@ -590,7 +563,7 @@
useStarlarkThread = true,
documented = false,
parameters = {
- @Param(name = "flag", type = String.class, doc = "Flag to get the value for."),
+ @Param(name = "flag", doc = "Flag to get the value for."),
})
boolean flagEnabled(String flag, StarlarkThread starlarkThread) throws EvalException;
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/AnalysisTestResultInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/AnalysisTestResultInfoApi.java
index 59f6312..a90f370 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/AnalysisTestResultInfoApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/AnalysisTestResultInfoApi.java
@@ -59,14 +59,12 @@
parameters = {
@Param(
name = "success",
- type = Boolean.class,
named = true,
doc =
"If true, then the analysis-phase test represented by this target should "
+ "pass. If false, the test should fail."),
@Param(
name = "message",
- type = String.class,
named = true,
doc =
"A descriptive message containing information about the test and its "
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/CoverageCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/CoverageCommonApi.java
index bb04ace..259910e 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/CoverageCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/CoverageCommonApi.java
@@ -17,9 +17,11 @@
import com.google.devtools.build.lib.starlarkbuildapi.StarlarkRuleContextApi;
import com.google.devtools.build.lib.starlarkbuildapi.platform.ConstraintValueInfoApi;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.EvalException;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkValue;
@@ -40,19 +42,13 @@
+ "instance. Use this provider to communicate coverage-related attributes of the "
+ "current build rule.",
parameters = {
- @Param(
- name = "ctx",
- positional = true,
- named = true,
- type = StarlarkRuleContextApi.class,
- doc = "The rule context."),
+ @Param(name = "ctx", positional = true, named = true, doc = "The rule context."),
@Param(
name = "source_attributes",
doc = "A list of attribute names which contain source files processed by this rule.",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "dependency_attributes",
doc =
@@ -60,10 +56,13 @@
+ "dependencies or runfiles).",
positional = false,
named = true,
- defaultValue = "[]",
- type = Sequence.class),
+ defaultValue = "[]"),
@Param(
name = "extensions",
+ allowedTypes = {
+ @ParamType(type = Sequence.class, generic1 = String.class),
+ @ParamType(type = NoneType.class),
+ },
doc =
"File extensions used to filter files from source_attributes. For example, 'js'. "
+ "If not provided (or None), then all files from source_attributes will be "
@@ -71,9 +70,7 @@
+ "no files from source attributes will be added.",
positional = false,
named = true,
- noneable = true,
- defaultValue = "None",
- type = Sequence.class),
+ defaultValue = "None"),
})
InstrumentedFilesInfoApi instrumentedFilesInfo(
RuleContextT starlarkRuleContext,
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/TestingModuleApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/TestingModuleApi.java
index c63d515..a6f243a 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/TestingModuleApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/test/TestingModuleApi.java
@@ -36,7 +36,6 @@
parameters = {
@Param(
name = "requirements",
- type = Dict.class,
named = false,
positional = true,
doc =
@@ -57,7 +56,6 @@
parameters = {
@Param(
name = "environment",
- type = Dict.class,
named = false,
positional = true,
doc =
diff --git a/src/main/java/net/starlark/java/annot/Param.java b/src/main/java/net/starlark/java/annot/Param.java
index 210477c..25fbd6d 100644
--- a/src/main/java/net/starlark/java/annot/Param.java
+++ b/src/main/java/net/starlark/java/annot/Param.java
@@ -46,51 +46,16 @@
String defaultValue() default "";
/**
- * Type of the parameter, e.g. {@link String}.class or {@link
- * net.starlark.java.eval.Sequence}.class. May not be used in conjunction with {@link
- * #allowedTypes}. Specifying neither {@code type} nor {@code allowedTypes} is equivalent to
- * specifying the class of the parameter variable.
- */
- // Deprecated. Use allowedTypes.
- Class<?> type() default Void.class;
-
- /**
* List of allowed types for the parameter.
*
* <p>The array may be omitted, in which case the parameter accepts any value whose class is
* assignable to the class of the parameter variable.
*
- * <p>If a function should accept None, NoneType should be in this list. (Currently one may set
- * {@link #noneable} to achieve the same effect, but it is going away.)
- *
- * <p>May not be used in conjunction with {@link #type}.
+ * <p>If a function should accept None, NoneType should be in this list.
*/
ParamType[] allowedTypes() default {};
/**
- * When {@link #type()} is a generic type (e.g., {@link net.starlark.java.eval.Sequence}), specify
- * the type parameter (e.g. {@link String}.class} along with {@link
- * net.starlark.java.eval.Sequence} for {@link #type()} to specify a list of strings).
- *
- * <p>This is only used for documentation generation. The actual generic type is not checked at
- * runtime, so the Java method signature should use a generic type of Object and cast
- * appropriately.
- */
- // Deprecated. Use allowedTypes.
- Class<?> generic1() default Object.class;
-
- /**
- * Indicates whether this parameter accepts {@code None} as a value, even if NoneType was not
- * among {@link #allowedTypes}.
- *
- * <p>If true, {@code None} is accepted as a valid input in addition to the types mentioned by
- * {@link #type} or {@link #allowedTypes}. In this case, the Java type of the corresponding method
- * parameter must be {@code Object}.
- */
- // Deprecated. Use allowedTypes={..., @ParamType(type=NoneType)}.
- boolean noneable() default false;
-
- /**
* If true, the parameter may be specified as a named parameter. For example for an integer named
* parameter {@code foo} of a method {@code bar}, then the method call will look like {@code
* bar(foo=1)}.
diff --git a/src/main/java/net/starlark/java/annot/processor/StarlarkMethodProcessor.java b/src/main/java/net/starlark/java/annot/processor/StarlarkMethodProcessor.java
index 7227937..5b8ebcc 100644
--- a/src/main/java/net/starlark/java/annot/processor/StarlarkMethodProcessor.java
+++ b/src/main/java/net/starlark/java/annot/processor/StarlarkMethodProcessor.java
@@ -237,9 +237,6 @@
private void checkParameters(ExecutableElement method, StarlarkMethod annot) {
List<? extends VariableElement> params = method.getParameters();
- TypeMirror objectType = getType("java.lang.Object");
- TypeMirror voidType = getType("java.lang.Void");
-
boolean allowPositionalNext = true;
boolean allowPositionalOnlyNext = true;
boolean allowNonDefaultPositionalNext = true;
@@ -259,7 +256,7 @@
}
VariableElement param = params.get(i);
- checkParameter(param, paramAnnot, objectType, voidType);
+ checkParameter(param, paramAnnot);
// Check parameter ordering.
if (paramAnnot.positional()) {
@@ -305,8 +302,7 @@
}
// Checks consistency of a single parameter with its Param annotation.
- private void checkParameter(
- Element param, Param paramAnnot, TypeMirror objectType, TypeMirror voidType) {
+ private void checkParameter(Element param, Param paramAnnot) {
TypeMirror paramType = param.asType(); // type of the Java method parameter
// Give helpful hint for parameter of type Integer.
@@ -318,32 +314,6 @@
paramAnnot.name());
}
- // Check param.type.
- if (!types.isSameType(getParamType(paramAnnot), voidType)) {
- // Reject Param.type if not assignable to parameter variable.
- TypeMirror t = getParamType(paramAnnot);
- if (!types.isAssignable(t, types.erasure(paramType))) {
- errorf(
- param,
- "annotated type %s of parameter '%s' is not assignable to variable of type %s",
- t,
- paramAnnot.name(),
- paramType);
- }
-
- // Reject the combination of Param.type and Param.allowed_types.
- if (paramAnnot.allowedTypes().length > 0) {
- errorf(
- param,
- "Parameter '%s' has both 'type' and 'allowedTypes' specified. Only one may be"
- + " specified.",
- paramAnnot.name());
- }
- }
-
- TypeMirror noneType = getType("net.starlark.java.eval.NoneType");
- boolean allowsNoneType = false;
-
// Reject an entry of Param.allowedTypes if not assignable to the parameter variable.
for (ParamType paramTypeAnnot : paramAnnot.allowedTypes()) {
TypeMirror t = getParamTypeType(paramTypeAnnot);
@@ -356,9 +326,6 @@
paramAnnot.name(),
paramType);
}
- if (types.isSameType(t, noneType)) {
- allowsNoneType = true;
- }
}
// Reject generic types C<T> other than C<?>,
@@ -378,26 +345,6 @@
}
}
- // A "noneable" parameter variable must accept the value None.
- // A parameter whose default is None must be noneable.
- if (paramAnnot.noneable()) {
- if (!types.isSameType(paramType, objectType)) {
- errorf(
- param,
- "Expected type 'Object' but got type '%s' for noneable parameter '%s'. The argument"
- + " for a noneable parameter may be None, so the java parameter must be"
- + " compatible with the type of None as well as possible non-None values.",
- paramType,
- param.getSimpleName());
- }
- } else if (paramAnnot.defaultValue().equals("None") && !allowsNoneType) {
- errorf(
- param,
- "Parameter '%s' has 'None' default value but is not noneable. (If this is intended"
- + " as a mandatory parameter, leave the defaultValue field empty)",
- paramAnnot.name());
- }
-
// Check sense of flag-controlled parameters.
boolean hasFlag = false;
if (!paramAnnot.enableOnlyWithFlag().isEmpty()) {
@@ -433,18 +380,6 @@
return s.charAt(0) == '-' || s.charAt(0) == '+';
}
- // Returns the logical type of Param.type.
- private static TypeMirror getParamType(Param param) {
- // See explanation of this hack at Element.getAnnotation
- // and at https://stackoverflow.com/a/10167558.
- try {
- param.type();
- throw new IllegalStateException("unreachable");
- } catch (MirroredTypeException ex) {
- return ex.getTypeMirror();
- }
- }
-
// Returns the logical type of ParamType.type.
private static TypeMirror getParamTypeType(ParamType paramType) {
// See explanation of this hack at Element.getAnnotation
diff --git a/src/main/java/net/starlark/java/eval/Dict.java b/src/main/java/net/starlark/java/eval/Dict.java
index 1c25717..d415474 100644
--- a/src/main/java/net/starlark/java/eval/Dict.java
+++ b/src/main/java/net/starlark/java/eval/Dict.java
@@ -169,11 +169,10 @@
+ "else <code>default</code>. If <code>default</code> is not given, it defaults to "
+ "<code>None</code>, so that this method never throws an error.",
parameters = {
- @Param(name = "key", noneable = true, doc = "The key to look for."),
+ @Param(name = "key", doc = "The key to look for."),
@Param(
name = "default",
defaultValue = "None",
- noneable = true,
named = true,
doc = "The default value to use (instead of None) if the key is not found.")
},
@@ -204,13 +203,11 @@
+ "If no entry with that key was found, remove nothing and return the specified "
+ "<code>default</code> value; if no default value was specified, fail instead.",
parameters = {
- @Param(name = "key", type = Object.class, doc = "The key.", noneable = true),
+ @Param(name = "key", doc = "The key."),
@Param(
name = "default",
- type = Object.class,
defaultValue = "unbound",
named = true,
- noneable = true,
doc = "a default value if the key is absent."),
},
useStarlarkThread = true)
@@ -254,13 +251,11 @@
+ "and return <code>default</code>. "
+ "<code>default</code> defaults to <code>None</code>.",
parameters = {
- @Param(name = "key", type = Object.class, doc = "The key."),
+ @Param(name = "key", doc = "The key."),
@Param(
name = "default",
- type = Object.class,
defaultValue = "None",
named = true,
- noneable = true,
doc = "a default value if the key is absent."),
})
@SuppressWarnings("unchecked") // Cast of value to V
@@ -290,7 +285,6 @@
parameters = {
@Param(
name = "args",
- type = Object.class,
defaultValue = "[]",
doc =
"Either a dictionary or a list of entries. Entries must be tuples or lists with "
diff --git a/src/main/java/net/starlark/java/eval/MethodLibrary.java b/src/main/java/net/starlark/java/eval/MethodLibrary.java
index a908636..fff7679 100644
--- a/src/main/java/net/starlark/java/eval/MethodLibrary.java
+++ b/src/main/java/net/starlark/java/eval/MethodLibrary.java
@@ -29,6 +29,7 @@
import java.util.NoSuchElementException;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
@@ -89,13 +90,7 @@
+ "Elements are converted to boolean using the <a href=\"#bool\">bool</a> function."
+ "<pre class=\"language-python\">all([\"hello\", 3, True]) == True\n"
+ "all([-1, 0, 1]) == False</pre>",
- parameters = {
- @Param(
- name = "elements",
- type = Object.class,
- noneable = true,
- doc = "A string or a collection of elements.")
- })
+ parameters = {@Param(name = "elements", doc = "A string or a collection of elements.")})
public Boolean all(Object collection) throws EvalException {
return !hasElementWithBooleanValue(collection, false);
}
@@ -107,13 +102,7 @@
+ "Elements are converted to boolean using the <a href=\"#bool\">bool</a> function."
+ "<pre class=\"language-python\">any([-1, 0, 1]) == True\n"
+ "any([False, 0, \"\"]) == False</pre>",
- parameters = {
- @Param(
- name = "elements",
- type = Object.class,
- noneable = true,
- doc = "A string or a collection of elements.")
- })
+ parameters = {@Param(name = "elements", doc = "A string or a collection of elements.")})
public Boolean any(Object collection) throws EvalException {
return hasElementWithBooleanValue(collection, true);
}
@@ -136,17 +125,15 @@
+ "It is an error if elements are not comparable (for example int with string)."
+ "<pre class=\"language-python\">sorted([3, 5, 4]) == [3, 4, 5]</pre>",
parameters = {
- @Param(name = "iterable", type = Object.class, doc = "The iterable sequence to sort."),
+ @Param(name = "iterable", doc = "The iterable sequence to sort."),
@Param(
name = "key",
doc = "An optional function applied to each element before comparison.",
named = true,
defaultValue = "None",
- positional = false,
- noneable = true),
+ positional = false),
@Param(
name = "reverse",
- type = Boolean.class,
doc = "Return results in descending order.",
named = true,
defaultValue = "False",
@@ -240,10 +227,7 @@
"Returns a list that contains the elements of the original sequence in reversed order."
+ "<pre class=\"language-python\">reversed([3, 5, 4]) == [4, 5, 3]</pre>",
parameters = {
- @Param(
- name = "sequence",
- type = Sequence.class,
- doc = "The sequence (list or tuple) to be reversed."),
+ @Param(name = "sequence", doc = "The sequence (list or tuple) to be reversed."),
},
useStarlarkThread = true)
public StarlarkList<?> reversed(Sequence<?> sequence, StarlarkThread thread)
@@ -302,7 +286,7 @@
"Converts any object to string. This is useful for debugging."
+ "<pre class=\"language-python\">str(\"ab\") == \"ab\"\n"
+ "str(8) == \"8\"</pre>",
- parameters = {@Param(name = "x", doc = "The object to convert.", noneable = true)})
+ parameters = {@Param(name = "x", doc = "The object to convert.")})
public String str(Object x) throws EvalException {
return Starlark.str(x);
}
@@ -312,7 +296,7 @@
doc =
"Converts any object to a string representation. This is useful for debugging.<br>"
+ "<pre class=\"language-python\">repr(\"ab\") == '\"ab\"'</pre>",
- parameters = {@Param(name = "x", doc = "The object to convert.", noneable = true)})
+ parameters = {@Param(name = "x", doc = "The object to convert.")})
public String repr(Object x) {
return Starlark.repr(x);
}
@@ -325,13 +309,7 @@
+ "</code>, an empty string (<code>\"\"</code>), the number <code>0</code>, or an "
+ "empty collection (e.g. <code>()</code>, <code>[]</code>). "
+ "Otherwise, it returns <code>True</code>.",
- parameters = {
- @Param(
- name = "x",
- defaultValue = "False",
- doc = "The variable to convert.",
- noneable = true)
- })
+ parameters = {@Param(name = "x", defaultValue = "False", doc = "The variable to convert.")})
public Boolean bool(Object x) throws EvalException {
return Starlark.truth(x);
}
@@ -379,10 +357,9 @@
+ "int(\"-0x10\", 0) == -16"
+ "</pre>",
parameters = {
- @Param(name = "x", type = Object.class, doc = "The string to convert."),
+ @Param(name = "x", doc = "The string to convert."),
@Param(
name = "base",
- type = StarlarkInt.class,
defaultValue = "unbound",
doc =
"The base used to interpret a string value; defaults to 10. Must be between 2 "
@@ -501,7 +478,6 @@
parameters = {
@Param(
name = "args",
- type = Object.class,
defaultValue = "[]",
doc =
"Either a dictionary or a list of entries. Entries must be tuples or lists with "
@@ -527,13 +503,8 @@
parameters = {
// Note Python uses 'sequence' keyword instead of 'list'. We may want to change tihs
// some day.
- @Param(name = "list", type = Object.class, doc = "input sequence.", named = true),
- @Param(
- name = "start",
- type = StarlarkInt.class,
- doc = "start index.",
- defaultValue = "0",
- named = true)
+ @Param(name = "list", doc = "input sequence.", named = true),
+ @Param(name = "start", doc = "start index.", defaultValue = "0", named = true),
},
useStarlarkThread = true)
public StarlarkList<?> enumerate(Object input, StarlarkInt startI, StarlarkThread thread)
@@ -556,7 +527,7 @@
// Deterministic hashing is important for the consistency of builds, hence why we
// promise a specific algorithm. This is in contrast to Java (Object.hashCode()) and
// Python, which promise stable hashing only within a given execution of the program.
- parameters = {@Param(name = "value", type = String.class, doc = "String value to hash.")})
+ parameters = {@Param(name = "value", doc = "String value to hash.")})
public Integer hash(String value) throws EvalException {
return value.hashCode();
}
@@ -573,21 +544,21 @@
parameters = {
@Param(
name = "start_or_stop",
- type = StarlarkInt.class,
doc =
"Value of the start element if stop is provided, "
+ "otherwise value of stop and the actual start is 0"),
@Param(
name = "stop_or_none",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc =
"optional index of the first item <i>not</i> to be included in the resulting "
+ "list; generation of the list stops before <code>stop</code> is reached."),
@Param(
name = "step",
- type = StarlarkInt.class,
defaultValue = "1",
doc = "The increment (default is 1). It may be negative.")
},
@@ -620,8 +591,8 @@
+ "<code>name</code>, otherwise False. Example:<br>"
+ "<pre class=\"language-python\">hasattr(ctx.attr, \"myattr\")</pre>",
parameters = {
- @Param(name = "x", doc = "The object to check.", noneable = true),
- @Param(name = "name", type = String.class, doc = "The name of the attribute.")
+ @Param(name = "x", doc = "The object to check."),
+ @Param(name = "name", doc = "The name of the attribute.")
},
useStarlarkThread = true)
public Boolean hasattr(Object obj, String name, StarlarkThread thread) throws EvalException {
@@ -637,15 +608,14 @@
+ "<pre class=\"language-python\">getattr(ctx.attr, \"myattr\")\n"
+ "getattr(ctx.attr, \"myattr\", \"mydefault\")</pre>",
parameters = {
- @Param(name = "x", doc = "The struct whose attribute is accessed.", noneable = true),
+ @Param(name = "x", doc = "The struct whose attribute is accessed."),
@Param(name = "name", doc = "The name of the struct attribute."),
@Param(
name = "default",
defaultValue = "unbound",
doc =
"The default value to return in case the struct "
- + "doesn't have an attribute of the given name.",
- noneable = true)
+ + "doesn't have an attribute of the given name.")
},
useStarlarkThread = true)
public Object getattr(Object obj, String name, Object defaultValue, StarlarkThread thread)
@@ -663,7 +633,7 @@
doc =
"Returns a list of strings: the names of the attributes and "
+ "methods of the parameter object.",
- parameters = {@Param(name = "x", doc = "The object to check.", noneable = true)},
+ parameters = {@Param(name = "x", doc = "The object to check.")},
useStarlarkThread = true)
public StarlarkList<?> dir(Object object, StarlarkThread thread) throws EvalException {
return Starlark.dir(thread.mutability(), thread.getSemantics(), object);
@@ -677,15 +647,15 @@
parameters = {
@Param(
name = "msg",
- type = Object.class,
doc = "Error to display for the user. The object is converted to a string.",
defaultValue = "None",
- named = true,
- noneable = true),
+ named = true),
@Param(
name = "attr",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc =
"The name of the attribute that caused the error. This is used only for "
@@ -715,7 +685,6 @@
parameters = {
@Param(
name = "sep",
- type = String.class,
defaultValue = "\" \"",
named = true,
positional = false,
@@ -757,7 +726,7 @@
+ "<pre class=\"language-python\">"
+ "if type(x) == type([]): # if x is a list"
+ "</pre>",
- parameters = {@Param(name = "x", doc = "The object to check type of.", noneable = true)})
+ parameters = {@Param(name = "x", doc = "The object to check type of.")})
public String type(Object object) {
// There is no 'type' type in Starlark, so we return a string with the type name.
return Starlark.type(object);
diff --git a/src/main/java/net/starlark/java/eval/ParamDescriptor.java b/src/main/java/net/starlark/java/eval/ParamDescriptor.java
index f62b221..be42efa 100644
--- a/src/main/java/net/starlark/java/eval/ParamDescriptor.java
+++ b/src/main/java/net/starlark/java/eval/ParamDescriptor.java
@@ -79,16 +79,10 @@
for (ParamType pt : allowedTypes) {
allowedClasses.add(pt.type());
}
- } else if (param.type() == Void.class) {
- // If no Param.type type was specified, use the class of the parameter itself.
+ } else {
+ // Use the class of the parameter itself.
// Interpret primitive boolean parameter as j.l.Boolean.
allowedClasses.add(paramClass == Boolean.TYPE ? Boolean.class : paramClass);
- } else {
- allowedClasses.add(param.type());
- }
-
- if (param.noneable() && !allowedClasses.contains(NoneType.class)) {
- allowedClasses.add(NoneType.class);
}
return new ParamDescriptor(
diff --git a/src/main/java/net/starlark/java/eval/StarlarkList.java b/src/main/java/net/starlark/java/eval/StarlarkList.java
index c62ce38..c0503e1 100644
--- a/src/main/java/net/starlark/java/eval/StarlarkList.java
+++ b/src/main/java/net/starlark/java/eval/StarlarkList.java
@@ -21,6 +21,7 @@
import java.util.Collection;
import javax.annotation.Nullable;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkBuiltin;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.syntax.Location;
@@ -346,7 +347,7 @@
doc =
"Removes the first item from the list whose value is x. "
+ "It is an error if there is no such item.",
- parameters = {@Param(name = "x", type = Object.class, doc = "The object to remove.")})
+ parameters = {@Param(name = "x", doc = "The object to remove.")})
public NoneType removeObject(Object x) throws EvalException {
for (int i = 0; i < size; i++) {
if (elems[i].equals(x)) {
@@ -373,9 +374,7 @@
@StarlarkMethod(
name = "append",
doc = "Adds an item to the end of the list.",
- parameters = {
- @Param(name = "item", type = Object.class, doc = "Item to add at the end.", noneable = true)
- })
+ parameters = {@Param(name = "item", doc = "Item to add at the end.")})
@SuppressWarnings("unchecked")
public NoneType append(Object item) throws EvalException {
add((E) item, (Location) null); // unchecked
@@ -396,8 +395,8 @@
name = "insert",
doc = "Inserts an item at a given position.",
parameters = {
- @Param(name = "index", type = StarlarkInt.class, doc = "The index of the given position."),
- @Param(name = "item", type = Object.class, doc = "The item.", noneable = true)
+ @Param(name = "index", doc = "The index of the given position."),
+ @Param(name = "item", doc = "The item.")
})
@SuppressWarnings("unchecked")
public NoneType insert(StarlarkInt index, Object item) throws EvalException {
@@ -408,7 +407,7 @@
@StarlarkMethod(
name = "extend",
doc = "Adds all items to the end of the list.",
- parameters = {@Param(name = "items", type = Object.class, doc = "Items to add at the end.")})
+ parameters = {@Param(name = "items", doc = "Items to add at the end.")})
public NoneType extend(Object items) throws EvalException {
@SuppressWarnings("unchecked")
Iterable<? extends E> src = (Iterable<? extends E>) Starlark.toIterable(items);
@@ -422,19 +421,23 @@
"Returns the index in the list of the first item whose value is x. "
+ "It is an error if there is no such item.",
parameters = {
- @Param(name = "x", type = Object.class, doc = "The object to search."),
+ @Param(name = "x", doc = "The object to search."),
@Param(
name = "start",
- type = StarlarkInt.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class), // TODO(adonovan): this is wrong
+ },
defaultValue = "None",
- noneable = true, // TODO(adonovan): this is wrong
named = true, // TODO(adonovan): this is wrong
doc = "The start index of the list portion to inspect."),
@Param(
name = "end",
- type = StarlarkInt.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class), // TODO(adonovan): this is wrong
+ },
defaultValue = "None",
- noneable = true, // TODO(adonovan): this is wrong
named = true, // TODO(adonovan): this is wrong
doc = "The end index of the list portion to inspect.")
})
@@ -458,8 +461,10 @@
parameters = {
@Param(
name = "i",
- type = StarlarkInt.class,
- noneable = true, // TODO(adonovan): this is not what Python3 does
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class), // TODO(adonovan): this is not what Python3 does
+ },
defaultValue = "-1",
doc = "The index of the item.")
})
diff --git a/src/main/java/net/starlark/java/eval/StringModule.java b/src/main/java/net/starlark/java/eval/StringModule.java
index 7375526..35230d5 100644
--- a/src/main/java/net/starlark/java/eval/StringModule.java
+++ b/src/main/java/net/starlark/java/eval/StringModule.java
@@ -121,10 +121,7 @@
+ "joined by this string as a separator. Example:<br>"
+ "<pre class=\"language-python\">\"|\".join([\"a\", \"b\", \"c\"]) == \"a|b|c\""
+ "</pre>",
- parameters = {
- @Param(name = "self", type = String.class),
- @Param(name = "elements", type = Object.class, doc = "The objects to join.")
- })
+ parameters = {@Param(name = "self"), @Param(name = "elements", doc = "The objects to join.")})
public String join(String self, Object elements) throws EvalException {
Iterable<?> items = Starlark.toIterable(elements);
int i = 0;
@@ -141,7 +138,7 @@
@StarlarkMethod(
name = "lower",
doc = "Returns the lower case version of this string.",
- parameters = {@Param(name = "self", type = String.class)})
+ parameters = {@Param(name = "self")})
public String lower(String self) {
return Ascii.toLowerCase(self);
}
@@ -149,7 +146,7 @@
@StarlarkMethod(
name = "upper",
doc = "Returns the upper case version of this string.",
- parameters = {@Param(name = "self", type = String.class)})
+ parameters = {@Param(name = "self")})
public String upper(String self) {
return Ascii.toUpperCase(self);
}
@@ -200,11 +197,13 @@
+ "\"abcba\".lstrip(\"ba\") == \"cba\""
+ "</pre>",
parameters = {
- @Param(name = "self", type = String.class),
+ @Param(name = "self"),
@Param(
name = "chars",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
doc = "The characters to remove, or all whitespace if None.",
defaultValue = "None")
})
@@ -223,11 +222,13 @@
+ "\"abcbaa\".rstrip(\"ab\") == \"abc\""
+ "</pre>",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
@Param(
name = "chars",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
doc = "The characters to remove, or all whitespace if None.",
defaultValue = "None")
})
@@ -247,11 +248,13 @@
+ "\"aabcbcbaa\".strip(\"ab\") == \"cbc\""
+ "</pre>",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
@Param(
name = "chars",
- type = String.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
doc = "The characters to remove, or all whitespace if None.",
defaultValue = "None")
})
@@ -267,13 +270,16 @@
+ "of <code>old</code> have been replaced with <code>new</code>, optionally "
+ "restricting the number of replacements to <code>maxsplit</code>.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "old", type = String.class, doc = "The string to be replaced."),
- @Param(name = "new", type = String.class, doc = "The string to replace with."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "old", doc = "The string to be replaced."),
+ @Param(name = "new", doc = "The string to replace with."),
@Param(
name = "count",
- type = StarlarkInt.class,
- noneable = true, // TODO(#11244): Set false once incompatible flag is deleted.
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(
+ type = NoneType.class), // TODO(#11244): remove once incompatible flag is deleted.
+ },
defaultValue = "unbound",
doc =
"The maximum number of replacements. If omitted, there is no limit."
@@ -339,12 +345,14 @@
"Returns a list of all the words in the string, using <code>sep</code> as the "
+ "separator, optionally limiting the number of splits to <code>maxsplit</code>.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sep", type = String.class, doc = "The string to split on."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sep", doc = "The string to split on."),
@Param(
name = "maxsplit",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "The maximum number of splits.")
},
@@ -379,12 +387,14 @@
+ "separator, optionally limiting the number of splits to <code>maxsplit</code>. "
+ "Except for splitting from the right, this method behaves like split().",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sep", type = String.class, doc = "The string to split on."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sep", doc = "The string to split on."),
@Param(
name = "maxsplit",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "The maximum number of splits.")
},
@@ -420,10 +430,7 @@
+ " returns the resulting partition as a three-element tuple of the form (before,"
+ " separator, after). If the input string does not contain the separator, partition"
+ " returns (self, '', '').",
- parameters = {
- @Param(name = "self", type = String.class),
- @Param(name = "sep", type = String.class, doc = "The string to split on.")
- })
+ parameters = {@Param(name = "self"), @Param(name = "sep", doc = "The string to split on.")})
public Tuple<String> partition(String self, String sep) throws EvalException {
return partitionCommon(self, sep, /*first=*/ true);
}
@@ -435,10 +442,7 @@
+ " returns the resulting partition as a three-element tuple of the form (before,"
+ " separator, after). If the input string does not contain the separator,"
+ " rpartition returns ('', '', self).",
- parameters = {
- @Param(name = "self", type = String.class),
- @Param(name = "sep", type = String.class, doc = "The string to split on.")
- })
+ parameters = {@Param(name = "self"), @Param(name = "sep", doc = "The string to split on.")})
public Tuple<String> rpartition(String self, String sep) throws EvalException {
return partitionCommon(self, sep, /*first=*/ false);
}
@@ -478,7 +482,7 @@
doc =
"Returns a copy of the string with its first character (if any) capitalized and the rest "
+ "lowercased. This method does not support non-ascii characters. ",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public String capitalize(String self) throws EvalException {
if (self.isEmpty()) {
return self;
@@ -494,7 +498,7 @@
+ "uppercase letter while the remaining letters are lowercase. In this "
+ "context, a word means strictly a sequence of letters. This method does "
+ "not support supplementary Unicode characters.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public String title(String self) throws EvalException {
char[] data = self.toCharArray();
boolean previousWasLetter = false;
@@ -544,18 +548,22 @@
+ "optionally restricting to <code>[start:end]</code>, "
+ "<code>start</code> being inclusive and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sub", type = String.class, doc = "The substring to find."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sub", doc = "The substring to find."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Restrict to search from this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position before which to restrict to search.")
})
@@ -570,18 +578,22 @@
+ "optionally restricting to <code>[start:end]</code>, "
+ "<code>start</code> being inclusive and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sub", type = String.class, doc = "The substring to find."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sub", doc = "The substring to find."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Restrict to search from this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position before which to restrict to search.")
})
@@ -596,18 +608,22 @@
+ "index exists, optionally restricting to <code>[start:end]</code>, "
+ "<code>start</code> being inclusive and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sub", type = String.class, doc = "The substring to find."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sub", doc = "The substring to find."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Restrict to search from this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position before which to restrict to search.")
})
@@ -626,18 +642,22 @@
+ " index exists, optionally restricting to <code>[start:end]</code>"
+ "<code>start</code> being inclusive and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sub", type = String.class, doc = "The substring to find."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sub", doc = "The substring to find."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Restrict to search from this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position before which to restrict to search.")
})
@@ -655,10 +675,10 @@
"Splits the string at line boundaries ('\\n', '\\r\\n', '\\r') "
+ "and returns the result as a list.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
@Param(
+ // TODO(b/67740837): clarify whether this is named or positional.
name = "keepends",
- type = Boolean.class,
defaultValue = "False",
doc = "Whether the line breaks should be included in the resulting list.")
})
@@ -688,7 +708,7 @@
doc =
"Returns True if all characters in the string are alphabetic ([a-zA-Z]) and there is "
+ "at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isAlpha(String self) throws EvalException {
return matches(self, ALPHA, false);
}
@@ -698,7 +718,7 @@
doc =
"Returns True if all characters in the string are alphanumeric ([a-zA-Z0-9]) and there "
+ "is at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isAlnum(String self) throws EvalException {
return matches(self, ALNUM, false);
}
@@ -708,7 +728,7 @@
doc =
"Returns True if all characters in the string are digits ([0-9]) and there is "
+ "at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isDigit(String self) throws EvalException {
return matches(self, DIGIT, false);
}
@@ -718,7 +738,7 @@
doc =
"Returns True if all characters are white space characters and the string "
+ "contains at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isSpace(String self) throws EvalException {
return matches(self, SPACE, false);
}
@@ -728,7 +748,7 @@
doc =
"Returns True if all cased characters in the string are lowercase and there is "
+ "at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isLower(String self) throws EvalException {
// Python also accepts non-cased characters, so we cannot use LOWER.
return matches(self, UPPER.negate(), true);
@@ -739,7 +759,7 @@
doc =
"Returns True if all cased characters in the string are uppercase and there is "
+ "at least one character.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isUpper(String self) throws EvalException {
// Python also accepts non-cased characters, so we cannot use UPPER.
return matches(self, LOWER.negate(), true);
@@ -752,7 +772,7 @@
+ "This means that every uppercase character must follow an uncased one (e.g. "
+ "whitespace) and every lowercase character must follow a cased one (e.g. "
+ "uppercase or lowercase).",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Boolean isTitle(String self) throws EvalException {
if (self.isEmpty()) {
return false;
@@ -819,18 +839,22 @@
+ "string, optionally restricting to <code>[start:end]</code>, <code>start</code> "
+ "being inclusive and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
- @Param(name = "sub", type = String.class, doc = "The substring to count."),
+ @Param(name = "self", doc = "This string."),
+ @Param(name = "sub", doc = "The substring to count."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Restrict to search from this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position before which to restrict to search.")
})
@@ -858,7 +882,7 @@
"Returns an iterable value containing successive 1-element substrings of the string. "
+ "Equivalent to <code>[s[i] for i in range(len(s))]</code>, except that the "
+ "returned value might not be a list.",
- parameters = {@Param(name = "self", type = String.class, doc = "This string.")})
+ parameters = {@Param(name = "self", doc = "This string.")})
public Sequence<String> elems(String self) throws EvalException {
ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
for (char c : self.toCharArray()) {
@@ -874,7 +898,7 @@
+ "restricting to <code>[start:end]</code>, <code>start</code> being inclusive "
+ "and <code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
@Param(
name = "sub",
allowedTypes = {
@@ -884,14 +908,18 @@
doc = "The suffix (or tuple of alternative suffixes) to match."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Test beginning at this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "optional position at which to stop comparing.")
})
@@ -935,20 +963,11 @@
+ "# Access by name:\n"
+ "\"x{key}x\".format(key = 2) == \"x2x\"</pre>\n",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
},
- extraPositionals =
- @Param(
- name = "args",
- type = Tuple.class,
- defaultValue = "()",
- doc = "List of arguments."),
+ extraPositionals = @Param(name = "args", defaultValue = "()", doc = "List of arguments."),
extraKeywords =
- @Param(
- name = "kwargs",
- type = Dict.class,
- defaultValue = "{}",
- doc = "Dictionary of arguments."))
+ @Param(name = "kwargs", defaultValue = "{}", doc = "Dictionary of arguments."))
public String format(String self, Tuple<Object> args, Dict<String, Object> kwargs)
throws EvalException {
return new FormatParser().format(self, args, kwargs);
@@ -961,7 +980,7 @@
+ "restricting to <code>[start:end]</code>, <code>start</code> being inclusive and "
+ "<code>end</code> being exclusive.",
parameters = {
- @Param(name = "self", type = String.class, doc = "This string."),
+ @Param(name = "self", doc = "This string."),
@Param(
name = "sub",
allowedTypes = {
@@ -971,14 +990,18 @@
doc = "The prefix (or tuple of alternative prefixes) to match."),
@Param(
name = "start",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "0",
doc = "Test beginning at this position."),
@Param(
name = "end",
- type = StarlarkInt.class,
- noneable = true,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
doc = "Stop comparing at this position.")
})
diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleClassFunctionsTest.java
index 45c3d2b..b8ae38a 100644
--- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleClassFunctionsTest.java
@@ -214,7 +214,10 @@
@Test
public void testAttrAllowedFileTypesWrongType() throws Exception {
ev.checkEvalErrorContains(
- "allow_files should be a boolean or a string list", "attr.label_list(allow_files = 18)");
+ // TODO(adonovan): this seems like a UI regression.
+ // Was: allow_files should be a boolean or a string list
+ "got value of type 'int', want 'bool or sequence or NoneType'",
+ "attr.label_list(allow_files = 18)");
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java
index 5a192fe..01fdbfb 100644
--- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkRuleImplementationFunctionsTest.java
@@ -104,7 +104,7 @@
documented = false,
parameters = {
@Param(name = "mandatory", doc = "", named = true),
- @Param(name = "optional", doc = "", defaultValue = "None", noneable = true, named = true),
+ @Param(name = "optional", doc = "", defaultValue = "None", named = true),
@Param(name = "mandatory_key", doc = "", positional = false, named = true),
@Param(
name = "optional_key",
diff --git a/src/test/java/net/starlark/java/annot/processor/StarlarkMethodProcessorTest.java b/src/test/java/net/starlark/java/annot/processor/StarlarkMethodProcessorTest.java
index 32c9925..90e1afe 100644
--- a/src/test/java/net/starlark/java/annot/processor/StarlarkMethodProcessorTest.java
+++ b/src/test/java/net/starlark/java/annot/processor/StarlarkMethodProcessorTest.java
@@ -162,27 +162,6 @@
}
@Test
- public void testInvalidParamNoneDefault() throws Exception {
- assertAbout(javaSource())
- .that(getFile("InvalidParamNoneDefault.java"))
- .processedWith(new StarlarkMethodProcessor())
- .failsToCompile()
- .withErrorContaining(
- "Parameter 'a_parameter' has 'None' default value but is not noneable.");
- }
-
- @Test
- public void testParamTypeConflict() throws Exception {
- assertAbout(javaSource())
- .that(getFile("ParamTypeConflict.java"))
- .processedWith(new StarlarkMethodProcessor())
- .failsToCompile()
- .withErrorContaining(
- "Parameter 'a_parameter' has both 'type' and 'allowedTypes' specified."
- + " Only one may be specified.");
- }
-
- @Test
public void testParamNeitherNamedNorPositional() throws Exception {
assertAbout(javaSource())
.that(getFile("ParamNeitherNamedNorPositional.java"))
@@ -344,15 +323,4 @@
"parameter 'one' has generic type "
+ "net.starlark.java.eval.Sequence<java.lang.String>");
}
-
- @Test
- public void testInvalidNoneableParameter() throws Exception {
- assertAbout(javaSource())
- .that(getFile("InvalidNoneableParameter.java"))
- .processedWith(new StarlarkMethodProcessor())
- .failsToCompile()
- .withErrorContaining(
- "Expected type 'Object' but got type 'java.lang.String' "
- + "for noneable parameter 'aParameter'.");
- }
}
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/ArgumentMissing.java b/src/test/java/net/starlark/java/annot/processor/testsources/ArgumentMissing.java
index 622d0bf..4d3d224 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/ArgumentMissing.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/ArgumentMissing.java
@@ -28,7 +28,7 @@
name = "method_with_params",
documented = false,
parameters = {
- @Param(name = "a_parameter", type = String.class, named = true),
+ @Param(name = "a_parameter", named = true),
})
public String methodWithParams() {
return "bunny";
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/ConflictingMethodNames.java b/src/test/java/net/starlark/java/annot/processor/testsources/ConflictingMethodNames.java
index 7b0e11c..1976bdb 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/ConflictingMethodNames.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/ConflictingMethodNames.java
@@ -29,7 +29,7 @@
name = "conflicting_method",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
+ @Param(name = "one", named = true),
})
public String conflictingMethod(String one) {
return "foo";
@@ -39,8 +39,8 @@
name = "conflicting_method",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
})
public String conflictingMethodTwo(String one, StarlarkInt two) {
return "foo";
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlag.java b/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlag.java
index 01abb8c..7e1c3b3 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlag.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlag.java
@@ -29,8 +29,8 @@
name = "someMethod",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
enableOnlyWithFlag = FOO,
disableWithFlag = FOO)
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlagParam.java b/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlagParam.java
index fd2c654..828b41c 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlagParam.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/EnablingAndDisablingFlagParam.java
@@ -31,13 +31,8 @@
name = "someMethod",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(
- name = "two",
- type = StarlarkInt.class,
- named = true,
- enableOnlyWithFlag = FOO,
- disableWithFlag = FOO),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true, enableOnlyWithFlag = FOO, disableWithFlag = FOO),
})
public String someMethod(String one, StarlarkInt two) {
return "foo";
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/GoldenCase.java b/src/test/java/net/starlark/java/annot/processor/testsources/GoldenCase.java
index 33940c1..3aefe18 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/GoldenCase.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/GoldenCase.java
@@ -15,8 +15,10 @@
package net.starlark.java.annot.processor.testsources;
import net.starlark.java.annot.Param;
+import net.starlark.java.annot.ParamType;
import net.starlark.java.annot.StarlarkMethod;
import net.starlark.java.eval.Dict;
+import net.starlark.java.eval.NoneType;
import net.starlark.java.eval.Sequence;
import net.starlark.java.eval.StarlarkInt;
import net.starlark.java.eval.StarlarkSemantics;
@@ -48,14 +50,16 @@
name = "three_arg_method",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
@Param(
name = "three",
- type = String.class,
+ allowedTypes = {
+ @ParamType(type = String.class),
+ @ParamType(type = NoneType.class),
+ },
named = true,
- defaultValue = "None",
- noneable = true),
+ defaultValue = "None"),
})
public String threeArgMethod(String one, StarlarkInt two, Object three) {
return "bar";
@@ -65,9 +69,9 @@
name = "three_arg_method_with_params_and_thread",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
- @Param(name = "three", type = String.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
+ @Param(name = "three", named = true),
},
useStarlarkThread = true)
public String threeArgMethodWithParams(
@@ -79,22 +83,12 @@
name = "many_arg_method_mixing_positional_and_named",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, positional = true, named = false),
- @Param(name = "two", type = String.class, positional = true, named = true),
- @Param(
- name = "three",
- type = String.class,
- positional = true,
- named = true,
- defaultValue = "three"),
- @Param(name = "four", type = String.class, positional = false, named = true),
- @Param(
- name = "five",
- type = String.class,
- positional = false,
- named = true,
- defaultValue = "five"),
- @Param(name = "six", type = String.class, positional = false, named = true),
+ @Param(name = "one", positional = true, named = false),
+ @Param(name = "two", positional = true, named = true),
+ @Param(name = "three", positional = true, named = true, defaultValue = "three"),
+ @Param(name = "four", positional = false, named = true),
+ @Param(name = "five", positional = false, named = true, defaultValue = "five"),
+ @Param(name = "six", positional = false, named = true),
})
public String manyArgMethodMixingPositionalAndNamed(
String one, String two, String three, String four, String five, String six) {
@@ -105,8 +99,8 @@
name = "two_arg_method_with_params_and_thread_and_kwargs",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
extraKeywords = @Param(name = "kwargs"),
useStarlarkThread = true)
@@ -119,8 +113,8 @@
name = "two_arg_method_with_env_and_args_and_kwargs",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
extraPositionals = @Param(name = "args"),
extraKeywords = @Param(name = "kwargs"),
@@ -134,8 +128,8 @@
name = "selfCallMethod",
selfCall = true,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
documented = false)
public Integer selfCallMethod(String one, StarlarkInt two) {
@@ -155,8 +149,8 @@
name = "method_with_list_and_dict",
documented = false,
parameters = {
- @Param(name = "one", type = Sequence.class, named = true),
- @Param(name = "two", type = Dict.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
})
public String methodWithListandDict(Sequence<?> one, Dict<?, ?> two) {
return "bar";
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/InvalidNoneableParameter.java b/src/test/java/net/starlark/java/annot/processor/testsources/InvalidNoneableParameter.java
deleted file mode 100644
index 418c10c..0000000
--- a/src/test/java/net/starlark/java/annot/processor/testsources/InvalidNoneableParameter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2019 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package net.starlark.java.annot.processor.testsources;
-
-import net.starlark.java.annot.Param;
-import net.starlark.java.annot.StarlarkMethod;
-import net.starlark.java.eval.StarlarkValue;
-
-/**
- * Test case for a StarlarkMethod method which has a parameter with both type and allowedTypes
- * specified.
- */
-public class InvalidNoneableParameter implements StarlarkValue {
-
- @StarlarkMethod(
- name = "invalid_noneable_parameter",
- documented = false,
- parameters = {
- @Param(name = "a_parameter", type = String.class, noneable = true, named = true)
- })
- public Integer invalidNoneableParameter(String aParameter) {
- return 42;
- }
-
-}
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/InvalidParamNoneDefault.java b/src/test/java/net/starlark/java/annot/processor/testsources/InvalidParamNoneDefault.java
deleted file mode 100644
index 5153113..0000000
--- a/src/test/java/net/starlark/java/annot/processor/testsources/InvalidParamNoneDefault.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package net.starlark.java.annot.processor.testsources;
-
-import net.starlark.java.annot.Param;
-import net.starlark.java.annot.StarlarkMethod;
-import net.starlark.java.eval.StarlarkValue;
-
-/**
- * Test case for a StarlarkMethod method which has a parameter with "None" set as the default, but
- * noneable is not true.
- */
-public class InvalidParamNoneDefault implements StarlarkValue {
-
- @StarlarkMethod(
- name = "method_with_invalid_default",
- documented = false,
- parameters = {
- @Param(name = "a_parameter", type = String.class, named = true, defaultValue = "None"),
- })
- public String methodWithParams(String x) {
- return "lamb";
- }
-}
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/MultipleSelfCallMethods.java b/src/test/java/net/starlark/java/annot/processor/testsources/MultipleSelfCallMethods.java
index 893056c..cdc28ba 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/MultipleSelfCallMethods.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/MultipleSelfCallMethods.java
@@ -26,8 +26,8 @@
name = "selfCallMethod",
selfCall = true,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
documented = false)
public StarlarkInt selfCallMethod(String one, StarlarkInt two) {
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/ParamTypeConflict.java b/src/test/java/net/starlark/java/annot/processor/testsources/ParamTypeConflict.java
deleted file mode 100644
index 7fa25c7..0000000
--- a/src/test/java/net/starlark/java/annot/processor/testsources/ParamTypeConflict.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package net.starlark.java.annot.processor.testsources;
-
-import net.starlark.java.annot.Param;
-import net.starlark.java.annot.ParamType;
-import net.starlark.java.annot.StarlarkMethod;
-import net.starlark.java.eval.StarlarkValue;
-
-/**
- * Test case for a StarlarkMethod method which has a parameter with both type and allowedTypes
- * specified.
- */
-public class ParamTypeConflict implements StarlarkValue {
-
- @StarlarkMethod(
- name = "param_type_conflict",
- documented = false,
- parameters = {
- @Param(
- name = "a_parameter",
- type = String.class,
- named = true,
- allowedTypes = {
- @ParamType(type = String.class),
- })
- })
- public Integer paramTypeConflict(String x) {
- return 42;
- }
-}
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/SpecifiedGenericType.java b/src/test/java/net/starlark/java/annot/processor/testsources/SpecifiedGenericType.java
index b25aa8f..286b60e 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/SpecifiedGenericType.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/SpecifiedGenericType.java
@@ -30,7 +30,7 @@
name = "specified_generic_type",
documented = false,
parameters = {
- @Param(name = "one", type = Sequence.class, named = true),
+ @Param(name = "one", named = true),
})
public String specifiedGenericType(Sequence<String> one) {
return "bar";
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkInfoBeforeParams.java b/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkInfoBeforeParams.java
index fb28b66..eee5838 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkInfoBeforeParams.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkInfoBeforeParams.java
@@ -29,9 +29,9 @@
name = "skylark_info_wrong_order",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
- @Param(name = "three", type = String.class, named = true)
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
+ @Param(name = "three", named = true)
},
useStarlarkThread = true)
public String threeArgMethod(StarlarkThread thread, String one, StarlarkInt two, String three) {
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkThreadMissing.java b/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkThreadMissing.java
index 6b1a1f1..b987277 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkThreadMissing.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/StarlarkThreadMissing.java
@@ -29,8 +29,8 @@
name = "three_arg_method_missing_env",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
useStarlarkThread = true)
public String threeArgMethod(String one, StarlarkInt two, String shouldBeThread) {
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/StructFieldWithArguments.java b/src/test/java/net/starlark/java/annot/processor/testsources/StructFieldWithArguments.java
index 5b563f8..74d9444 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/StructFieldWithArguments.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/StructFieldWithArguments.java
@@ -24,7 +24,7 @@
@StarlarkMethod(
name = "struct_field_method",
parameters = {
- @Param(name = "foo", type = String.class, named = true),
+ @Param(name = "foo", named = true),
},
structField = true,
doc = "A private method")
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/ToggledKwargsParam.java b/src/test/java/net/starlark/java/annot/processor/testsources/ToggledKwargsParam.java
index 1f57f8d..c05f6de 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/ToggledKwargsParam.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/ToggledKwargsParam.java
@@ -34,8 +34,8 @@
name = "toggled_kwargs_method",
documented = false,
parameters = {
- @Param(name = "one", type = String.class, named = true),
- @Param(name = "two", type = StarlarkInt.class, named = true),
+ @Param(name = "one", named = true),
+ @Param(name = "two", named = true),
},
extraPositionals = @Param(name = "args"),
extraKeywords = @Param(name = "kwargs", enableOnlyWithFlag = FOO),
diff --git a/src/test/java/net/starlark/java/annot/processor/testsources/TooManyArguments.java b/src/test/java/net/starlark/java/annot/processor/testsources/TooManyArguments.java
index 9021811..f79286e 100644
--- a/src/test/java/net/starlark/java/annot/processor/testsources/TooManyArguments.java
+++ b/src/test/java/net/starlark/java/annot/processor/testsources/TooManyArguments.java
@@ -28,7 +28,7 @@
name = "method_with_too_many_arguments",
documented = false,
parameters = {
- @Param(name = "parameter_one", type = String.class, named = true),
+ @Param(name = "parameter_one", named = true),
})
public String methodWithTooManyArguments(String parameterOne, String parameterTwo) {
return "dolphin";
diff --git a/src/test/java/net/starlark/java/eval/Examples.java b/src/test/java/net/starlark/java/eval/Examples.java
index f098a29..00a5cac 100644
--- a/src/test/java/net/starlark/java/eval/Examples.java
+++ b/src/test/java/net/starlark/java/eval/Examples.java
@@ -123,10 +123,10 @@
static final class MyFunctions {
@StarlarkMethod(
name = "square",
- parameters = {@Param(name = "x", type = int.class)},
+ parameters = {@Param(name = "x")},
doc = "Returns the square of its integer argument.")
- public int square(int x) {
- return x * x;
+ public StarlarkInt square(StarlarkInt x) {
+ return StarlarkInt.multiply(x, x);
}
}
}
diff --git a/src/test/java/net/starlark/java/eval/ScriptTest.java b/src/test/java/net/starlark/java/eval/ScriptTest.java
index 0cce2e6..03584ae 100644
--- a/src/test/java/net/starlark/java/eval/ScriptTest.java
+++ b/src/test/java/net/starlark/java/eval/ScriptTest.java
@@ -62,7 +62,7 @@
name = "assert_",
documented = false,
parameters = {
- @Param(name = "cond", noneable = true),
+ @Param(name = "cond"),
@Param(name = "msg", defaultValue = "'assertion failed'"),
},
useStarlarkThread = true)
@@ -78,12 +78,11 @@
name = "assert_eq",
documented = false,
parameters = {
- @Param(name = "x", noneable = true),
- @Param(name = "y", noneable = true),
+ @Param(name = "x"),
+ @Param(name = "y"),
},
useStarlarkThread = true)
public Object assertEq(Object x, Object y, StarlarkThread thread) throws EvalException {
- // TODO(adonovan): use Starlark.equals.
if (!x.equals(y)) {
String msg = String.format("assert_eq: %s != %s", Starlark.repr(x), Starlark.repr(y));
thread.getThreadLocal(Reporter.class).reportError(thread, msg);
diff --git a/src/test/java/net/starlark/java/eval/StarlarkEvaluationTest.java b/src/test/java/net/starlark/java/eval/StarlarkEvaluationTest.java
index b5f5ccf..59d39f7 100644
--- a/src/test/java/net/starlark/java/eval/StarlarkEvaluationTest.java
+++ b/src/test/java/net/starlark/java/eval/StarlarkEvaluationTest.java
@@ -122,7 +122,7 @@
selfCall = true,
documented = false,
parameters = {
- @Param(name = "pos", positional = true, type = String.class),
+ @Param(name = "pos", positional = true),
})
public String selfCall(String myName) {
return "I'm a mock named " + myName;
@@ -130,7 +130,7 @@
@StarlarkMethod(
name = "value_of",
- parameters = {@Param(name = "str", type = String.class)},
+ parameters = {@Param(name = "str")},
documented = false)
public Integer valueOf(String str) {
return Integer.valueOf(str);
@@ -138,7 +138,7 @@
@StarlarkMethod(
name = "is_empty",
- parameters = {@Param(name = "str", type = String.class)},
+ parameters = {@Param(name = "str")},
documented = false)
public Boolean isEmpty(String str) {
return str.isEmpty();
@@ -185,8 +185,8 @@
@StarlarkMethod(
name = "nullfunc_failing",
parameters = {
- @Param(name = "p1", type = String.class),
- @Param(name = "p2", type = StarlarkInt.class),
+ @Param(name = "p1"),
+ @Param(name = "p2"),
},
documented = false,
allowReturnNones = false)
@@ -222,31 +222,18 @@
documented = false,
parameters = {
@Param(name = "pos1"),
- @Param(name = "pos2", defaultValue = "False", type = Boolean.class),
- @Param(
- name = "posOrNamed",
- defaultValue = "False",
- type = Boolean.class,
- positional = true,
- named = true),
- @Param(name = "named", type = Boolean.class, positional = false, named = true),
- @Param(
- name = "optionalNamed",
- type = Boolean.class,
- defaultValue = "False",
- positional = false,
- named = true),
- @Param(
- name = "acceptsAny",
- type = Object.class,
- defaultValue = "\"a\"",
- positional = false,
- named = true),
+ @Param(name = "pos2", defaultValue = "False"),
+ @Param(name = "posOrNamed", defaultValue = "False", positional = true, named = true),
+ @Param(name = "named", positional = false, named = true),
+ @Param(name = "optionalNamed", defaultValue = "False", positional = false, named = true),
+ @Param(name = "acceptsAny", defaultValue = "'a'", positional = false, named = true),
@Param(
name = "noneable",
- type = StarlarkInt.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
- noneable = true,
positional = false,
named = true),
@Param(
@@ -255,9 +242,9 @@
@ParamType(type = String.class),
@ParamType(type = StarlarkInt.class),
@ParamType(type = Sequence.class, generic1 = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
},
defaultValue = "None",
- noneable = true,
positional = false,
named = true)
})
@@ -297,31 +284,18 @@
documented = false,
parameters = {
@Param(name = "pos1"),
- @Param(name = "pos2", defaultValue = "False", type = Boolean.class),
- @Param(
- name = "posOrNamed",
- defaultValue = "False",
- type = Boolean.class,
- positional = true,
- named = true),
- @Param(name = "named", type = Boolean.class, positional = false, named = true),
- @Param(
- name = "optionalNamed",
- type = Boolean.class,
- defaultValue = "False",
- positional = false,
- named = true),
- @Param(
- name = "acceptsAny",
- type = Object.class,
- defaultValue = "\"a\"",
- positional = false,
- named = true),
+ @Param(name = "pos2", defaultValue = "False"),
+ @Param(name = "posOrNamed", defaultValue = "False", positional = true, named = true),
+ @Param(name = "named", positional = false, named = true),
+ @Param(name = "optionalNamed", defaultValue = "False", positional = false, named = true),
+ @Param(name = "acceptsAny", defaultValue = "'a'", positional = false, named = true),
@Param(
name = "noneable",
- type = StarlarkInt.class,
+ allowedTypes = {
+ @ParamType(type = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
+ },
defaultValue = "None",
- noneable = true,
positional = false,
named = true),
@Param(
@@ -330,9 +304,9 @@
@ParamType(type = String.class),
@ParamType(type = StarlarkInt.class),
@ParamType(type = Sequence.class, generic1 = StarlarkInt.class),
+ @ParamType(type = NoneType.class),
},
defaultValue = "None",
- noneable = true,
positional = false,
named = true)
},
@@ -388,9 +362,9 @@
name = "with_args_and_thread",
documented = false,
parameters = {
- @Param(name = "pos1", type = StarlarkInt.class),
- @Param(name = "pos2", defaultValue = "False", type = Boolean.class),
- @Param(name = "named", type = Boolean.class, positional = false, named = true),
+ @Param(name = "pos1"),
+ @Param(name = "pos2", defaultValue = "False"),
+ @Param(name = "named", positional = false, named = true),
},
extraPositionals = @Param(name = "args"),
useStarlarkThread = true)
@@ -412,8 +386,8 @@
name = "with_kwargs",
documented = false,
parameters = {
- @Param(name = "pos", defaultValue = "False", type = Boolean.class),
- @Param(name = "named", type = Boolean.class, positional = false, named = true),
+ @Param(name = "pos", defaultValue = "False"),
+ @Param(name = "named", positional = false, named = true),
},
extraKeywords = @Param(name = "kwargs"))
public String withKwargs(boolean pos, boolean named, Dict<String, Object> kwargs) {
@@ -432,7 +406,7 @@
name = "with_args_and_kwargs",
documented = false,
parameters = {
- @Param(name = "foo", named = true, positional = true, type = String.class),
+ @Param(name = "foo", named = true, positional = true),
},
extraPositionals = @Param(name = "args"),
extraKeywords = @Param(name = "kwargs"))
@@ -475,7 +449,7 @@
static interface MockInterface extends StarlarkValue {
@StarlarkMethod(
name = "is_empty_interface",
- parameters = {@Param(name = "str", type = String.class)},
+ parameters = {@Param(name = "str")},
documented = false)
public Boolean isEmptyInterface(String str);
}
@@ -498,7 +472,7 @@
name = "method",
documented = false,
parameters = {
- @Param(name = "foo", named = true, positional = true, type = Object.class),
+ @Param(name = "foo", named = true, positional = true),
})
public ObjectT method(ObjectT o);
}
diff --git a/src/test/java/net/starlark/java/eval/StarlarkFlagGuardingTest.java b/src/test/java/net/starlark/java/eval/StarlarkFlagGuardingTest.java
index 3e4c4bd..7747422 100644
--- a/src/test/java/net/starlark/java/eval/StarlarkFlagGuardingTest.java
+++ b/src/test/java/net/starlark/java/eval/StarlarkFlagGuardingTest.java
@@ -54,15 +54,14 @@
name = "positionals_only_method",
documented = false,
parameters = {
- @Param(name = "a", positional = true, named = false, type = StarlarkInt.class),
+ @Param(name = "a", positional = true, named = false),
@Param(
name = "b",
positional = true,
named = false,
- type = Boolean.class,
enableOnlyWithFlag = EXPERIMENTAL_FLAG,
valueWhenDisabled = "False"),
- @Param(name = "c", positional = true, named = false, type = StarlarkInt.class),
+ @Param(name = "c", positional = true, named = false),
},
useStarlarkThread = true)
public String positionalsOnlyMethod(
@@ -74,15 +73,14 @@
name = "keywords_only_method",
documented = false,
parameters = {
- @Param(name = "a", positional = false, named = true, type = StarlarkInt.class),
+ @Param(name = "a", positional = false, named = true),
@Param(
name = "b",
positional = false,
named = true,
- type = Boolean.class,
enableOnlyWithFlag = EXPERIMENTAL_FLAG,
valueWhenDisabled = "False"),
- @Param(name = "c", positional = false, named = true, type = StarlarkInt.class),
+ @Param(name = "c", positional = false, named = true),
},
useStarlarkThread = true)
public String keywordsOnlyMethod(
@@ -94,22 +92,20 @@
name = "mixed_params_method",
documented = false,
parameters = {
- @Param(name = "a", positional = true, named = false, type = StarlarkInt.class),
+ @Param(name = "a", positional = true, named = false),
@Param(
name = "b",
positional = true,
named = false,
- type = Boolean.class,
enableOnlyWithFlag = EXPERIMENTAL_FLAG,
valueWhenDisabled = "False"),
@Param(
name = "c",
positional = false,
named = true,
- type = StarlarkInt.class,
enableOnlyWithFlag = EXPERIMENTAL_FLAG,
valueWhenDisabled = "3"),
- @Param(name = "d", positional = false, named = true, type = Boolean.class),
+ @Param(name = "d", positional = false, named = true),
},
useStarlarkThread = true)
public String mixedParamsMethod(
@@ -121,19 +117,17 @@
name = "keywords_multiple_flags",
documented = false,
parameters = {
- @Param(name = "a", positional = false, named = true, type = StarlarkInt.class),
+ @Param(name = "a", positional = false, named = true),
@Param(
name = "b",
positional = false,
named = true,
- type = Boolean.class,
disableWithFlag = FLAG2,
valueWhenDisabled = "False"),
@Param(
name = "c",
positional = false,
named = true,
- type = StarlarkInt.class,
enableOnlyWithFlag = FLAG1,
valueWhenDisabled = "3"),
},
diff --git a/src/test/java/net/starlark/java/eval/testdata/int_constructor.sky b/src/test/java/net/starlark/java/eval/testdata/int_constructor.sky
index 2ca2584..fd64fc6 100644
--- a/src/test/java/net/starlark/java/eval/testdata/int_constructor.sky
+++ b/src/test/java/net/starlark/java/eval/testdata/int_constructor.sky
@@ -78,7 +78,7 @@
---
int('123', 37) ### invalid base 37 \(want 2 <= base <= 36\)
---
-int('123', 'x') ### parameter 'base' got value of type 'string', want 'int'
+int('123', 'x') ### got string for base, want int
---
int(True, 2) ### can't convert non-string with explicit base
---