Rename SkylarkMutable to StarlarkMutable
RELNOTES: None.
PiperOrigin-RevId: 253111275
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
index df30e48..6db9a89 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
@@ -65,8 +65,8 @@
import com.google.devtools.build.lib.syntax.Runtime;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
-import com.google.devtools.build.lib.syntax.SkylarkMutable;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
+import com.google.devtools.build.lib.syntax.StarlarkMutable;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.protobuf.GeneratedMessage;
@@ -620,7 +620,7 @@
/** Args module. */
@VisibleForTesting
- public static class Args extends SkylarkMutable implements CommandLineArgsApi {
+ public static class Args extends StarlarkMutable implements CommandLineArgsApi {
private final Mutability mutability;
private final StarlarkSemantics starlarkSemantics;
private final SkylarkCustomCommandLine.Builder commandLine;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
index 3558a4b..cfec3cd 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
@@ -389,14 +389,14 @@
}
public static void lock(Object object, Location loc) {
- if (object instanceof SkylarkMutable) {
- ((SkylarkMutable) object).lock(loc);
+ if (object instanceof StarlarkMutable) {
+ ((StarlarkMutable) object).lock(loc);
}
}
public static void unlock(Object object, Location loc) {
- if (object instanceof SkylarkMutable) {
- ((SkylarkMutable) object).unlock(loc);
+ if (object instanceof StarlarkMutable) {
+ ((StarlarkMutable) object).unlock(loc);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java b/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java
index a6554e6..3ae49a2 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Mutability.java
@@ -27,7 +27,7 @@
* Collectively, the managed objects are called {@link Freezable}s.
*
* <p>Each {@code Environment}, and each of the mutable Skylark values (i.e., {@link
- * SkylarkMutable}s) that are created in that {@code Environment}, holds a pointer to the same
+ * StarlarkMutable}s) that are created in that {@code Environment}, holds a pointer to the same
* {@code Mutability} instance. Once the {@code Environment} is done evaluating, its {@code
* Mutability} is irreversibly closed ("frozen"). At that point, it is no longer possible to change
* either the bindings in that {@code Environment} or the state of its objects. This protects each
@@ -53,11 +53,13 @@
*
* <p>We follow two disciplines to ensure safety. First, all mutation methods of a {@code Freezable}
* must take in a {@code Mutability} as a parameter, and confirm that
+ *
* <ol>
* <li>the {@code Freezable} is not yet frozen,
* <li>the given {@code Mutability} matches the one referred to by the {@code Freezable}, and
* <li>the {@code Freezable} is not locked.
* </ol>
+ *
* It is a high-level error ({@link MutabilityException}, which gets translated to {@link
* EvalException}) to attempt to modify a frozen or locked value. But it is a low-level error
* ({@link IllegalArgumentException}) to attempt to modify a value using the wrong {@link
@@ -65,9 +67,11 @@
* circumstances.
*
* <p>Second, {@code Mutability}s are created using the try-with-resource style:
+ *
* <pre>{@code
* try (Mutability mutability = Mutability.create(fmt, ...)) { ... }
* }</pre>
+ *
* The general pattern is to create a {@code Mutability}, build an {@code Environment}, mutate that
* {@code Environment} and its objects, and possibly return the result from within the {@code try}
* block, relying on the try-with-resource construct to ensure that everything gets frozen before
@@ -76,6 +80,7 @@
*
* <p>We keep some (unchecked) invariants regarding where {@code Mutability} objects may appear
* within a compound value.
+ *
* <ol>
* <li>A compound value can never contain an unfrozen {@code Mutability} for any {@code
* Environment} except the one currently being evaluated.
@@ -84,10 +89,11 @@
* <li>If a value has the special {@link #SHALLOW_IMMUTABLE} {@code Mutability}, its contents may
* or may not be mutable.
* </ol>
+ *
* It follows that, if these invariants hold, an unfrozen value cannot appear as the child of a
* value whose {@code Mutability} is already frozen, unless this {@code Mutability} is the special
- * {@code #SHALLOW_IMMUTABLE} instance. This knowledge is used by {@link SkylarkMutable#isImmutable}
- * to prune traversals of a compound value.
+ * {@code #SHALLOW_IMMUTABLE} instance. This knowledge is used by {@link
+ * StarlarkMutable#isImmutable} to prune traversals of a compound value.
*
* <p>There is a special API for freezing individual values rather than whole {@code Environment}s.
* Because this API makes it easier to violate the above invariants, you should avoid using it if at
@@ -306,8 +312,8 @@
* <p>It is up to the caller to ensure that any contents of this {@code Freezable} are also
* frozen in order to preserve/restore the invariant that an immutable value cannot contain a
* mutable one unless the immutable value's {@code Mutability} is {@link #SHALLOW_IMMUTABLE}.
- * Note that {@link SkylarkMutable#isImmutable} correctness and thread-safety are not guaranteed
- * otherwise.
+ * Note that {@link StarlarkMutable#isImmutable} correctness and thread-safety are not
+ * guaranteed otherwise.
*/
default void unsafeShallowFreeze() {
throw new UnsupportedOperationException();
@@ -393,6 +399,6 @@
// for values whose Environments have been frozen.
//
// This would also affect structs (SkylarkInfo). Maybe they would implement an interface similar
- // to SkylarkMutable, or the relevant methods could be worked into SkylarkValue.
+ // to StarlarkMutable, or the relevant methods could be worked into SkylarkValue.
public static final Mutability SHALLOW_IMMUTABLE = create("SHALLOW_IMMUTABLE").freeze();
}
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java
index d396ff4..0b4c7f3 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkDict.java
@@ -25,7 +25,7 @@
import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
import com.google.devtools.build.lib.syntax.SkylarkList.MutableList;
import com.google.devtools.build.lib.syntax.SkylarkList.Tuple;
-import com.google.devtools.build.lib.syntax.SkylarkMutable.MutableMap;
+import com.google.devtools.build.lib.syntax.StarlarkMutable.MutableMap;
import com.google.devtools.build.lib.syntax.Type.ConversionException;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java
index 0ef4e28..85ee536 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkList.java
@@ -25,7 +25,7 @@
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
-import com.google.devtools.build.lib.syntax.SkylarkMutable.BaseMutableList;
+import com.google.devtools.build.lib.syntax.StarlarkMutable.BaseMutableList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -646,7 +646,7 @@
}
// Overridden to recurse over children, since tuples use SHALLOW_IMMUTABLE and other
- // SkylarkMutable subclasses do not.
+ // StarlarkMutable subclasses do not.
@Override
public boolean isImmutable() {
for (Object item : this) {
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkMutable.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkMutable.java
similarity index 94%
rename from src/main/java/com/google/devtools/build/lib/syntax/SkylarkMutable.java
rename to src/main/java/com/google/devtools/build/lib/syntax/StarlarkMutable.java
index 3532bfb..5852f35 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkMutable.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkMutable.java
@@ -31,7 +31,7 @@
/**
* Base class for data structures that are only mutable using a proper, unfrozen {@link Mutability}.
*/
-public abstract class SkylarkMutable implements Freezable, SkylarkValue {
+public abstract class StarlarkMutable implements Freezable, SkylarkValue {
/**
* Checks whether this object is currently mutable in the given {@link Environment}, and throws
@@ -84,9 +84,9 @@
}
/**
- * Base class for a {@link SkylarkMutable} that implements a Java Collections Framework interface.
- * All of the interface's accessors should be supported, while its mutating methods must be
- * disallowed.
+ * Base class for a {@link StarlarkMutable} that implements a Java Collections Framework
+ * interface. All of the interface's accessors should be supported, while its mutating methods
+ * must be disallowed.
*
* <p>Think of this as similar to {@link Collections#unmodifiableList}, etc., except that it's an
* extendable class rather than a method.
@@ -108,7 +108,7 @@
* <p>Subclasses need not overwrite the default methods added to some data structures in Java 8.
* since these are defined in terms of the non-default methods.
*/
- abstract static class BaseMutableWrapper extends SkylarkMutable {
+ abstract static class BaseMutableWrapper extends StarlarkMutable {
/**
* The underlying contents, to which read access is forwarded. This object must not be modified
@@ -127,7 +127,7 @@
}
}
- /** Base class for a {@link SkylarkMutable} that is also a {@link Collection}. */
+ /** Base class for a {@link StarlarkMutable} that is also a {@link Collection}. */
abstract static class MutableCollection<E> extends BaseMutableWrapper implements Collection<E> {
@Override
@@ -210,7 +210,7 @@
}
}
- /** Base class for a {@link SkylarkMutable} that is also a {@link List}. */
+ /** Base class for a {@link StarlarkMutable} that is also a {@link List}. */
abstract static class BaseMutableList<E> extends MutableCollection<E> implements List<E> {
@Override
@@ -275,7 +275,7 @@
}
}
- /** Base class for a {@link SkylarkMutable} that is also a {@link Map}. */
+ /** Base class for a {@link StarlarkMutable} that is also a {@link Map}. */
abstract static class MutableMap<K, V> extends BaseMutableWrapper implements Map<K, V> {
@Override
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkMutableTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkMutableTest.java
index add2e71..46dc09b 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkMutableTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkMutableTest.java
@@ -26,7 +26,7 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/** Tests for {@link SkylarkMutable}. */
+/** Tests for {@link StarlarkMutable}. */
@RunWith(JUnit4.class)
public final class SkylarkMutableTest {