Skylark -> Starlark, getting my feet wet: SkylarkImportLookupFunction
Done in near-instant time with IntelliJ refactoring.
There are still some conceptually related references in the old style
(SkylarkImportLookupFunctionException, other code' getters, /*skylarkImportLookupFunctionForInlining=*/ parameters, etc).
I'm hoping to strike the right balance of grouping conceptually related symbols while keeping changelists manageably nimble.
PiperOrigin-RevId: 305775997
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
index 728c2b4..bcde413 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
@@ -66,7 +66,7 @@
import com.google.devtools.build.lib.skyframe.AspectValue.AspectKey;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.ConfiguredTargetFunctionException;
import com.google.devtools.build.lib.skyframe.SkyframeExecutor.BuildViewProvider;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.SkylarkImportFailedException;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction.SkylarkImportFailedException;
import com.google.devtools.build.lib.util.OrderedSetMultimap;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionException;
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 73b0d22..96f6897 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
@@ -54,8 +54,8 @@
import com.google.devtools.build.lib.repository.ExternalPackageUtil;
import com.google.devtools.build.lib.rules.repository.WorkspaceFileHelper;
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.skyframe.StarlarkImportLookupFunction.SkylarkImportFailedException;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.FileOptions;
import com.google.devtools.build.lib.syntax.Location;
@@ -105,7 +105,7 @@
private final Label preludeLabel;
// Not final only for testing.
- @Nullable private SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining;
+ @Nullable private StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining;
private final ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile;
@@ -118,11 +118,11 @@
Cache<PackageIdentifier, LoadedPackageCacheEntry> packageFunctionCache,
Cache<PackageIdentifier, StarlarkFile> fileSyntaxCache,
AtomicInteger numPackagesLoaded,
- @Nullable SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining,
+ @Nullable StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining,
@Nullable PackageProgressReceiver packageProgress,
ActionOnIOExceptionReadingBuildFile actionOnIOExceptionReadingBuildFile,
IncrementalityIntent incrementalityIntent) {
- this.skylarkImportLookupFunctionForInlining = skylarkImportLookupFunctionForInlining;
+ this.starlarkImportLookupFunctionForInlining = starlarkImportLookupFunctionForInlining;
// Can be null in tests.
this.preludeLabel = packageFactory == null
? null
@@ -146,7 +146,7 @@
Cache<PackageIdentifier, LoadedPackageCacheEntry> packageFunctionCache,
Cache<PackageIdentifier, StarlarkFile> fileSyntaxCache,
AtomicInteger numPackagesLoaded,
- @Nullable SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining) {
+ @Nullable StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining) {
this(
packageFactory,
pkgLocator,
@@ -154,15 +154,15 @@
packageFunctionCache,
fileSyntaxCache,
numPackagesLoaded,
- skylarkImportLookupFunctionForInlining,
+ starlarkImportLookupFunctionForInlining,
/*packageProgress=*/ null,
ActionOnIOExceptionReadingBuildFile.UseOriginalIOException.INSTANCE,
IncrementalityIntent.INCREMENTAL);
}
public void setSkylarkImportLookupFunctionForInliningForTesting(
- SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining) {
- this.skylarkImportLookupFunctionForInlining = skylarkImportLookupFunctionForInlining;
+ StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining) {
+ this.starlarkImportLookupFunctionForInlining = starlarkImportLookupFunctionForInlining;
}
/**
@@ -587,13 +587,13 @@
StarlarkFile file,
int workspaceChunk,
Environment env,
- SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining)
+ StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining)
throws NoSuchPackageException, InterruptedException {
Preconditions.checkArgument(!packageId.getRepository().isDefault());
// Parse the labels in the file's load statements.
Map<String, Label> loadMap =
- SkylarkImportLookupFunction.getLoadMap(env.getListener(), file, packageId, repoMapping);
+ StarlarkImportLookupFunction.getLoadMap(env.getListener(), file, packageId, repoMapping);
if (loadMap == null) {
// malformed load statements
throw new BuildFileContainsErrorsException(packageId, "malformed load statements");
@@ -618,10 +618,10 @@
Map<SkyKey, SkyValue> skylarkImportMap;
try {
skylarkImportMap =
- skylarkImportLookupFunctionForInlining == null
+ starlarkImportLookupFunctionForInlining == null
? computeSkylarkImportMapNoInlining(env, importLookupKeys)
: computeSkylarkImportMapWithInlining(
- env, importLookupKeys, skylarkImportLookupFunctionForInlining);
+ env, importLookupKeys, starlarkImportLookupFunctionForInlining);
} catch (SkylarkImportFailedException e) {
throw makeSkylarkImportFailedException(packageId, e);
} catch (InconsistentFilesystemException e) {
@@ -687,7 +687,7 @@
private static Map<SkyKey, SkyValue> computeSkylarkImportMapWithInlining(
Environment env,
List<? extends SkyKey> importLookupKeys,
- SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining)
+ StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining)
throws InterruptedException, SkylarkImportFailedException, InconsistentFilesystemException {
Map<SkyKey, SkyValue> skylarkImportMap =
Maps.newHashMapWithExpectedSize(importLookupKeys.size());
@@ -703,7 +703,7 @@
skyValue = visitedDepsInToplevelLoad.get(importLookupKey).getValue();
} else {
skyValue =
- skylarkImportLookupFunctionForInlining
+ starlarkImportLookupFunctionForInlining
.computeWithInlineCallsForPackageAndWorkspaceNodes(
importLookupKey, env, visitedDepsInToplevelLoad);
}
@@ -1231,7 +1231,7 @@
file,
/* workspaceChunk = */ -1,
env,
- skylarkImportLookupFunctionForInlining);
+ starlarkImportLookupFunctionForInlining);
} catch (NoSuchPackageException e) {
throw new PackageFunctionException(e, Transience.PERSISTENT);
} catch (InterruptedException e) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index ec15121..55e428f 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -457,7 +457,7 @@
private ImmutableMap<SkyFunctionName, SkyFunction> skyFunctions(PackageFactory pkgFactory) {
ConfiguredRuleClassProvider ruleClassProvider =
(ConfiguredRuleClassProvider) pkgFactory.getRuleClassProvider();
- SkylarkImportLookupFunction skylarkImportLookupFunctionForInliningPackageAndWorkspaceNodes =
+ StarlarkImportLookupFunction starlarkImportLookupFunctionForInliningPackageAndWorkspaceNodes =
getSkylarkImportLookupFunctionForInliningPackageAndWorkspaceNodes();
// TODO(janakr): use this semaphore to bound memory usage for SkyFunctions besides
// ConfiguredTargetFunction that may have a large temporary memory blow-up.
@@ -520,7 +520,7 @@
packageFunctionCache,
fileSyntaxCache,
numPackagesLoaded,
- skylarkImportLookupFunctionForInliningPackageAndWorkspaceNodes,
+ starlarkImportLookupFunctionForInliningPackageAndWorkspaceNodes,
packageProgress,
actionOnIOExceptionReadingBuildFile,
tracksStateForIncrementality()
@@ -564,7 +564,7 @@
ruleClassProvider,
pkgFactory,
directories,
- skylarkImportLookupFunctionForInliningPackageAndWorkspaceNodes));
+ starlarkImportLookupFunctionForInliningPackageAndWorkspaceNodes));
map.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction());
map.put(
SkyFunctions.TARGET_COMPLETION,
@@ -635,14 +635,14 @@
}
@Nullable
- protected SkylarkImportLookupFunction
+ protected StarlarkImportLookupFunction
getSkylarkImportLookupFunctionForInliningPackageAndWorkspaceNodes() {
return null;
}
protected SkyFunction newSkylarkImportLookupFunction(
RuleClassProvider ruleClassProvider, PackageFactory pkgFactory) {
- return new SkylarkImportLookupFunction(ruleClassProvider, this.pkgFactory);
+ return new StarlarkImportLookupFunction(ruleClassProvider, this.pkgFactory);
}
protected PerBuildSyscallCache newPerBuildSyscallCache(int concurrencyLevel) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunction.java
similarity index 88%
rename from src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
rename to src/main/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunction.java
index ca2a4c8..64e99d0 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunction.java
@@ -68,33 +68,34 @@
import javax.annotation.Nullable;
/**
- * A Skyframe function to look up and import a single Skylark extension.
+ * A Skyframe function to look up and import a single Starlark extension.
*
- * <p>Given a {@link Label} referencing a Skylark file, attempts to locate the file and load it. The
- * Label must be absolute, and must not reference the special {@code external} package. If loading
- * is successful, returns a {@link SkylarkImportLookupValue} that encapsulates the loaded {@link
- * Extension} and {@link SkylarkFileDependency} information. If loading is unsuccessful, throws a
- * {@link SkylarkImportLookupFunctionException} that encapsulates the cause of the failure.
+ * <p>Given a {@link Label} referencing a Starlark file, attempts to locate the file and load it.
+ * The Label must be absolute, and must not reference the special {@code external} package. If
+ * loading is successful, returns a {@link SkylarkImportLookupValue} that encapsulates the loaded
+ * {@link Extension} and {@link SkylarkFileDependency} information. If loading is unsuccessful,
+ * throws a {@link StarlarkImportLookupFunctionException} that encapsulates the cause of the
+ * failure.
*/
-public class SkylarkImportLookupFunction implements SkyFunction {
+public class StarlarkImportLookupFunction implements SkyFunction {
private final RuleClassProvider ruleClassProvider;
private final PackageFactory packageFactory;
private final int starlarkImportLookupValueCacheSize;
- private Cache<SkyKey, CachedSkylarkImportLookupValueAndDeps> skylarkImportLookupValueCache;
+ private Cache<SkyKey, CachedSkylarkImportLookupValueAndDeps> starlarkImportLookupValueCache;
private CachedSkylarkImportLookupValueAndDepsBuilderFactory
- cachedSkylarkImportLookupValueAndDepsBuilderFactory =
+ cachedStarlarkImportLookupValueAndDepsBuilderFactory =
new CachedSkylarkImportLookupValueAndDepsBuilderFactory();
private static final Logger logger =
- Logger.getLogger(SkylarkImportLookupFunction.class.getName());
+ Logger.getLogger(StarlarkImportLookupFunction.class.getName());
- public SkylarkImportLookupFunction(
+ public StarlarkImportLookupFunction(
RuleClassProvider ruleClassProvider, PackageFactory packageFactory) {
this(ruleClassProvider, packageFactory, /*starlarkImportLookupValueCacheSize=*/ -1);
}
- public SkylarkImportLookupFunction(
+ public StarlarkImportLookupFunction(
RuleClassProvider ruleClassProvider,
PackageFactory packageFactory,
int starlarkImportLookupValueCacheSize) {
@@ -119,9 +120,9 @@
/*inlineCachedValueBuilder=*/ null,
/*visitedDepsInToplevelLoad=*/ null);
} catch (InconsistentFilesystemException e) {
- throw new SkylarkImportLookupFunctionException(e, Transience.PERSISTENT);
+ throw new StarlarkImportLookupFunctionException(e, Transience.PERSISTENT);
} catch (SkylarkImportFailedException e) {
- throw new SkylarkImportLookupFunctionException(e);
+ throw new StarlarkImportLookupFunctionException(e);
}
}
@@ -132,19 +133,19 @@
Map<SkylarkImportLookupKey, CachedSkylarkImportLookupValueAndDeps> visitedDepsInToplevelLoad)
throws InconsistentFilesystemException, SkylarkImportFailedException, InterruptedException {
// We use the visitedNested set to track if there are any cyclic dependencies when loading the
- // skylark file and the visitedDepsInToplevelLoad set to avoid re-registering previously seen
+ // Starlark file and the visitedDepsInToplevelLoad set to avoid re-registering previously seen
// dependencies. Note that the visitedNested set must use insertion order to display the correct
// error.
- CachedSkylarkImportLookupValueAndDeps cachedSkylarkImportLookupValueAndDeps =
+ CachedSkylarkImportLookupValueAndDeps cachedStarlarkImportLookupValueAndDeps =
computeWithInlineCallsInternal(
skyKey,
env,
/*visitedNested=*/ new LinkedHashSet<>(),
/*visitedDepsInToplevelLoad=*/ visitedDepsInToplevelLoad);
- if (cachedSkylarkImportLookupValueAndDeps == null) {
+ if (cachedStarlarkImportLookupValueAndDeps == null) {
return null;
}
- return cachedSkylarkImportLookupValueAndDeps.getValue();
+ return cachedStarlarkImportLookupValueAndDeps.getValue();
}
@Nullable
@@ -160,21 +161,21 @@
// If we've visited a SkylarkImportLookupValue through some other load path for a given package,
// we must use the existing value to preserve reference equality between Starlark values that
// ought to be the same. See b/138598337 for details.
- CachedSkylarkImportLookupValueAndDeps cachedSkylarkImportLookupValueAndDeps =
+ CachedSkylarkImportLookupValueAndDeps cachedStarlarkImportLookupValueAndDeps =
visitedDepsInToplevelLoad.get(key);
- if (cachedSkylarkImportLookupValueAndDeps == null) {
+ if (cachedStarlarkImportLookupValueAndDeps == null) {
// Note that we can't block other threads on the computation of this value due to a potential
// deadlock on a cycle. Although we are repeating some work, it is possible we have an import
// cycle where one thread starts at one side of the cycle and the other thread starts at the
// other side, and they then wait forever on the results of each others computations.
- cachedSkylarkImportLookupValueAndDeps = skylarkImportLookupValueCache.getIfPresent(skyKey);
- if (cachedSkylarkImportLookupValueAndDeps != null) {
- cachedSkylarkImportLookupValueAndDeps.traverse(
+ cachedStarlarkImportLookupValueAndDeps = starlarkImportLookupValueCache.getIfPresent(skyKey);
+ if (cachedStarlarkImportLookupValueAndDeps != null) {
+ cachedStarlarkImportLookupValueAndDeps.traverse(
env::registerDependencies, visitedDepsInToplevelLoad);
}
}
- if (cachedSkylarkImportLookupValueAndDeps != null) {
- return cachedSkylarkImportLookupValueAndDeps;
+ if (cachedStarlarkImportLookupValueAndDeps != null) {
+ return cachedStarlarkImportLookupValueAndDeps;
}
if (!visitedNested.add(importLabel)) {
@@ -184,7 +185,7 @@
}
CachedSkylarkImportLookupValueAndDeps.Builder inlineCachedValueBuilder =
- cachedSkylarkImportLookupValueAndDepsBuilderFactory
+ cachedStarlarkImportLookupValueAndDepsBuilderFactory
.newCachedSkylarkImportLookupValueAndDepsBuilder();
Preconditions.checkState(
!(env instanceof RecordingSkyFunctionEnvironment),
@@ -212,26 +213,26 @@
if (value != null) {
inlineCachedValueBuilder.setValue(value);
inlineCachedValueBuilder.setKey(key);
- cachedSkylarkImportLookupValueAndDeps = inlineCachedValueBuilder.build();
- visitedDepsInToplevelLoad.put(key, cachedSkylarkImportLookupValueAndDeps);
- skylarkImportLookupValueCache.put(skyKey, cachedSkylarkImportLookupValueAndDeps);
+ cachedStarlarkImportLookupValueAndDeps = inlineCachedValueBuilder.build();
+ visitedDepsInToplevelLoad.put(key, cachedStarlarkImportLookupValueAndDeps);
+ starlarkImportLookupValueCache.put(skyKey, cachedStarlarkImportLookupValueAndDeps);
}
- return cachedSkylarkImportLookupValueAndDeps;
+ return cachedStarlarkImportLookupValueAndDeps;
}
public void resetCache() {
- if (skylarkImportLookupValueCache != null) {
+ if (starlarkImportLookupValueCache != null) {
logger.info(
"Starlark inlining cache stats from earlier build: "
- + skylarkImportLookupValueCache.stats());
+ + starlarkImportLookupValueCache.stats());
}
- cachedSkylarkImportLookupValueAndDepsBuilderFactory =
+ cachedStarlarkImportLookupValueAndDepsBuilderFactory =
new CachedSkylarkImportLookupValueAndDepsBuilderFactory();
Preconditions.checkState(
starlarkImportLookupValueCacheSize >= 0,
- "Expected positive skylark cache size if caching. %s",
+ "Expected positive Starlark cache size if caching. %s",
starlarkImportLookupValueCacheSize);
- skylarkImportLookupValueCache =
+ starlarkImportLookupValueCache =
CacheBuilder.newBuilder()
.concurrencyLevel(BlazeInterners.concurrencyLevel())
.maximumSize(starlarkImportLookupValueCacheSize)
@@ -314,7 +315,7 @@
return null;
}
if (!astLookupValue.lookupSuccessful()) {
- // Skylark import files have to exist.
+ // Starlark import files have to exist.
throw new SkylarkImportFailedException(astLookupValue.getErrorMsg());
}
StarlarkFile file = astLookupValue.getAST();
@@ -346,18 +347,18 @@
importLookupKeys.add(SkylarkImportLookupValue.key(importLabel));
}
}
- Map<SkyKey, SkyValue> skylarkImportMap =
+ Map<SkyKey, SkyValue> starlarkImportMap =
(visitedNested == null)
- ? computeSkylarkImportMapNoInlining(env, importLookupKeys, file.getStartLocation())
- : computeSkylarkImportMapWithInlining(
+ ? computeStarlarkImportMapNoInlining(env, importLookupKeys, file.getStartLocation())
+ : computeStarlarkImportMapWithInlining(
env,
importLookupKeys,
fileLabel,
visitedNested,
inlineCachedValueBuilder,
visitedDepsInToplevelLoad);
- // skylarkImportMap is null when skyframe deps are unavailable.
- if (skylarkImportMap == null) {
+ // starlarkImportMap is null when skyframe deps are unavailable.
+ if (starlarkImportMap == null) {
return null;
}
@@ -376,7 +377,7 @@
keyForLabel = SkylarkImportLookupValue.key(importLabel);
}
SkylarkImportLookupValue importLookupValue =
- (SkylarkImportLookupValue) skylarkImportMap.get(keyForLabel);
+ (SkylarkImportLookupValue) starlarkImportMap.get(keyForLabel);
extensionsForImports.put(importString, importLookupValue.getEnvironmentExtension());
fileDependencies.add(importLookupValue.getDependency());
}
@@ -494,32 +495,32 @@
* returning {@code null} if skyframe deps were missing and have been requested.
*/
@Nullable
- private static Map<SkyKey, SkyValue> computeSkylarkImportMapNoInlining(
+ private static Map<SkyKey, SkyValue> computeStarlarkImportMapNoInlining(
Environment env, List<SkyKey> importLookupKeys, Location locationForErrors)
throws SkylarkImportFailedException, InterruptedException {
- Map<SkyKey, SkyValue> skylarkImportMap =
+ Map<SkyKey, SkyValue> starlarkImportMap =
Maps.newHashMapWithExpectedSize(importLookupKeys.size());
Map<SkyKey, ValueOrException<SkylarkImportFailedException>> values =
env.getValuesOrThrow(importLookupKeys, SkylarkImportFailedException.class);
// NOTE: Iterating over imports in the order listed in the file.
for (SkyKey key : importLookupKeys) {
try {
- skylarkImportMap.put(key, values.get(key).get());
+ starlarkImportMap.put(key, values.get(key).get());
} catch (SkylarkImportFailedException exn) {
throw new SkylarkImportFailedException(
"in " + locationForErrors.file() + ": " + exn.getMessage());
}
}
- return env.valuesMissing() ? null : skylarkImportMap;
+ return env.valuesMissing() ? null : starlarkImportMap;
}
/**
* Compute the SkylarkImportLookupValue for all given SkyKeys by reusing this instance of the
- * SkylarkImportLookupFunction, bypassing traditional skyframe evaluation, returning {@code null}
+ * StarlarkImportLookupFunction, bypassing traditional skyframe evaluation, returning {@code null}
* if skyframe deps were missing and have been requested.
*/
@Nullable
- private Map<SkyKey, SkyValue> computeSkylarkImportMapWithInlining(
+ private Map<SkyKey, SkyValue> computeStarlarkImportMapWithInlining(
Environment env,
List<SkyKey> importLookupKeys,
Label fileLabel,
@@ -532,10 +533,10 @@
"Expected inline cached value builder to be not-null when inlining.");
Preconditions.checkState(
env instanceof RecordingSkyFunctionEnvironment,
- "Expected to be recording dep requests when inlining SkylarkImportLookupFunction: %s",
+ "Expected to be recording dep requests when inlining StarlarkImportLookupFunction: %s",
fileLabel);
Environment strippedEnv = ((RecordingSkyFunctionEnvironment) env).getDelegate();
- Map<SkyKey, SkyValue> skylarkImportMap =
+ Map<SkyKey, SkyValue> starlarkImportMap =
Maps.newHashMapWithExpectedSize(importLookupKeys.size());
Exception deferredException = null;
boolean valuesMissing = false;
@@ -561,7 +562,7 @@
valuesMissing = true;
} else {
SkyValue skyValue = cachedValue.getValue();
- skylarkImportMap.put(importLookupKey, skyValue);
+ starlarkImportMap.put(importLookupKey, skyValue);
inlineCachedValueBuilder.addTransitiveDeps(cachedValue);
}
}
@@ -571,7 +572,7 @@
throw new IllegalStateException(
"caught a checked exception of unexpected type", deferredException);
}
- return valuesMissing ? null : skylarkImportMap;
+ return valuesMissing ? null : starlarkImportMap;
}
/** Creates the Extension to be imported. */
@@ -701,12 +702,12 @@
}
}
- private static final class SkylarkImportLookupFunctionException extends SkyFunctionException {
- private SkylarkImportLookupFunctionException(SkylarkImportFailedException cause) {
+ private static final class StarlarkImportLookupFunctionException extends SkyFunctionException {
+ private StarlarkImportLookupFunctionException(SkylarkImportFailedException cause) {
super(cause, Transience.PERSISTENT);
}
- private SkylarkImportLookupFunctionException(InconsistentFilesystemException e,
+ private StarlarkImportLookupFunctionException(InconsistentFilesystemException e,
Transience transience) {
super(e, transience);
}
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 0e7c87f..25eb7b1 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
@@ -47,18 +47,18 @@
private final PackageFactory packageFactory;
private final BlazeDirectories directories;
private final RuleClassProvider ruleClassProvider;
- private final SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining;
+ private final StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining;
private static final PackageIdentifier rootPackage = PackageIdentifier.createInMainRepo("");
public WorkspaceFileFunction(
RuleClassProvider ruleClassProvider,
PackageFactory packageFactory,
BlazeDirectories directories,
- SkylarkImportLookupFunction skylarkImportLookupFunctionForInlining) {
+ StarlarkImportLookupFunction starlarkImportLookupFunctionForInlining) {
this.packageFactory = packageFactory;
this.directories = directories;
this.ruleClassProvider = ruleClassProvider;
- this.skylarkImportLookupFunctionForInlining = skylarkImportLookupFunctionForInlining;
+ this.starlarkImportLookupFunctionForInlining = starlarkImportLookupFunctionForInlining;
}
@Override
@@ -132,7 +132,7 @@
ast,
key.getIndex(),
env,
- skylarkImportLookupFunctionForInlining);
+ starlarkImportLookupFunctionForInlining);
if (importResult == null) {
return null;
}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
index 9d687a9..b7acb09 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java
@@ -64,7 +64,7 @@
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.lib.skyframe.RepositoryMappingFunction;
import com.google.devtools.build.lib.skyframe.SkyFunctions;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction;
import com.google.devtools.build.lib.skyframe.WorkspaceASTFunction;
import com.google.devtools.build.lib.skyframe.WorkspaceFileFunction;
import com.google.devtools.build.lib.skyframe.WorkspaceNameFunction;
@@ -429,7 +429,7 @@
.put(SkyFunctions.AST_FILE_LOOKUP, new ASTFileLookupFunction(ruleClassProvider))
.put(
SkyFunctions.SKYLARK_IMPORTS_LOOKUP,
- new SkylarkImportLookupFunction(ruleClassProvider, pkgFactory))
+ new StarlarkImportLookupFunction(ruleClassProvider, pkgFactory))
.put(SkyFunctions.WORKSPACE_NAME, new WorkspaceNameFunction())
.put(SkyFunctions.WORKSPACE_AST, new WorkspaceASTFunction(ruleClassProvider))
.put(
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
index de07415..d979b9b 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
@@ -55,7 +55,7 @@
return flow;
}
- // Hack for SkylarkImportLookupFunction's "export" semantics.
+ // Hack for StarlarkImportLookupFunction's "export" semantics.
// We enable it only for statements outside any function (isToplevelFunction)
// and outside any if- or for- statements (!indented).
if (isToplevelFunction && !indented && fr.thread.postAssignHook != null) {
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 3a64a34..4af9fc5 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
@@ -635,7 +635,7 @@
* Specifies a hook function to be run after each assignment at top level.
*
* <p>This is a short-term hack to allow us to consolidate all StarlarkFile execution in one place
- * even while SkylarkImportLookupFunction implements the old "export" behavior, in which rules,
+ * even while StarlarkImportLookupFunction implements the old "export" behavior, in which rules,
* aspects and providers are "exported" as soon as they are assigned, not at the end of file
* execution.
*/
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java
index 40c418e..8ebc7f1 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorTest.java
@@ -54,7 +54,7 @@
import com.google.devtools.build.lib.skyframe.PrecomputedFunction;
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.lib.skyframe.SkyFunctions;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction;
import com.google.devtools.build.lib.skyframe.WorkspaceASTFunction;
import com.google.devtools.build.lib.skyframe.WorkspaceFileFunction;
import com.google.devtools.build.lib.skylarkbuildapi.repository.RepositoryBootstrap;
@@ -152,12 +152,12 @@
PackageFactory.BuilderForTesting pkgFactoryBuilder =
AnalysisMock.get().getPackageFactoryBuilderForTesting(directories);
- SkylarkImportLookupFunction skylarkImportLookupFunction =
- new SkylarkImportLookupFunction(
+ StarlarkImportLookupFunction starlarkImportLookupFunction =
+ new StarlarkImportLookupFunction(
ruleClassProvider,
pkgFactoryBuilder.build(ruleClassProvider, fileSystem),
/*starlarkImportLookupValueCacheSize=*/ 2);
- skylarkImportLookupFunction.resetCache();
+ starlarkImportLookupFunction.resetCache();
MemoizingEvaluator evaluator =
new InMemoryMemoizingEvaluator(
@@ -188,7 +188,7 @@
.builder(directories)
.build(ruleClassProvider, fileSystem),
directories,
- skylarkImportLookupFunction))
+ starlarkImportLookupFunction))
.put(SkyFunctions.REPOSITORY, new RepositoryLoaderFunction())
.put(SkyFunctions.LOCAL_REPOSITORY_LOOKUP, new LocalRepositoryLookupFunction())
.put(SkyFunctions.EXTERNAL_PACKAGE, new ExternalPackageFunction())
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunctionTest.java
similarity index 83%
rename from src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java
rename to src/test/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunctionTest.java
index 16fa8a9..3527422 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/StarlarkImportLookupFunctionTest.java
@@ -27,7 +27,7 @@
import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.SkylarkImportFailedException;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction.SkylarkImportFailedException;
import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.Path;
@@ -44,9 +44,9 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/** Tests for SkylarkImportLookupFunction. */
+/** Tests for StarlarkImportLookupFunction. */
@RunWith(JUnit4.class)
-public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+public class StarlarkImportLookupFunctionTest extends BuildViewTestCase {
@Before
public final void preparePackageLoading() throws Exception {
@@ -70,7 +70,7 @@
}
@Test
- public void testSkylarkImportLabels() throws Exception {
+ public void testStarlarkImportLabels() throws Exception {
scratch.file("pkg1/BUILD");
scratch.file("pkg1/ext.bzl");
checkSuccessfulLookup("//pkg1:ext.bzl");
@@ -92,7 +92,7 @@
}
@Test
- public void testSkylarkImportLabelsMultipleBuildFiles() throws Exception {
+ public void testStarlarkImportLabelsMultipleBuildFiles() throws Exception {
scratch.file("dir1/BUILD");
scratch.file("dir1/dir2/BUILD");
scratch.file("dir1/dir2/ext.bzl");
@@ -100,7 +100,7 @@
}
@Test
- public void testLoadFromSkylarkFileInRemoteRepo() throws Exception {
+ public void testLoadFromStarlarkFileInRemoteRepo() throws Exception {
scratch.overwriteFile(
"WORKSPACE",
"local_repository(",
@@ -156,13 +156,13 @@
checkSuccessfulLookup("//pkg:subdir/ext2.bzl");
}
- private EvaluationResult<SkylarkImportLookupValue> get(SkyKey skylarkImportLookupKey)
+ private EvaluationResult<SkylarkImportLookupValue> get(SkyKey starlarkImportLookupKey)
throws Exception {
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
if (result.hasError()) {
- fail(result.getError(skylarkImportLookupKey).getException().getMessage());
+ fail(result.getError(starlarkImportLookupKey).getException().getMessage());
}
return result;
}
@@ -171,24 +171,24 @@
return SkylarkImportLookupValue.key(Label.parseAbsoluteUnchecked(label));
}
- // Ensures that a Skylark file has been successfully processed by checking that the
+ // Ensures that a Starlark file has been successfully processed by checking that the
// the label in its dependency set corresponds to the requested label.
private void checkSuccessfulLookup(String label) throws Exception {
- SkyKey skylarkImportLookupKey = key(label);
- EvaluationResult<SkylarkImportLookupValue> result = get(skylarkImportLookupKey);
+ SkyKey starlarkImportLookupKey = key(label);
+ EvaluationResult<SkylarkImportLookupValue> result = get(starlarkImportLookupKey);
assertThat(label)
- .isEqualTo(result.get(skylarkImportLookupKey).getDependency().getLabel().toString());
+ .isEqualTo(result.get(starlarkImportLookupKey).getDependency().getLabel().toString());
}
@Test
- public void testSkylarkImportLookupNoBuildFile() throws Exception {
+ public void testStarlarkImportLookupNoBuildFile() throws Exception {
scratch.file("pkg/ext.bzl", "");
- SkyKey skylarkImportLookupKey = key("//pkg:ext.bzl");
+ SkyKey starlarkImportLookupKey = key("//pkg:ext.bzl");
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
assertThat(result.hasError()).isTrue();
- ErrorInfo errorInfo = result.getError(skylarkImportLookupKey);
+ ErrorInfo errorInfo = result.getError(starlarkImportLookupKey);
String errorMessage = errorInfo.getException().getMessage();
assertThat(errorMessage)
.contains(
@@ -196,31 +196,32 @@
}
@Test
- public void testSkylarkImportLookupNoBuildFileForLoad() throws Exception {
+ public void testStarlarkImportLookupNoBuildFileForLoad() throws Exception {
scratch.file("pkg2/BUILD");
scratch.file("pkg1/ext.bzl", "a = 1");
scratch.file("pkg2/ext.bzl", "load('//pkg1:ext.bzl', 'a')");
- SkyKey skylarkImportLookupKey = key("//pkg:ext.bzl");
+ SkyKey starlarkImportLookupKey = key("//pkg:ext.bzl");
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
assertThat(result.hasError()).isTrue();
- ErrorInfo errorInfo = result.getError(skylarkImportLookupKey);
+ ErrorInfo errorInfo = result.getError(starlarkImportLookupKey);
String errorMessage = errorInfo.getException().getMessage();
assertThat(errorMessage).contains("Every .bzl file must have a corresponding package");
}
@Test
- public void testSkylarkImportFilenameWithControlChars() throws Exception {
+ public void testStarlarkImportFilenameWithControlChars() throws Exception {
scratch.file("pkg/BUILD", "");
scratch.file("pkg/ext.bzl", "load('//pkg:oops\u0000.bzl', 'a')");
- SkyKey skylarkImportLookupKey = key("//pkg:ext.bzl");
+ SkyKey starlarkImportLookupKey = key("//pkg:ext.bzl");
AssertionError e =
assertThrows(
AssertionError.class,
() ->
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter));
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false,
+ reporter));
String errorMessage = e.getMessage();
assertThat(errorMessage)
.contains(
@@ -245,7 +246,7 @@
RootedPath.toRootedPath(
Root.fromPath(p.getParentDirectory()), PathFragment.create("WORKSPACE"));
- SkyKey skylarkImportLookupKey =
+ SkyKey starlarkImportLookupKey =
SkylarkImportLookupValue.keyInWorkspace(
Label.parseAbsoluteUnchecked("@a_remote_repo//remote_pkg:ext.bzl"),
/* inWorkspace= */
@@ -253,7 +254,7 @@
rootedPath);
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
assertThat(result.hasError()).isFalse();
}
@@ -322,17 +323,17 @@
// checkStrayLabel checks that execution of target fails because
// the label of its load statement strays into a subpackage.
private void checkStrayLabel(String target, String expectedMessage) throws InterruptedException {
- SkyKey skylarkImportLookupKey = key(target);
+ SkyKey starlarkImportLookupKey = key(target);
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
assertThat(result.hasError()).isTrue();
assertThatEvaluationResult(result)
- .hasErrorEntryForKeyThat(skylarkImportLookupKey)
+ .hasErrorEntryForKeyThat(starlarkImportLookupKey)
.hasExceptionThat()
.isInstanceOf(SkylarkImportFailedException.class);
assertThatEvaluationResult(result)
- .hasErrorEntryForKeyThat(skylarkImportLookupKey)
+ .hasErrorEntryForKeyThat(starlarkImportLookupKey)
.hasExceptionThat()
.hasMessageThat()
.contains(expectedMessage);
@@ -343,17 +344,17 @@
throws Exception {
scratch.file("BUILD", "load(\"@repository//dir:file.bzl\", \"foo\")");
- SkyKey skylarkImportLookupKey = key("@repository//dir:file.bzl");
+ SkyKey starlarkImportLookupKey = key("@repository//dir:file.bzl");
EvaluationResult<com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
assertThat(result.hasError()).isTrue();
assertThatEvaluationResult(result)
- .hasErrorEntryForKeyThat(skylarkImportLookupKey)
+ .hasErrorEntryForKeyThat(starlarkImportLookupKey)
.hasExceptionThat()
.isInstanceOf(SkylarkImportFailedException.class);
assertThatEvaluationResult(result)
- .hasErrorEntryForKeyThat(skylarkImportLookupKey)
+ .hasErrorEntryForKeyThat(starlarkImportLookupKey)
.hasExceptionThat()
.hasMessageThat()
.contains(
@@ -388,15 +389,15 @@
Root root = Root.fromPath(p.getParentDirectory());
RootedPath rootedPath = RootedPath.toRootedPath(root, PathFragment.create("WORKSPACE"));
- SkyKey skylarkImportLookupKey =
+ SkyKey starlarkImportLookupKey =
SkylarkImportLookupValue.keyInWorkspace(
Label.parseAbsoluteUnchecked("@a//:a.bzl"), 1, rootedPath);
EvaluationResult<SkylarkImportLookupValue> result =
SkyframeExecutorTestUtils.evaluate(
- getSkyframeExecutor(), skylarkImportLookupKey, /*keepGoing=*/ false, reporter);
+ getSkyframeExecutor(), starlarkImportLookupKey, /*keepGoing=*/ false, reporter);
- assertThat(result.get(skylarkImportLookupKey).getEnvironmentExtension().getBindings())
+ assertThat(result.get(starlarkImportLookupKey).getEnvironmentExtension().getBindings())
.containsEntry("a_symbol", 5);
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
index 1c5a2eb..8394263 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkIntegrationTest.java
@@ -55,7 +55,7 @@
import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
import com.google.devtools.build.lib.skyframe.PackageFunction;
import com.google.devtools.build.lib.skyframe.SkyFunctions;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction;
import com.google.devtools.build.lib.syntax.Depset;
import com.google.devtools.build.lib.syntax.Sequence;
import com.google.devtools.build.lib.syntax.Starlark;
@@ -3053,14 +3053,14 @@
ImmutableMap<SkyFunctionName, ? extends SkyFunction> skyFunctions =
((InMemoryMemoizingEvaluator) getSkyframeExecutor().getEvaluatorForTesting())
.getSkyFunctionsForTesting();
- SkylarkImportLookupFunction skylarkImportLookupFunction =
- new SkylarkImportLookupFunction(
+ StarlarkImportLookupFunction starlarkImportLookupFunction =
+ new StarlarkImportLookupFunction(
this.getRuleClassProvider(),
this.getPackageFactory(),
/*starlarkImportLookupValueCacheSize=*/ 2);
- skylarkImportLookupFunction.resetCache();
+ starlarkImportLookupFunction.resetCache();
((PackageFunction) skyFunctions.get(SkyFunctions.PACKAGE))
- .setSkylarkImportLookupFunctionForInliningForTesting(skylarkImportLookupFunction);
+ .setSkylarkImportLookupFunctionForInliningForTesting(starlarkImportLookupFunction);
}
@Override
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 fe1e6f6..11ef9a4 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,7 @@
import com.google.devtools.build.lib.packages.StructImpl;
import com.google.devtools.build.lib.packages.StructProvider;
import com.google.devtools.build.lib.packages.Type;
-import com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction;
+import com.google.devtools.build.lib.skyframe.StarlarkImportLookupFunction;
import com.google.devtools.build.lib.skylark.util.SkylarkTestCase;
import com.google.devtools.build.lib.syntax.ClassObject;
import com.google.devtools.build.lib.syntax.Depset;
@@ -756,7 +756,7 @@
if (!file.ok()) {
throw new SyntaxError.Exception(file.errors());
}
- SkylarkImportLookupFunction.execAndExport(file, FAKE_LABEL, ev.getEventHandler(), thread);
+ StarlarkImportLookupFunction.execAndExport(file, FAKE_LABEL, ev.getEventHandler(), thread);
}
@Test