bazel syntax: abolish Environment.StarlarkContext
The bulk of this change eliminates parameters of type
StarlarkContext in annotated methods, replacing them
by Environment parameters if not already present.
From the Environment, the BazelStarlarkContext can
be retrieved using getThreadLocal.
The only interesting parts are:
Environment: delete {get,set}StarlarkContext;
use {get,set}ThreadLocal instead.
Also, sprinkle 'private' keywords.
Label: store the HasRepoMapping as a thread-local.
Its value is an alias for the BazelStarlarkContext, but
we can't mention that type down here.
BazelStarlarkContext: define and use BSC.from(Environment),
which loads the Bazel info from a Starlark thread,
and BSC.storeInThread(Environment), which stores it,
plus the Label.RepoMapping, so we don't forget it.
ConfiguredRuleClassProvider: inline one flavor of
createSkylarkRuleClassEnvironment into the other.
PiperOrigin-RevId: 271039685
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
index 9b197c6..dfa82d5 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
@@ -35,7 +35,6 @@
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkSignature;
import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
-import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
import com.google.devtools.build.lib.syntax.SkylarkList.MutableList;
import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;
import com.google.devtools.build.lib.testutil.TestMode;
@@ -316,14 +315,9 @@
useLocation = true,
useAst = true,
useEnvironment = true,
- useStarlarkSemantics = true,
- useContext = true)
+ useStarlarkSemantics = true)
public String withExtraInterpreterParams(
- Location location,
- FuncallExpression func,
- Environment env,
- StarlarkSemantics sem,
- StarlarkContext context) {
+ Location location, FuncallExpression func, Environment env, StarlarkSemantics sem) {
return "with_extra("
+ location.getStartLine()
+ ", "
@@ -332,8 +326,6 @@
+ env.isGlobal()
+ ", "
+ (sem != null)
- + ", "
- + (context != null)
+ ")";
}
@@ -1319,7 +1311,7 @@
new SkylarkTest()
.update("mock", new Mock())
.setUp("v = mock.with_extra()")
- .testLookup("v", "with_extra(1, 0, true, true, true)");
+ .testLookup("v", "with_extra(1, 0, true, true)");
}
@Test