bazel syntax: rename BuildFileAST -> StarlarkFile

This change was 100% mechanical, thanks to the distinctive name.
We do not attempt to rename local variables.

Another breaking API change for copybara.

PiperOrigin-RevId: 271351606
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AstParseResult.java b/src/main/java/com/google/devtools/build/lib/packages/AstParseResult.java
index 08d6bb2..fc0cd9b 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AstParseResult.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AstParseResult.java
@@ -16,15 +16,15 @@
 import com.google.devtools.build.lib.events.Event;
 import com.google.devtools.build.lib.events.ExtendedEventHandler.Postable;
 import com.google.devtools.build.lib.events.StoredEventHandler;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 
 /** The result of parsing a BUILD file. */
 public class AstParseResult {
-  public final BuildFileAST ast;
+  public final StarlarkFile ast;
   public final Iterable<Event> allEvents;
   public final Iterable<Postable> allPosts;
 
-  public AstParseResult(BuildFileAST ast, StoredEventHandler astParsingEventHandler) {
+  public AstParseResult(StarlarkFile ast, StoredEventHandler astParsingEventHandler) {
     this.ast = ast;
     this.allPosts = astParsingEventHandler.getPosts();
     this.allEvents = astParsingEventHandler.getEvents();
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
index 56124b8..3ea6144 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
@@ -43,7 +43,6 @@
 import com.google.devtools.build.lib.skylarkinterface.SkylarkValue;
 import com.google.devtools.build.lib.syntax.Argument;
 import com.google.devtools.build.lib.syntax.BaseFunction;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.BuiltinFunction;
 import com.google.devtools.build.lib.syntax.CallUtils;
 import com.google.devtools.build.lib.syntax.ClassObject;
@@ -69,6 +68,7 @@
 import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor;
 import com.google.devtools.build.lib.syntax.SkylarkUtils;
 import com.google.devtools.build.lib.syntax.SkylarkUtils.Phase;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
@@ -1373,12 +1373,8 @@
     StoredEventHandler localReporterForParsing = new StoredEventHandler();
     // Run the lexer and parser with a local reporter, so that errors from other threads do not
     // show up below.
-    BuildFileAST buildFileAST =
-        parseBuildFile(
-            packageId,
-            input,
-            preludeStatements,
-            localReporterForParsing);
+    StarlarkFile buildFileAST =
+        parseBuildFile(packageId, input, preludeStatements, localReporterForParsing);
     AstParseResult astParseResult =
         new AstParseResult(buildFileAST, localReporterForParsing);
     return createPackageFromAst(
@@ -1394,15 +1390,15 @@
         globber);
   }
 
-  public static BuildFileAST parseBuildFile(
+  public static StarlarkFile parseBuildFile(
       PackageIdentifier packageId,
       ParserInput input,
       List<Statement> preludeStatements,
       ExtendedEventHandler eventHandler) {
     // Logged messages are used as a testability hook tracing the parsing progress
     logger.fine("Starting to parse " + packageId);
-    BuildFileAST buildFileAST =
-        BuildFileAST.parseWithPrelude(input, preludeStatements, eventHandler);
+    StarlarkFile buildFileAST =
+        StarlarkFile.parseWithPrelude(input, preludeStatements, eventHandler);
     logger.fine("Finished parsing of " + packageId);
     return buildFileAST;
   }
@@ -1722,7 +1718,7 @@
   public Package.Builder evaluateBuildFile(
       String workspaceName,
       PackageIdentifier packageId,
-      BuildFileAST file,
+      StarlarkFile file,
       RootedPath buildFilePath,
       Globber globber,
       Iterable<Event> pastEvents,
@@ -1925,7 +1921,7 @@
   // files.
   // TODO(adonovan): this is the ideal place to extract string literals from glob calls for
   // prefetching. Combine.
-  public static boolean checkBuildSyntax(BuildFileAST file, final EventHandler eventHandler) {
+  public static boolean checkBuildSyntax(StarlarkFile file, final EventHandler eventHandler) {
     final boolean[] success = {true};
     NodeVisitor checker =
         new NodeVisitor() {
diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java
index 230abe9..dc59b49 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java
@@ -29,7 +29,6 @@
 import com.google.devtools.build.lib.packages.Package.NameConflictException;
 import com.google.devtools.build.lib.packages.PackageFactory.EnvironmentExtension;
 import com.google.devtools.build.lib.syntax.BaseFunction;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.BuiltinFunction;
 import com.google.devtools.build.lib.syntax.CallUtils;
 import com.google.devtools.build.lib.syntax.ClassObject;
@@ -41,6 +40,7 @@
 import com.google.devtools.build.lib.syntax.Runtime;
 import com.google.devtools.build.lib.syntax.SkylarkUtils;
 import com.google.devtools.build.lib.syntax.SkylarkUtils.Phase;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
@@ -134,7 +134,7 @@
     if (localReporter == null) {
       localReporter = new StoredEventHandler();
     }
-    BuildFileAST buildFileAST = BuildFileAST.parse(source, localReporter);
+    StarlarkFile buildFileAST = StarlarkFile.parse(source, localReporter);
     if (buildFileAST.containsErrors()) {
       throw new BuildFileContainsErrorsException(
           LabelConstants.EXTERNAL_PACKAGE_IDENTIFIER, "Failed to parse " + source.getPath());
@@ -153,7 +153,7 @@
    * the //external package.
    */
   public void execute(
-      BuildFileAST file,
+      StarlarkFile file,
       Map<String, Extension> importedExtensions,
       StarlarkSemantics starlarkSemantics,
       WorkspaceFileValue.WorkspaceFileKey workspaceFileKey)
@@ -165,7 +165,7 @@
   }
 
   private void execute(
-      BuildFileAST file,
+      StarlarkFile file,
       @Nullable Map<String, Extension> importedExtensions,
       StarlarkSemantics starlarkSemantics,
       StoredEventHandler localReporter,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/ResolvedFileFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/ResolvedFileFunction.java
index f2e2f8f..ec711e8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/repository/ResolvedFileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/ResolvedFileFunction.java
@@ -23,9 +23,9 @@
 import com.google.devtools.build.lib.packages.NoSuchThingException;
 import com.google.devtools.build.lib.rules.repository.ResolvedFileValue.ResolvedFileKey;
 import com.google.devtools.build.lib.skyframe.PrecomputedValue;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
@@ -63,8 +63,8 @@
         byte[] bytes =
             FileSystemUtils.readWithKnownFileSize(
                 key.getPath().asPath(), key.getPath().asPath().getFileSize());
-        BuildFileAST ast =
-            BuildFileAST.parse(
+        StarlarkFile ast =
+            StarlarkFile.parse(
                 ParserInput.create(bytes, key.getPath().asPath().asFragment()), env.getListener());
         if (ast.containsErrors()) {
           throw new ResolvedFileFunctionException(
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java
index d065bfd..5cb106c 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java
@@ -20,9 +20,9 @@
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.packages.BuildFileNotFoundException;
 import com.google.devtools.build.lib.packages.RuleClassProvider;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
@@ -41,10 +41,10 @@
 /**
  * A SkyFunction for {@link ASTFileLookupValue}s.
  *
- * <p> Given a {@link Label} referencing a Skylark file, loads it as a syntax tree
- * ({@link BuildFileAST}). The Label must be absolute, and must not reference the special
- * {@code external} package. If the file (or the package containing it) doesn't exist, the
- * function doesn't fail, but instead returns a specific {@code NO_FILE} {@link ASTFileLookupValue}.
+ * <p>Given a {@link Label} referencing a Skylark file, loads it as a syntax tree ({@link
+ * StarlarkFile}). The Label must be absolute, and must not reference the special {@code external}
+ * package. If the file (or the package containing it) doesn't exist, the function doesn't fail, but
+ * instead returns a specific {@code NO_FILE} {@link ASTFileLookupValue}.
  */
 public class ASTFileLookupFunction implements SkyFunction {
 
@@ -110,7 +110,7 @@
     }
 
     // Both the package and the file exist; load the file and parse it as an AST.
-    BuildFileAST file = null;
+    StarlarkFile file = null;
     Path path = rootedPath.asPath();
     try {
       long astFileSize = fileValue.getSize();
@@ -127,7 +127,7 @@
                 /*repoMapping=*/ ImmutableMap.of());
         byte[] bytes = FileSystemUtils.readWithKnownFileSize(path, astFileSize);
         ParserInput input = ParserInput.create(bytes, path.asFragment());
-        file = BuildFileAST.parseWithDigest(input, path.getDigest(), env.getListener());
+        file = StarlarkFile.parseWithDigest(input, path.getDigest(), env.getListener());
         file = file.validate(thread, /*isBuildFile=*/ false, env.getListener());
       }
     } catch (IOException e) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupValue.java
index 7f38607..7104882 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupValue.java
@@ -19,7 +19,7 @@
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.concurrent.BlazeInterners;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.skyframe.AbstractSkyKey;
 import com.google.devtools.build.skyframe.NotComparableSkyValue;
 import com.google.devtools.build.skyframe.SkyFunctionName;
@@ -33,23 +33,25 @@
 // almost certainly be unequal to the previous value. This is because of (i) the change-pruning
 // semantics of the PackageLookupValue dep and the FileValue dep; consider the latter: if the
 // FileValue for the bzl file has changed, then the contents of the bzl file probably changed and
-// (ii) we don't currently have skylark-semantic-equality in BuildFileAST, so two BuildFileAST
+// (ii) we don't currently have skylark-semantic-equality in StarlarkFile, so two StarlarkFile
 // instances representing two different contents of a bzl file will be different.
 // TODO(bazel-team): Consider doing better here. As a pre-req, we would need
-// skylark-semantic-equality in BuildFileAST, rather than equality naively based on the contents of
+// skylark-semantic-equality in StarlarkFile, rather than equality naively based on the contents of
 // the bzl file. For a concrete example, the contents of comment lines do not currently impact
 // skylark semantics.
 public abstract class ASTFileLookupValue implements NotComparableSkyValue {
   public abstract boolean lookupSuccessful();
-  public abstract BuildFileAST getAST();
+
+  public abstract StarlarkFile getAST();
+
   public abstract String getErrorMsg();
 
   /** If the file is found, this class encapsulates the parsed AST. */
   @AutoCodec.VisibleForSerialization
   public static class ASTLookupWithFile extends ASTFileLookupValue {
-    private final BuildFileAST ast;
+    private final StarlarkFile ast;
 
-    private ASTLookupWithFile(BuildFileAST ast) {
+    private ASTLookupWithFile(StarlarkFile ast) {
       Preconditions.checkNotNull(ast);
       this.ast = ast;
     }
@@ -60,7 +62,7 @@
     }
 
     @Override
-    public BuildFileAST getAST() {
+    public StarlarkFile getAST() {
       return this.ast;
     }
 
@@ -86,7 +88,7 @@
     }
 
     @Override
-    public BuildFileAST getAST() {
+    public StarlarkFile getAST() {
       throw new IllegalStateException("attempted to retrieve AST from an unsuccessful lookup");
     }
 
@@ -111,7 +113,7 @@
         String.format("Unable to load file '%s': it isn't a regular file", fileLabel));
   }
 
-  public static ASTFileLookupValue withFile(BuildFileAST ast) {
+  public static ASTFileLookupValue withFile(StarlarkFile ast) {
     return new ASTLookupWithFile(ast);
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
index dbbbf39..6b8ede8 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java
@@ -56,9 +56,9 @@
 import com.google.devtools.build.lib.skyframe.GlobValue.InvalidGlobPatternException;
 import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.SkylarkImportFailedException;
 import com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue.SkylarkImportLookupKey;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.ParserInput;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
 import com.google.devtools.build.lib.syntax.Statement;
@@ -548,7 +548,7 @@
       RootedPath buildFilePath,
       PackageIdentifier packageId,
       ImmutableMap<RepositoryName, RepositoryName> repoMapping,
-      BuildFileAST file,
+      StarlarkFile file,
       int workspaceChunk,
       Environment env,
       SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining)
@@ -1167,7 +1167,7 @@
         }
         input = ParserInput.create(buildFileBytes, inputFile.asFragment());
         StoredEventHandler astParsingEventHandler = new StoredEventHandler();
-        BuildFileAST ast =
+        StarlarkFile ast =
             PackageFactory.parseBuildFile(
                 packageId, input, preludeStatements, astParsingEventHandler);
         astParseResult = new AstParseResult(ast, astParsingEventHandler);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
index db9176f..b4d8881 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
@@ -44,11 +44,11 @@
 import com.google.devtools.build.lib.packages.WorkspaceFileValue;
 import com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue.SkylarkImportLookupKey;
 import com.google.devtools.build.lib.syntax.AssignmentStatement;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Identifier;
 import com.google.devtools.build.lib.syntax.LoadStatement;
 import com.google.devtools.build.lib.syntax.Mutability;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
@@ -319,7 +319,7 @@
       // Skylark import files have to exist.
       throw new SkylarkImportFailedException(astLookupValue.getErrorMsg());
     }
-    BuildFileAST file = astLookupValue.getAST();
+    StarlarkFile file = astLookupValue.getAST();
     if (file.containsErrors()) {
       throw SkylarkImportFailedException.skylarkErrors(filePath);
     }
@@ -443,7 +443,7 @@
   @Nullable
   static Map<String, Label> getLoadMap(
       EventHandler handler,
-      BuildFileAST file,
+      StarlarkFile file,
       PackageIdentifier base,
       ImmutableMap<RepositoryName, RepositoryName> repoMapping) {
     Preconditions.checkArgument(!base.getRepository().isDefault());
@@ -577,7 +577,7 @@
 
   /** Creates the Extension to be imported. */
   private Extension createExtension(
-      BuildFileAST ast,
+      StarlarkFile ast,
       Label extensionLabel,
       Map<String, Extension> importMap,
       StarlarkSemantics starlarkSemantics,
@@ -616,7 +616,7 @@
   }
 
   public static void execAndExport(
-      BuildFileAST ast,
+      StarlarkFile ast,
       Label extensionLabel,
       EventHandler eventHandler,
       StarlarkThread extensionThread)
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
index 55b14b4..e33ade1 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunction.java
@@ -27,10 +27,10 @@
 import com.google.devtools.build.lib.packages.RuleClassProvider;
 import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction;
 import com.google.devtools.build.lib.rules.repository.ResolvedFileValue;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.LoadStatement;
 import com.google.devtools.build.lib.syntax.ParserInput;
 import com.google.devtools.build.lib.syntax.Printer;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.Statement;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
 import com.google.devtools.build.lib.vfs.Path;
@@ -45,9 +45,7 @@
 import java.util.List;
 import java.util.Map;
 
-/**
- * A SkyFunction to parse WORKSPACE files into a BuildFileAST.
- */
+/** A SkyFunction to parse WORKSPACE files into a StarlarkFile. */
 public class WorkspaceASTFunction implements SkyFunction {
   private final RuleClassProvider ruleClassProvider;
 
@@ -81,8 +79,8 @@
 
     Path repoWorkspace = workspaceRoot.getRoot().getRelative(workspaceRoot.getRootRelativePath());
     try {
-      BuildFileAST file =
-          BuildFileAST.parse(
+      StarlarkFile file =
+          StarlarkFile.parse(
               ParserInput.create(
                   ruleClassProvider.getDefaultWorkspacePrefix(),
                   PathFragment.create("/DEFAULT.WORKSPACE")),
@@ -96,7 +94,7 @@
       }
       if (newWorkspaceFileContents != null) {
         file =
-            BuildFileAST.parseVirtualBuildFile(
+            StarlarkFile.parseVirtualBuildFile(
                 ParserInput.create(
                     newWorkspaceFileContents, resolvedFile.get().asPath().asFragment()),
                 file.getStatements(),
@@ -105,7 +103,7 @@
         byte[] bytes =
             FileSystemUtils.readWithKnownFileSize(repoWorkspace, repoWorkspace.getFileSize());
         file =
-            BuildFileAST.parseWithPrelude(
+            StarlarkFile.parseWithPrelude(
                 ParserInput.create(bytes, repoWorkspace.asFragment()),
                 file.getStatements(),
                 env.getListener());
@@ -117,7 +115,7 @@
         }
       }
       file =
-          BuildFileAST.parseWithPrelude(
+          StarlarkFile.parseWithPrelude(
               ParserInput.create(
                   resolvedFile.isPresent() ? "" : ruleClassProvider.getDefaultWorkspaceSuffix(),
                   PathFragment.create("/DEFAULT.WORKSPACE.SUFFIX")),
@@ -222,8 +220,8 @@
    * Cut {@code ast} into a list of AST separated by load statements. We cut right before each load
    * statement series.
    */
-  private static ImmutableList<BuildFileAST> splitAST(BuildFileAST ast) {
-    ImmutableList.Builder<BuildFileAST> asts = ImmutableList.builder();
+  private static ImmutableList<StarlarkFile> splitAST(StarlarkFile ast) {
+    ImmutableList.Builder<StarlarkFile> asts = ImmutableList.builder();
     int prevIdx = 0;
     boolean lastIsLoad = true; // don't cut if the first statement is a load.
     List<Statement> statements = ast.getStatements();
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTValue.java
index 7011784..6397c79 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceASTValue.java
@@ -18,7 +18,7 @@
 import com.google.common.collect.Interner;
 import com.google.devtools.build.lib.concurrent.BlazeInterners;
 import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.vfs.RootedPath;
 import com.google.devtools.build.skyframe.AbstractSkyKey;
 import com.google.devtools.build.skyframe.SkyFunctionName;
@@ -48,14 +48,14 @@
  */
 public class WorkspaceASTValue implements SkyValue {
 
-  private final ImmutableList<BuildFileAST> asts;
+  private final ImmutableList<StarlarkFile> asts;
 
-  public WorkspaceASTValue(List<BuildFileAST> asts) {
+  public WorkspaceASTValue(List<StarlarkFile> asts) {
     Preconditions.checkNotNull(asts);
     this.asts = ImmutableList.copyOf(asts);
   }
 
-  public ImmutableList<BuildFileAST> getASTs() {
+  public ImmutableList<StarlarkFile> getASTs() {
     return asts;
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
index 74716bd..22aadd5 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunction.java
@@ -25,8 +25,8 @@
 import com.google.devtools.build.lib.packages.WorkspaceFactory;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue.WorkspaceFileKey;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.Mutability;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
 import com.google.devtools.build.lib.vfs.RootedPath;
@@ -123,7 +123,7 @@
         }
         parser.setParent(prevValue.getPackage(), prevValue.getImportMap(), prevValue.getBindings());
       }
-      BuildFileAST ast = workspaceASTValue.getASTs().get(key.getIndex());
+      StarlarkFile ast = workspaceASTValue.getASTs().get(key.getIndex());
       PackageFunction.SkylarkImportResult importResult =
           PackageFunction.fetchImportsFromBuildFile(
               repoWorkspace,
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Comment.java b/src/main/java/com/google/devtools/build/lib/syntax/Comment.java
index a5924f9..9ca6728 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Comment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Comment.java
@@ -36,7 +36,7 @@
   @Override
   public void prettyPrint(Appendable buffer, int indentLevel) throws IOException {
     // We can't really print comments in the right place anyway, due to how their relative order
-    // is lost in the representation of BuildFileAST. So don't bother word-wrapping and just print
+    // is lost in the representation of StarlarkFile. So don't bother word-wrapping and just print
     // it on a single line.
     printIndent(buffer, indentLevel);
     buffer.append("# ");
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Expression.java b/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
index 5368e2e..06bc54c 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
@@ -69,7 +69,7 @@
   // TODO(adonovan): remove dependency from syntax -> EventHandler.
   // A call to Expression.parse either succeeds or fails; there is no useful middle ground, so an
   // exception is appropriate. The exception would contain the list of errors.
-  // By contrast, a call to BuildFileAST.parse should return both a partial AST and a list of
+  // By contrast, a call to StarlarkFile.parse should return both a partial AST and a list of
   // errors,
   // and generally it is useful to keep both around, so if we put the errors in the root of the AST,
   // then client can deal with them however they like, e.g. by sending them to the event handler.
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Node.java b/src/main/java/com/google/devtools/build/lib/syntax/Node.java
index 1150116..d19b669 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Node.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Node.java
@@ -92,7 +92,7 @@
    *
    * <p>Pretty printing can also be used as a proxy for comparing for equality between two ASTs.
    * This can be very useful in tests. However, it is still possible for two different trees to have
-   * the same pretty printing. In particular, {@link BuildFileAST} includes import metadata and
+   * the same pretty printing. In particular, {@link StarlarkFile} includes import metadata and
    * comment information that is not reflected in the string.
    */
   public abstract void prettyPrint(Appendable buffer, int indentLevel) throws IOException;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/NodeVisitor.java b/src/main/java/com/google/devtools/build/lib/syntax/NodeVisitor.java
index eaaa97d..a98a016 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/NodeVisitor.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/NodeVisitor.java
@@ -53,7 +53,7 @@
     }
   }
 
-  public void visit(BuildFileAST node) {
+  public void visit(StarlarkFile node) {
     visitBlock(node.getStatements());
     visitAll(node.getComments());
   }
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
index 6834531..ff4e4d8 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Parser.java
@@ -41,7 +41,7 @@
  */
 // TODO(adonovan): break syntax->events dependency and simplify error handling in the API. The
 // result of parsing is a complete, partial, or even empty, file plus a list of errors. For
-// BuildFileAST.parse, we should materialize the error list within the BuildFileAST and remove all
+// StarlarkFile.parse, we should materialize the error list within the StarlarkFile and remove all
 // mention of event handlers; let the client decide whether to throw or report errors. For
 // Expression.parse, throwing an exception is appropriate: expressions are typically so short that
 // only one error is wanted, so the result can be all-or-nothing.
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSignatureProcessor.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSignatureProcessor.java
index 83723fa..5cd12f4 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSignatureProcessor.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSignatureProcessor.java
@@ -251,7 +251,7 @@
                   .setEventHandler(StarlarkThread.FAIL_FAST_HANDLER)
                   .build()
                   .update("unbound", Runtime.UNBOUND);
-          defaultValue = BuildFileAST.eval(ParserInput.fromLines(paramDefaultValue), thread);
+          defaultValue = StarlarkFile.eval(ParserInput.fromLines(paramDefaultValue), thread);
           defaultValueCache.put(paramDefaultValue, defaultValue);
           return defaultValue;
         }
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkFile.java
similarity index 91%
rename from src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java
rename to src/main/java/com/google/devtools/build/lib/syntax/StarlarkFile.java
index 7f7e7b5..9a9f458 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkFile.java
@@ -24,8 +24,7 @@
 import javax.annotation.Nullable;
 
 /** Syntax tree for a Starlark file, such as a Bazel BUILD or .bzl file. */
-// TODO(adonovan): rename to StarlarkFile.
-public class BuildFileAST extends Node {
+public class StarlarkFile extends Node {
 
   private final ImmutableList<Statement> statements;
 
@@ -40,7 +39,7 @@
 
   @Nullable private final String contentHashCode;
 
-  private BuildFileAST(
+  private StarlarkFile(
       ImmutableList<Statement> statements,
       boolean containsErrors,
       String contentHashCode,
@@ -55,7 +54,7 @@
     this.stringEscapeEvents = stringEscapeEvents;
   }
 
-  private static BuildFileAST create(
+  private static StarlarkFile create(
       List<Statement> preludeStatements,
       ParseResult result,
       String contentHashCode,
@@ -75,7 +74,7 @@
       statementsbuilder.addAll(result.statements);
     }
     ImmutableList<Statement> statements = statementsbuilder.build();
-    return new BuildFileAST(
+    return new StarlarkFile(
         statements,
         result.containsErrors,
         contentHashCode,
@@ -88,9 +87,9 @@
    * Extract a subtree containing only statements from {@code firstStatement} (included) up to
    * {@code lastStatement} excluded.
    */
-  public BuildFileAST subTree(int firstStatement, int lastStatement) {
+  public StarlarkFile subTree(int firstStatement, int lastStatement) {
     ImmutableList<Statement> statements = this.statements.subList(firstStatement, lastStatement);
-    return new BuildFileAST(
+    return new StarlarkFile(
         statements,
         containsErrors,
         null,
@@ -207,7 +206,7 @@
 
   @Override
   public String toString() {
-    return "<BuildFileAST with " + statements.size() + " statements>";
+    return "<StarlarkFile with " + statements.size() + " statements>";
   }
 
   @Override
@@ -220,10 +219,8 @@
    * front of its statement list. All errors during scanning or parsing will be reported to the
    * event handler.
    */
-  public static BuildFileAST parseWithPrelude(
-      ParserInput input,
-      List<Statement> preludeStatements,
-      EventHandler eventHandler) {
+  public static StarlarkFile parseWithPrelude(
+      ParserInput input, List<Statement> preludeStatements, EventHandler eventHandler) {
     Parser.ParseResult result = Parser.parseFile(input, eventHandler);
     return create(
         preludeStatements, result, /* contentHashCode= */ null, /*allowImportInternal=*/ false);
@@ -234,16 +231,14 @@
    * exempt from visibility restrictions. All errors during scanning or parsing will be reported to
    * the event handler.
    */
-  public static BuildFileAST parseVirtualBuildFile(
-      ParserInput input,
-      List<Statement> preludeStatements,
-      EventHandler eventHandler) {
+  public static StarlarkFile parseVirtualBuildFile(
+      ParserInput input, List<Statement> preludeStatements, EventHandler eventHandler) {
     Parser.ParseResult result = Parser.parseFile(input, eventHandler);
     return create(
         preludeStatements, result, /* contentHashCode= */ null, /*allowImportInternal=*/ true);
   }
 
-  public static BuildFileAST parseWithDigest(
+  public static StarlarkFile parseWithDigest(
       ParserInput input, byte[] digest, EventHandler eventHandler) throws IOException {
     Parser.ParseResult result = Parser.parseFile(input, eventHandler);
     return create(
@@ -253,7 +248,7 @@
         /* allowImportInternal= */ false);
   }
 
-  public static BuildFileAST parse(ParserInput input, EventHandler eventHandler) {
+  public static StarlarkFile parse(ParserInput input, EventHandler eventHandler) {
     Parser.ParseResult result = Parser.parseFile(input, eventHandler);
     return create(
         /* preludeStatements= */ ImmutableList.<Statement>of(),
@@ -267,9 +262,9 @@
    * during scanning or parsing will be reported to the event handler.
    */
   // TODO(adonovan): redundant; delete.
-  public static BuildFileAST parseWithoutImports(ParserInput input, EventHandler eventHandler) {
+  public static StarlarkFile parseWithoutImports(ParserInput input, EventHandler eventHandler) {
     ParseResult result = Parser.parseFile(input, eventHandler);
-    return new BuildFileAST(
+    return new StarlarkFile(
         ImmutableList.copyOf(result.statements),
         result.containsErrors,
         /* contentHashCode= */ null,
@@ -286,7 +281,7 @@
   // TODO(adonovan): eliminate. Most callers need validation because they intend to execute the
   // file, and should be made to use higher-level operations in EvalUtils.
   // rest should skip this step. Called from EvaluationTestCase, ParserTest, ASTFileLookupFunction.
-  public BuildFileAST validate(
+  public StarlarkFile validate(
       StarlarkThread thread, boolean isBuildFile, EventHandler eventHandler) {
     try {
       ValidationEnvironment.validateFile(this, thread, isBuildFile);
@@ -299,7 +294,7 @@
     if (containsErrors) {
       return this; // already marked as errant
     }
-    return new BuildFileAST(
+    return new StarlarkFile(
         statements,
         /*containsErrors=*/ true,
         contentHashCode,
@@ -338,7 +333,7 @@
   @Nullable
   public static Object eval(ParserInput input, StarlarkThread thread)
       throws EvalException, InterruptedException {
-    BuildFileAST ast = parseAndValidateSkylark(input, thread);
+    StarlarkFile ast = parseAndValidateSkylark(input, thread);
     return ast.eval(thread);
   }
 
@@ -347,9 +342,9 @@
    * it throws an EvalException. Uses Starlark (not BUILD) validation semantics.
    */
   // TODO(adonovan): move to EvalUtils; see above.
-  public static BuildFileAST parseAndValidateSkylark(ParserInput input, StarlarkThread thread)
+  public static StarlarkFile parseAndValidateSkylark(ParserInput input, StarlarkThread thread)
       throws EvalException {
-    BuildFileAST file = parse(input, thread.getEventHandler());
+    StarlarkFile file = parse(input, thread.getEventHandler());
     file.replayLexerEvents(thread, thread.getEventHandler());
     ValidationEnvironment.validateFile(file, thread, /*isBuildFile=*/ false);
     return file;
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkThread.java b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkThread.java
index a7732e2..a03b7de 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/StarlarkThread.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/StarlarkThread.java
@@ -1206,7 +1206,7 @@
   // TODO(adonovan): push this up into the debugger once the exec API is finalized.
   public void debugExec(ParserInput input) throws EvalException, InterruptedException {
     EvalEventHandler handler = new EvalEventHandler();
-    BuildFileAST file = BuildFileAST.parse(input, handler);
+    StarlarkFile file = StarlarkFile.parse(input, handler);
     if (!handler.messages.isEmpty()) {
       Event ev = handler.messages.get(0);
       throw new EvalException(ev.getLocation(), ev.getMessage());
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java b/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
index d3d90b5..bb61d57 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/ValidationEnvironment.java
@@ -396,7 +396,7 @@
 
   // Public entry point, throwing variant.
   // TODO(adonovan): combine with variant below.
-  public static void validateFile(BuildFileAST file, StarlarkThread thread, boolean isBuildFile)
+  public static void validateFile(StarlarkFile file, StarlarkThread thread, boolean isBuildFile)
       throws EvalException {
     try {
       ValidationEnvironment venv = new ValidationEnvironment(thread, isBuildFile);
@@ -410,7 +410,7 @@
 
   // Public entry point, error handling variant.
   public static boolean validateFile(
-      BuildFileAST file, StarlarkThread thread, boolean isBuildFile, EventHandler eventHandler) {
+      StarlarkFile file, StarlarkThread thread, boolean isBuildFile, EventHandler eventHandler) {
     try {
       validateFile(file, thread, isBuildFile);
       return true;
diff --git a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
index f1368e8..a960812 100644
--- a/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
+++ b/src/main/java/com/google/devtools/build/skydoc/SkydocMain.java
@@ -55,13 +55,13 @@
 import com.google.devtools.build.lib.skylarkbuildapi.stubs.SkylarkAspectStub;
 import com.google.devtools.build.lib.skylarkbuildapi.test.TestingBootstrap;
 import com.google.devtools.build.lib.syntax.BaseFunction;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.LoadStatement;
 import com.google.devtools.build.lib.syntax.MethodLibrary;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
 import com.google.devtools.build.lib.syntax.Runtime;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkFunction;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
@@ -389,7 +389,7 @@
     }
   }
 
-  private static String getModuleDoc(BuildFileAST buildFileAST) {
+  private static String getModuleDoc(StarlarkFile buildFileAST) {
     ImmutableList<Statement> fileStatements = buildFileAST.getStatements();
     if (!fileStatements.isEmpty()) {
       Statement moduleComment = fileStatements.get(0);
@@ -429,7 +429,7 @@
     pending.add(path);
 
     ParserInput parserInputSource = getInputSource(path.toString());
-    BuildFileAST file = BuildFileAST.parse(parserInputSource, eventHandler);
+    StarlarkFile file = StarlarkFile.parse(parserInputSource, eventHandler);
 
     moduleDocMap.put(label, getModuleDoc(file));
 
@@ -490,7 +490,7 @@
   /** Evaluates the AST from a single skylark file, given the already-resolved imports. */
   private StarlarkThread evalSkylarkBody(
       StarlarkSemantics semantics,
-      BuildFileAST buildFileAST,
+      StarlarkFile buildFileAST,
       Map<String, Extension> imports,
       List<RuleInfoWrapper> ruleInfoList,
       List<ProviderInfoWrapper> providerInfoList,
diff --git a/src/main/java/com/google/devtools/starlark/Starlark.java b/src/main/java/com/google/devtools/starlark/Starlark.java
index 0da0ace..bcfc5e1 100644
--- a/src/main/java/com/google/devtools/starlark/Starlark.java
+++ b/src/main/java/com/google/devtools/starlark/Starlark.java
@@ -16,11 +16,11 @@
 import com.google.devtools.build.lib.events.Event;
 import com.google.devtools.build.lib.events.EventHandler;
 import com.google.devtools.build.lib.events.EventKind;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
 import com.google.devtools.build.lib.syntax.Printer;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -91,7 +91,7 @@
     String line;
     while ((line = prompt()) != null) {
       try {
-        Object result = BuildFileAST.eval(ParserInput.fromLines(line), thread);
+        Object result = StarlarkFile.eval(ParserInput.fromLines(line), thread);
         if (result != null) {
           System.out.println(Printer.repr(result));
         }
@@ -117,7 +117,7 @@
   public int execute(String content) {
     try {
       ParserInput input = ParserInput.create(content, null);
-      BuildFileAST.eval(input, thread);
+      StarlarkFile.eval(input, thread);
       return 0;
     } catch (EvalException e) {
       System.err.println(e.print());
diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
index e88bf80..dd9dd13 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java
@@ -28,8 +28,8 @@
 import com.google.devtools.build.lib.packages.PackageFactory.GlobPatternExtractor;
 import com.google.devtools.build.lib.packages.util.PackageFactoryApparatus;
 import com.google.devtools.build.lib.packages.util.PackageFactoryTestBase;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.ParserInput;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.testutil.TestUtils;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -1207,7 +1207,7 @@
   public void testGlobPatternExtractor() {
     GlobPatternExtractor globPatternExtractor = new GlobPatternExtractor();
     globPatternExtractor.visit(
-        BuildFileAST.parse(
+        StarlarkFile.parse(
             ParserInput.fromLines(
                 "pattern = '*'",
                 "some_variable = glob([",
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryApparatus.java b/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryApparatus.java
index 1792021..9ce4643 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryApparatus.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/util/PackageFactoryApparatus.java
@@ -30,8 +30,8 @@
 import com.google.devtools.build.lib.packages.PackageFactory.LegacyGlobber;
 import com.google.devtools.build.lib.packages.RuleClassProvider;
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.ParserInput;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread.Extension;
 import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
@@ -134,18 +134,16 @@
     return createPackage(packageIdentifier, buildFile, reporter, null);
   }
 
-  /**
-   * Parses the {@code buildFile} into a {@link BuildFileAST}.
-   */
-  public BuildFileAST ast(Path buildFile) throws IOException {
+  /** Parses the {@code buildFile} into a {@link StarlarkFile}. */
+  public StarlarkFile ast(Path buildFile) throws IOException {
     byte[] bytes = FileSystemUtils.readWithKnownFileSize(buildFile, buildFile.getFileSize());
     ParserInput input = ParserInput.create(bytes, buildFile.asFragment());
-    return BuildFileAST.parse(input, eventHandler);
+    return StarlarkFile.parse(input, eventHandler);
   }
 
   /** Evaluates the {@code buildFileAST} into a {@link Package}. */
   public Pair<Package, GlobCache> evalAndReturnGlobCache(
-      String packageName, RootedPath buildFile, BuildFileAST buildFileAST)
+      String packageName, RootedPath buildFile, StarlarkFile buildFileAST)
       throws InterruptedException, NoSuchPackageException {
     PackageIdentifier packageId = PackageIdentifier.createInMainRepo(packageName);
     GlobCache globCache =
@@ -191,7 +189,7 @@
     return Pair.of(result, globCache);
   }
 
-  public Package eval(String packageName, RootedPath buildFile, BuildFileAST buildFileAST)
+  public Package eval(String packageName, RootedPath buildFile, StarlarkFile buildFileAST)
       throws InterruptedException, NoSuchPackageException {
     return evalAndReturnGlobCache(packageName, buildFile, buildFileAST).first;
   }
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java
index 71ba585..23d6663 100644
--- a/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java
+++ b/src/test/java/com/google/devtools/build/lib/pkgcache/PackageCacheTest.java
@@ -42,7 +42,7 @@
 import com.google.devtools.build.lib.skyframe.BazelSkyframeExecutorConstants;
 import com.google.devtools.build.lib.skyframe.PrecomputedValue;
 import com.google.devtools.build.lib.skyframe.SkyframeExecutor;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.testutil.FoundationTestCase;
 import com.google.devtools.build.lib.testutil.MoreAsserts;
 import com.google.devtools.build.lib.testutil.TestConstants;
@@ -214,7 +214,7 @@
   public void testASTIsNotRetained() throws Exception {
     createPkg1();
     Package pkg1 = getPackage("pkg1");
-    MoreAsserts.assertInstanceOfNotReachable(pkg1, BuildFileAST.class);
+    MoreAsserts.assertInstanceOfNotReachable(pkg1, StarlarkFile.class);
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
index 8442317..3ef2e18 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
@@ -22,8 +22,8 @@
 import com.google.devtools.build.lib.cmdline.PackageIdentifier;
 import com.google.devtools.build.lib.packages.NoSuchPackageException;
 import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.LoadStatement;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.Statement;
 import com.google.devtools.build.lib.vfs.FileStatus;
 import com.google.devtools.build.lib.vfs.FileSystem;
@@ -153,7 +153,7 @@
     assertThat(loads).containsExactly(":ext2.bzl");
   }
 
-  private static List<String> getLoads(BuildFileAST file) {
+  private static List<String> getLoads(StarlarkFile file) {
     List<String> loads = Lists.newArrayList();
     for (Statement stmt : file.getStatements()) {
       if (stmt instanceof LoadStatement) {
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunctionTest.java
index c1bc87e..b6ea916 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceASTFunctionTest.java
@@ -22,7 +22,7 @@
 import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
 import com.google.devtools.build.lib.skyframe.WorkspaceFileFunctionTest.FakeFileValue;
 import com.google.devtools.build.lib.skyframe.WorkspaceFileFunctionTest.SkyKeyMatchers;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -77,7 +77,7 @@
     return env;
   }
 
-  private List<BuildFileAST> getASTs(String... lines)
+  private List<StarlarkFile> getASTs(String... lines)
       throws IOException, SkyFunctionException, InterruptedException {
     RootedPath workspacePath = createWorkspaceFile(lines);
 
@@ -88,7 +88,7 @@
 
   @Test
   public void testSplitASTNoLoad() throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts = getASTs("foo_bar = 1");
+    List<StarlarkFile> asts = getASTs("foo_bar = 1");
     assertThat(asts).hasSize(1);
     assertThat(asts.get(0).getStatements()).hasSize(1);
   }
@@ -96,14 +96,14 @@
   @Test
   public void testSplitASTOneLoadAtTop()
       throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts = getASTs("load('//:foo.bzl', 'bar')", "foo_bar = 1");
+    List<StarlarkFile> asts = getASTs("load('//:foo.bzl', 'bar')", "foo_bar = 1");
     assertThat(asts).hasSize(1);
     assertThat(asts.get(0).getStatements()).hasSize(2);
   }
 
   @Test
   public void testSplitASTOneLoad() throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts = getASTs("foo_bar = 1", "load('//:foo.bzl', 'bar')");
+    List<StarlarkFile> asts = getASTs("foo_bar = 1", "load('//:foo.bzl', 'bar')");
     assertThat(asts).hasSize(2);
     assertThat(asts.get(0).getStatements()).hasSize(1);
     assertThat(asts.get(1).getStatements()).hasSize(1);
@@ -112,7 +112,7 @@
   @Test
   public void testSplitASTTwoSuccessiveLoads()
       throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts =
+    List<StarlarkFile> asts =
         getASTs("foo_bar = 1", "load('//:foo.bzl', 'bar')", "load('//:bar.bzl', 'foo')");
     assertThat(asts).hasSize(2);
     assertThat(asts.get(0).getStatements()).hasSize(1);
@@ -122,7 +122,7 @@
   @Test
   public void testSplitASTTwoSucessiveLoadsWithNonLoadStatement()
       throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts =
+    List<StarlarkFile> asts =
         getASTs(
             "foo_bar = 1",
             "load('//:foo.bzl', 'bar')",
@@ -136,7 +136,7 @@
   @Test
   public void testSplitASTThreeLoadsThreeSegments()
       throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts =
+    List<StarlarkFile> asts =
         getASTs(
             "foo_bar = 1",
             "load('//:foo.bzl', 'bar')",
@@ -152,7 +152,7 @@
   @Test
   public void testSplitASTThreeLoadsThreeSegmentsWithContent()
       throws IOException, SkyFunctionException, InterruptedException {
-    List<BuildFileAST> asts =
+    List<StarlarkFile> asts =
         getASTs(
             "foo_bar = 1",
             "load('//:foo.bzl', 'bar')",
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index 21e4578..7baff22 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -48,7 +48,6 @@
 import com.google.devtools.build.lib.packages.Type;
 import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction;
 import com.google.devtools.build.lib.skylark.util.SkylarkTestCase;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.ClassObject;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.EvalUtils;
@@ -57,6 +56,7 @@
 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.SkylarkNestedSet;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkSemantics;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.testutil.MoreAsserts;
@@ -704,7 +704,7 @@
 
   protected void evalAndExport(String... lines) throws Exception {
     ParserInput input = ParserInput.fromLines(lines);
-    BuildFileAST file = BuildFileAST.parseAndValidateSkylark(input, ev.getStarlarkThread());
+    StarlarkFile file = StarlarkFile.parseAndValidateSkylark(input, ev.getStarlarkThread());
     SkylarkImportLookupFunction.execAndExport(
         file, FAKE_LABEL, ev.getEventHandler(), ev.getStarlarkThread());
   }
diff --git a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
index 93b8128..a614466 100644
--- a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
@@ -37,12 +37,12 @@
 import com.google.devtools.build.lib.skylarkdebugging.SkylarkDebuggingProtos.StartDebuggingResponse;
 import com.google.devtools.build.lib.skylarkdebugging.SkylarkDebuggingProtos.Stepping;
 import com.google.devtools.build.lib.skylarkdebugging.SkylarkDebuggingProtos.Value;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalUtils;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
 import com.google.devtools.build.lib.syntax.Runtime;
 import com.google.devtools.build.lib.syntax.SkylarkList;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.testutil.Scratch;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
@@ -136,7 +136,7 @@
 
   @Test
   public void testPausedUntilStartDebuggingRequestReceived() throws Exception {
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]");
     StarlarkThread thread = newStarlarkThread();
 
     Thread evaluationThread = execInWorkerThread(buildFile, thread);
@@ -167,7 +167,7 @@
   @Test
   public void testResumeAllThreads() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
 
     Location breakpoint =
         Location.newBuilder().setLineNumber(2).setPath("/a/build/file/BUILD").build();
@@ -202,7 +202,7 @@
   @Test
   public void testPauseAtBreakpoint() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -230,7 +230,7 @@
   @Test
   public void testDoNotPauseAtUnsatisfiedConditionalBreakpoint() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile =
+    StarlarkFile buildFile =
         parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]", "z = 1");
     StarlarkThread thread = newStarlarkThread();
 
@@ -266,7 +266,7 @@
   @Test
   public void testPauseAtSatisfiedConditionalBreakpoint() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location location =
@@ -296,7 +296,7 @@
   @Test
   public void testPauseAtInvalidConditionBreakpointWithError() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location location =
@@ -341,7 +341,7 @@
   @Test
   public void testSimpleListFramesRequest() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -372,7 +372,7 @@
   @Test
   public void testGetChildrenRequest() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -402,7 +402,7 @@
   @Test
   public void testListFramesShadowedBinding() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST bzlFile =
+    StarlarkFile bzlFile =
         parseSkylarkFile(
             "/a/build/file/test.bzl",
             "a = 1",
@@ -465,7 +465,7 @@
   @Test
   public void testEvaluateRequestWithExpression() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -492,7 +492,7 @@
   @Test
   public void testEvaluateRequestWithAssignmentStatement() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -526,7 +526,7 @@
   @Test
   public void testEvaluateRequestWithExpressionStatementMutatingState() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -560,7 +560,7 @@
   @Test
   public void testEvaluateRequestThrowingException() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
+    StarlarkFile buildFile = parseBuildFile("/a/build/file/BUILD", "x = [1,2,3]", "y = [2,3,4]");
     StarlarkThread thread = newStarlarkThread();
 
     Location breakpoint =
@@ -587,7 +587,7 @@
   @Test
   public void testStepIntoFunction() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST bzlFile =
+    StarlarkFile bzlFile =
         parseSkylarkFile(
             "/a/build/file/test.bzl",
             "def fn():",
@@ -635,7 +635,7 @@
   @Test
   public void testStepOverFunction() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST bzlFile =
+    StarlarkFile bzlFile =
         parseSkylarkFile(
             "/a/build/file/test.bzl",
             "def fn():",
@@ -678,7 +678,7 @@
   @Test
   public void testStepOutOfFunction() throws Exception {
     sendStartDebuggingRequest();
-    BuildFileAST bzlFile =
+    StarlarkFile bzlFile =
         parseSkylarkFile(
             "/a/build/file/test.bzl",
             "def fn():",
@@ -763,22 +763,22 @@
     return StarlarkThread.builder(mutability).useDefaultSemantics().build();
   }
 
-  private BuildFileAST parseBuildFile(String path, String... lines) throws IOException {
+  private StarlarkFile parseBuildFile(String path, String... lines) throws IOException {
     Path file = scratch.file(path, lines);
     byte[] bytes = FileSystemUtils.readWithKnownFileSize(file, file.getFileSize());
     ParserInput inputSource = ParserInput.create(bytes, file.asFragment());
-    return BuildFileAST.parse(inputSource, events.reporter());
+    return StarlarkFile.parse(inputSource, events.reporter());
   }
 
-  private BuildFileAST parseSkylarkFile(String path, String... lines) throws IOException {
+  private StarlarkFile parseSkylarkFile(String path, String... lines) throws IOException {
     return parseBuildFile(path, lines); // TODO(adonovan): combine these functions
   }
 
   /**
-   * Creates and starts a worker thread executing the given {@link BuildFileAST} in the given
+   * Creates and starts a worker thread executing the given {@link StarlarkFile} in the given
    * environment.
    */
-  private Thread execInWorkerThread(BuildFileAST ast, StarlarkThread thread) {
+  private Thread execInWorkerThread(StarlarkFile ast, StarlarkThread thread) {
     Thread javaThread =
         new Thread(
             () -> {
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ASTPrettyPrintTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ASTPrettyPrintTest.java
index 5078938..12ca90a 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ASTPrettyPrintTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ASTPrettyPrintTest.java
@@ -389,15 +389,13 @@
 
   @Test
   public void buildFileAST() {
-    Node node = parseBuildFileASTWithoutValidation("print(x)\nprint(y)");
+    Node node = parseStarlarkFileWithoutValidation("print(x)\nprint(y)");
     assertIndentedPrettyMatches(
         node,
         join("  print(x)",
              "  print(y)",
              ""));
-    assertTostringMatches(
-        node,
-        "<BuildFileAST with 2 statements>");
+    assertTostringMatches(node, "<StarlarkFile with 2 statements>");
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/LValueBoundNamesTest.java b/src/test/java/com/google/devtools/build/lib/syntax/LValueBoundNamesTest.java
index e7ac035..0b651fc 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/LValueBoundNamesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/LValueBoundNamesTest.java
@@ -52,7 +52,7 @@
 
   private static void assertBoundNames(String assignment, String... expectedBoundNames) {
     ParserInput input = ParserInput.fromLines(assignment);
-    BuildFileAST file = BuildFileAST.parse(input, StarlarkThread.FAIL_FAST_HANDLER);
+    StarlarkFile file = StarlarkFile.parse(input, StarlarkThread.FAIL_FAST_HANDLER);
     Expression lhs = ((AssignmentStatement) file.getStatements().get(0)).getLHS();
     Set<String> boundNames =
         Identifier.boundIdentifiers(lhs).stream()
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/NodeVisitorTest.java b/src/test/java/com/google/devtools/build/lib/syntax/NodeVisitorTest.java
index 0cb7d87..6be69bf 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/NodeVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/NodeVisitorTest.java
@@ -26,9 +26,9 @@
 @RunWith(JUnit4.class)
 public final class NodeVisitorTest {
 
-  private BuildFileAST parse(String... lines) throws IOException {
+  private StarlarkFile parse(String... lines) throws IOException {
     ParserInput input = ParserInput.fromLines(lines);
-    return BuildFileAST.parse(input, StarlarkThread.FAIL_FAST_HANDLER);
+    return StarlarkFile.parse(input, StarlarkThread.FAIL_FAST_HANDLER);
   }
 
   @Test
@@ -48,7 +48,7 @@
       }
     }
 
-    BuildFileAST file =
+    StarlarkFile file =
         parse(
             "a = b", //
             "def c(p1, p2=4, **p3):",
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
index b136f3a..45c8655 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
@@ -58,9 +58,9 @@
   }
 
   // Joins the lines, parses, and returns a file.
-  private BuildFileAST parseFile(String... lines) {
+  private StarlarkFile parseFile(String... lines) {
     ParserInput input = ParserInput.fromLines(lines);
-    return BuildFileAST.parse(input, events.reporter());
+    return StarlarkFile.parse(input, events.reporter());
   }
 
   // Joins the lines, parses, and returns the sole statement.
@@ -991,7 +991,7 @@
 
   @Test
   public void testParseBuildFileWithComments() throws Exception {
-    BuildFileAST result =
+    StarlarkFile result =
         parseFile(
             "# Test BUILD file", //
             "# with multi-line comment",
@@ -1007,7 +1007,7 @@
 
   @Test
   public void testParseBuildFileWithManyComments() throws Exception {
-    BuildFileAST result =
+    StarlarkFile result =
         parseFile(
             "# 1", //
             "# 2",
@@ -1386,7 +1386,7 @@
 
   @Test
   public void testStringsAreDeduped() throws Exception {
-    BuildFileAST file = parseFile("L1 = ['cat', 'dog', 'fish']", "L2 = ['dog', 'fish', 'cat']");
+    StarlarkFile file = parseFile("L1 = ['cat', 'dog', 'fish']", "L2 = ['dog', 'fish', 'cat']");
     Set<String> uniqueStringInstances = Sets.newIdentityHashSet();
     NodeVisitor collectAllStringsInStringLiteralsVisitor =
         new NodeVisitor() {
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
similarity index 78%
rename from src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
rename to src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
index 4132b35..24a7fa0 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
@@ -27,11 +27,9 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-/**
- * Unit tests for BuildFileAST.
- */
+/** Unit tests for StarlarkFile. */
 @RunWith(JUnit4.class)
-public class BuildFileASTTest extends EvaluationTestCase {
+public class StarlarkFileTest extends EvaluationTestCase {
 
   private Scratch scratch = new Scratch();
 
@@ -41,22 +39,23 @@
   }
 
   /**
-   * Parses the contents of the specified string (using DUMMY_PATH as the fake
-   * filename) and returns the AST. Resets the error handler beforehand.
+   * Parses the contents of the specified string (using DUMMY_PATH as the fake filename) and returns
+   * the AST. Resets the error handler beforehand.
    */
-  private BuildFileAST parseBuildFile(String... lines) throws IOException {
+  private StarlarkFile parseBuildFile(String... lines) throws IOException {
     Path file = scratch.file("/a/build/file/BUILD", lines);
     byte[] bytes = FileSystemUtils.readWithKnownFileSize(file, file.getFileSize());
     ParserInput input = ParserInput.create(bytes, file.asFragment());
-    return BuildFileAST.parse(input, getEventHandler());
+    return StarlarkFile.parse(input, getEventHandler());
   }
 
   @Test
   public void testParseBuildFileOK() throws Exception {
-    BuildFileAST buildfile = parseBuildFile(
-        "# a file in the build language",
-        "",
-        "x = [1,2,'foo',4] + [1,2, \"%s%d\" % ('foo', 1)]");
+    StarlarkFile buildfile =
+        parseBuildFile(
+            "# a file in the build language",
+            "",
+            "x = [1,2,'foo',4] + [1,2, \"%s%d\" % ('foo', 1)]");
 
     assertThat(buildfile.exec(thread, getEventHandler())).isTrue();
 
@@ -71,11 +70,7 @@
   @Test
   public void testEvalException() throws Exception {
     setFailFast(false);
-    BuildFileAST buildfile = parseBuildFile(
-        "x = 1",
-        "y = [2,3]",
-        "",
-        "z = x + y");
+    StarlarkFile buildfile = parseBuildFile("x = 1", "y = [2,3]", "", "z = x + y");
 
     assertThat(buildfile.exec(thread, getEventHandler())).isFalse();
     Event e = assertContainsError("unsupported operand type(s) for +: 'int' and 'list'");
@@ -84,7 +79,7 @@
 
   @Test
   public void testParsesFineWithNewlines() throws Exception {
-    BuildFileAST buildFileAST = parseBuildFile("foo()", "bar()", "something = baz()", "bar()");
+    StarlarkFile buildFileAST = parseBuildFile("foo()", "bar()", "something = baz()", "bar()");
     assertThat(buildFileAST.getStatements()).hasSize(4);
   }
 
@@ -92,8 +87,7 @@
   public void testFailsIfNewlinesAreMissing() throws Exception {
     setFailFast(false);
 
-    BuildFileAST buildFileAST =
-      parseBuildFile("foo() bar() something = baz() bar()");
+    StarlarkFile buildFileAST = parseBuildFile("foo() bar() something = baz() bar()");
 
     Event event = assertContainsError("syntax error at \'bar\': expected newline");
     assertThat(event.getLocation().getPath().toString()).isEqualTo("/a/build/file/BUILD");
@@ -104,7 +98,7 @@
   @Test
   public void testImplicitStringConcatenationFails() throws Exception {
     setFailFast(false);
-    BuildFileAST buildFileAST = parseBuildFile("a = 'foo' 'bar'");
+    StarlarkFile buildFileAST = parseBuildFile("a = 'foo' 'bar'");
     Event event = assertContainsError(
         "Implicit string concatenation is forbidden, use the + operator");
     assertThat(event.getLocation().getPath().toString()).isEqualTo("/a/build/file/BUILD");
@@ -116,7 +110,7 @@
   @Test
   public void testImplicitStringConcatenationAcrossLinesIsIllegal() throws Exception {
     setFailFast(false);
-    BuildFileAST buildFileAST = parseBuildFile("a = 'foo'\n  'bar'");
+    StarlarkFile buildFileAST = parseBuildFile("a = 'foo'\n  'bar'");
 
     Event event = assertContainsError("indentation error");
     assertThat(event.getLocation().getPath().toString()).isEqualTo("/a/build/file/BUILD");
@@ -128,14 +122,15 @@
   @Test
   public void testWithSyntaxErrorsDoesNotPrintDollarError() throws Exception {
     setFailFast(false);
-    BuildFileAST buildFile = parseBuildFile(
-        "abi = '$(ABI)-glibc-' + glibc_version + '-' + $(TARGET_CPU) + '-linux'",
-        "libs = [abi + opt_level + '/lib/libcc.a']",
-        "shlibs = [abi + opt_level + '/lib/libcc.so']",
-        "+* shlibs", // syntax error at '+'
-        "cc_library(name = 'cc',",
-        "           srcs = libs,",
-        "           includes = [ abi + opt_level + '/include' ])");
+    StarlarkFile buildFile =
+        parseBuildFile(
+            "abi = '$(ABI)-glibc-' + glibc_version + '-' + $(TARGET_CPU) + '-linux'",
+            "libs = [abi + opt_level + '/lib/libcc.a']",
+            "shlibs = [abi + opt_level + '/lib/libcc.so']",
+            "+* shlibs", // syntax error at '+'
+            "cc_library(name = 'cc',",
+            "           srcs = libs,",
+            "           includes = [ abi + opt_level + '/include' ])");
     assertThat(buildFile.containsErrors()).isTrue();
     assertContainsError("syntax error at '*': expected expression");
     assertThat(buildFile.exec(thread, getEventHandler())).isFalse();
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/StarlarkThreadTest.java b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkThreadTest.java
index 8784cbb..a3746ee 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/StarlarkThreadTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkThreadTest.java
@@ -190,7 +190,7 @@
   @Test
   public void testBuiltinsCanBeShadowed() throws Exception {
     StarlarkThread thread = newStarlarkThreadWithSkylarkOptions().setup("special_var", 42);
-    BuildFileAST.eval(ParserInput.fromLines("special_var = 41"), thread);
+    StarlarkFile.eval(ParserInput.fromLines("special_var = 41"), thread);
     assertThat(thread.moduleLookup("special_var")).isEqualTo(41);
   }
 
@@ -198,7 +198,7 @@
   public void testVariableIsReferencedBeforeAssignment() throws Exception {
     StarlarkThread thread = newStarlarkThread().update("global_var", 666);
     try {
-      BuildFileAST.eval(
+      StarlarkFile.eval(
           ParserInput.fromLines("def foo(x): x += global_var; global_var = 36; return x", "foo(1)"),
           thread);
       throw new AssertionError("failed to fail");
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java b/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java
index 456c56b..35425cc 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java
@@ -27,13 +27,13 @@
 import com.google.devtools.build.lib.packages.BazelStarlarkContext;
 import com.google.devtools.build.lib.packages.PackageFactory;
 import com.google.devtools.build.lib.packages.SymbolGenerator;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.EvalException;
 import com.google.devtools.build.lib.syntax.Expression;
 import com.google.devtools.build.lib.syntax.Mutability;
 import com.google.devtools.build.lib.syntax.ParserInput;
 import com.google.devtools.build.lib.syntax.SkylarkUtils;
 import com.google.devtools.build.lib.syntax.SkylarkUtils.Phase;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.StarlarkThread;
 import com.google.devtools.build.lib.syntax.StarlarkThread.FailFastException;
 import com.google.devtools.build.lib.syntax.Statement;
@@ -150,13 +150,13 @@
     return thread;
   }
 
-  protected final BuildFileAST parseBuildFileASTWithoutValidation(String... lines) {
+  protected final StarlarkFile parseStarlarkFileWithoutValidation(String... lines) {
     ParserInput input = ParserInput.fromLines(lines);
-    return BuildFileAST.parse(input, getEventHandler());
+    return StarlarkFile.parse(input, getEventHandler());
   }
 
-  private BuildFileAST parseBuildFileAST(String... lines) {
-    BuildFileAST ast = parseBuildFileASTWithoutValidation(lines);
+  private StarlarkFile parseStarlarkFile(String... lines) {
+    StarlarkFile ast = parseStarlarkFileWithoutValidation(lines);
     return ast.validate(thread, /*isBuildFile=*/ false, getEventHandler());
   }
 
@@ -165,12 +165,12 @@
   // Separate all the tests clearly into tests of the scanner, parser, resolver,
   // and evaluation.
   protected List<Statement> parseFile(String... lines) {
-    return parseBuildFileAST(lines).getStatements();
+    return parseStarlarkFile(lines).getStatements();
   }
 
   /** Parses a statement, without validation. */
   protected final Statement parseStatement(String... lines) {
-    return parseBuildFileASTWithoutValidation(lines).getStatements().get(0);
+    return parseStarlarkFileWithoutValidation(lines).getStatements().get(0);
   }
 
   /** Parses an expression. */
@@ -191,9 +191,9 @@
     ParserInput input = ParserInput.fromLines(lines);
     if (testMode == TestMode.SKYLARK) {
       // TODO(adonovan): inline this call and factor with 'else' case.
-      return BuildFileAST.eval(input, thread);
+      return StarlarkFile.eval(input, thread);
     } else {
-      BuildFileAST file = BuildFileAST.parse(input, thread.getEventHandler());
+      StarlarkFile file = StarlarkFile.parse(input, thread.getEventHandler());
       if (ValidationEnvironment.validateFile(
           file, thread, /*isBuildFile=*/ true, thread.getEventHandler())) {
         PackageFactory.checkBuildSyntax(file, thread.getEventHandler());
diff --git a/src/tools/skylark/java/com/google/devtools/skylark/common/DocstringUtils.java b/src/tools/skylark/java/com/google/devtools/skylark/common/DocstringUtils.java
index acf974a..00e2ae7 100644
--- a/src/tools/skylark/java/com/google/devtools/skylark/common/DocstringUtils.java
+++ b/src/tools/skylark/java/com/google/devtools/skylark/common/DocstringUtils.java
@@ -18,11 +18,11 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.devtools.build.lib.syntax.AssignmentStatement;
-import com.google.devtools.build.lib.syntax.BuildFileAST;
 import com.google.devtools.build.lib.syntax.DefStatement;
 import com.google.devtools.build.lib.syntax.Expression;
 import com.google.devtools.build.lib.syntax.ExpressionStatement;
 import com.google.devtools.build.lib.syntax.Identifier;
+import com.google.devtools.build.lib.syntax.StarlarkFile;
 import com.google.devtools.build.lib.syntax.Statement;
 import com.google.devtools.build.lib.syntax.StringLiteral;
 import com.google.devtools.skylark.common.LocationRange.Location;
@@ -50,7 +50,7 @@
    * @return a map from identifier names to their docstring; if there is a file-level docstring, its
    *     key is "".
    */
-  public static ImmutableMap<String, StringLiteral> collectDocstringLiterals(BuildFileAST ast) {
+  public static ImmutableMap<String, StringLiteral> collectDocstringLiterals(StarlarkFile ast) {
     ImmutableMap.Builder<String, StringLiteral> nameToDocstringLiteral = ImmutableMap.builder();
     Statement previousStatement = null;
     for (Statement currentStatement : ast.getStatements()) {
diff --git a/src/tools/skylark/java/com/google/devtools/skylark/common/LocationRange.java b/src/tools/skylark/java/com/google/devtools/skylark/common/LocationRange.java
index b3d1731..be7db38 100644
--- a/src/tools/skylark/java/com/google/devtools/skylark/common/LocationRange.java
+++ b/src/tools/skylark/java/com/google/devtools/skylark/common/LocationRange.java
@@ -68,7 +68,7 @@
     }
 
     public static Location from(@Nullable LineAndColumn lac) {
-      // LineAndColumn may be null, e.g. if a BuildFileAST contains no statements:
+      // LineAndColumn may be null, e.g. if a StarlarkFile contains no statements:
       if (lac == null) {
         return new Location(1, 1);
       }