bazel syntax: remove Location from calling convention
This change removes the Location parameter from StarlarkCallable.call
(built-in functions) and the SkylarkCallable.useLocation feature from
annotated built-in functions.
Lately, the thread's call stack records the position of the program
counter of each active frame, so clients may access it through
StarlarkThread.getCallerLocation.
Numerous parameters that pass Locations merely to construct an
EvalException have been deleted. (This is the bulk of the change.)
Many places that directly constructed an EvalException now call
Starlark.errorf instead. (A few places in Bazel formerly specified a
location other than thread.getCallerLocation, or equivalently, null.)
The evaluator ensures that any exception thrown by Starlark.call
is augmented with the location of the call.
PiperOrigin-RevId: 291009378
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
index 8a134cc..eb292c5 100644
--- a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
+++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkRuleContextApi.java
@@ -16,7 +16,6 @@
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.skylarkbuildapi.core.ProviderApi;
import com.google.devtools.build.lib.skylarkbuildapi.core.StructApi;
import com.google.devtools.build.lib.skylarkbuildapi.core.TransitiveInfoCollectionApi;
@@ -422,9 +421,8 @@
},
defaultValue = "unbound",
doc = "")
- },
- useLocation = true)
- FileApi newFile(Object var1, Object var2, Object var3, Location loc) throws EvalException;
+ })
+ FileApi newFile(Object var1, Object var2, Object var3) throws EvalException;
@SkylarkCallable(
name = "experimental_new_directory",
@@ -669,7 +667,6 @@
+ "they are typically generated by resolve_command.")
},
allowReturnNones = true,
- useLocation = true,
useStarlarkThread = true)
NoneType action(
Sequence<?> outputs,
@@ -684,7 +681,6 @@
Object envUnchecked,
Object executionRequirementsUnchecked,
Object inputManifestsUnchecked,
- Location loc,
StarlarkThread thread)
throws EvalException;
@@ -717,9 +713,8 @@
doc = "List of targets for additional lookup information."),
},
allowReturnNones = true,
- useLocation = true,
useStarlarkThread = true)
- String expandLocation(String input, Sequence<?> targets, Location loc, StarlarkThread thread)
+ String expandLocation(String input, Sequence<?> targets, StarlarkThread thread)
throws EvalException;
@SkylarkCallable(
@@ -742,10 +737,8 @@
doc = "Whether the output file should be executable (default is False).")
},
allowReturnNones = true,
- useLocation = true,
useStarlarkThread = true)
- NoneType fileAction(
- FileApi output, String content, Boolean executable, Location loc, StarlarkThread thread)
+ NoneType fileAction(FileApi output, String content, Boolean executable, StarlarkThread thread)
throws EvalException;
@SkylarkCallable(
@@ -775,10 +768,8 @@
doc = "List of the input files of the action."),
},
allowReturnNones = true,
- useLocation = true,
useStarlarkThread = true)
- NoneType emptyAction(String mnemonic, Object inputs, Location loc, StarlarkThread thread)
- throws EvalException;
+ NoneType emptyAction(String mnemonic, Object inputs, StarlarkThread thread) throws EvalException;
@SkylarkCallable(
name = "template_action",
@@ -814,14 +805,12 @@
doc = "Whether the output file should be executable (default is False).")
},
allowReturnNones = true,
- useLocation = true,
useStarlarkThread = true)
NoneType templateAction(
FileApi template,
FileApi output,
Dict<?, ?> substitutionsUnchecked,
Boolean executable,
- Location loc,
StarlarkThread thread)
throws EvalException;
@@ -882,16 +871,14 @@
defaultValue = "{}",
named = true,
doc = "The map of symlinks to be added to the runfiles.")
- },
- useLocation = true)
+ })
RunfilesApi runfiles(
Sequence<?> files,
Object transitiveFiles,
Boolean collectData,
Boolean collectDefault,
Dict<?, ?> symlinks,
- Dict<?, ?> rootSymlinks,
- Location loc)
+ Dict<?, ?> rootSymlinks)
throws EvalException;
@SkylarkCallable(
@@ -966,7 +953,6 @@
+ "<a href=\"$BE_ROOT/common-definitions.html#common.tags\">tags</a> "
+ "for useful keys."),
},
- useLocation = true,
useStarlarkThread = true)
Tuple<Object> resolveCommand(
String command,
@@ -976,7 +962,6 @@
Sequence<?> tools,
Dict<?, ?> labelDictUnchecked,
Dict<?, ?> executionRequirementsUnchecked,
- Location loc,
StarlarkThread thread)
throws EvalException;
@@ -998,8 +983,6 @@
named = true,
positional = false,
doc = "List of tools (list of targets)."),
- },
- useLocation = false,
- useStarlarkThread = false)
+ })
Tuple<Object> resolveTools(Sequence<?> tools) throws EvalException;
}