Create ValidationEnvironment from Environment
Allow ValidationEnvironment to be created from initial Environment so that
there is no need to manually keep two different sets of constructors in synch.
--
MOS_MIGRATED_REVID=101588695
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
index 5357d4d..3acbec1 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
@@ -101,6 +101,15 @@
protected Set<String> propagatingVariables = new HashSet<>();
/**
+ * Is this a global environment?
+ * @return true if this is a global (top-level) environment
+ * as opposed to inside the body of a function
+ */
+ public boolean isGlobal() {
+ return true;
+ }
+
+ /**
* An EventHandler for errors and warnings. This is not used in the BUILD language,
* however it might be used in Skylark code called from the BUILD language.
*/
@@ -191,9 +200,10 @@
* Updates the value of variable "varname" in the environment, corresponding
* to an {@link AssignmentStatement}.
*/
- public void update(String varname, Object value) {
+ public Environment update(String varname, Object value) {
Preconditions.checkNotNull(value, "update(value == null)");
env.put(varname, value);
+ return this;
}
/**