From 41a3cb021e0c7e2058f5104cbd80ae8766790a2b Mon Sep 17 00:00:00 2001 From: jcater Date: Tue, 14 Apr 2020 11:14:57 -0700 Subject: [PATCH] Remove ConfiguredTargetValue.key. All uses should be ConfiguredTargetKey.of. PiperOrigin-RevId: 306476845 --- .../devtools/build/lib/analysis/AspectResolver.java | 7 +++---- .../lib/query2/aquery/ActionGraphQueryEnvironment.java | 9 ++++----- .../lib/query2/cquery/ConfiguredTargetAccessor.java | 3 ++- .../query2/cquery/ConfiguredTargetQueryEnvironment.java | 2 +- .../build/lib/skyframe/ConfiguredTargetFunction.java | 7 +++---- .../build/lib/skyframe/ConfiguredTargetValue.java | 6 ------ .../devtools/build/lib/skyframe/SkyframeExecutor.java | 4 ++-- .../lib/skyframe/util/SkyframeExecutorTestUtils.java | 3 ++- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java index 4b098130f74d72..ebb8058d999133 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectResolver.java @@ -26,7 +26,7 @@ import com.google.devtools.build.lib.skyframe.AspectFunction; import com.google.devtools.build.lib.skyframe.AspectValue; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; -import com.google.devtools.build.lib.skyframe.ConfiguredTargetValue; +import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.util.OrderedSetMultimap; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyKey; @@ -92,8 +92,7 @@ public static OrderedSetMultimap resolveAspectDepe // Validate that aspect is applicable to "bare" configured target. ConfiguredTargetAndData associatedTarget = - configuredTargetMap.get( - ConfiguredTargetValue.key(dep.getLabel(), dep.getConfiguration())); + configuredTargetMap.get(ConfiguredTargetKey.of(dep.getLabel(), dep.getConfiguration())); if (!aspectMatchesConfiguredTarget(associatedTarget, aspectValue.getAspect())) { continue; } @@ -126,7 +125,7 @@ public static OrderedSetMultimap mergeA for (Map.Entry entry : depValueNames.entries()) { Dependency dep = entry.getValue(); - SkyKey depKey = ConfiguredTargetValue.key(dep.getLabel(), dep.getConfiguration()); + SkyKey depKey = ConfiguredTargetKey.of(dep.getLabel(), dep.getConfiguration()); ConfiguredTargetAndData depConfiguredTarget = depConfiguredTargetMap.get(depKey); result.put( diff --git a/src/main/java/com/google/devtools/build/lib/query2/aquery/ActionGraphQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/aquery/ActionGraphQueryEnvironment.java index 6b39da8e8fe4d1..557eb0ad302866 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/aquery/ActionGraphQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/aquery/ActionGraphQueryEnvironment.java @@ -237,7 +237,7 @@ public Label getCorrectLabel(ConfiguredTargetValue configuredTargetValue) { @Nullable @Override protected ConfiguredTargetValue getHostConfiguredTarget(Label label) throws InterruptedException { - return this.getConfiguredTargetValue(ConfiguredTargetValue.key(label, hostConfiguration)); + return this.getConfiguredTargetValue(ConfiguredTargetKey.of(label, hostConfiguration)); } @Nullable @@ -246,12 +246,12 @@ protected ConfiguredTargetValue getTargetConfiguredTarget(Label label) throws InterruptedException { if (topLevelConfigurations.isTopLevelTarget(label)) { return this.getConfiguredTargetValue( - ConfiguredTargetValue.key( + ConfiguredTargetKey.of( label, topLevelConfigurations.getConfigurationForTopLevelTarget(label))); } else { ConfiguredTargetValue toReturn; for (BuildConfiguration configuration : topLevelConfigurations.getConfigurations()) { - toReturn = this.getConfiguredTargetValue(ConfiguredTargetValue.key(label, configuration)); + toReturn = this.getConfiguredTargetValue(ConfiguredTargetKey.of(label, configuration)); if (toReturn != null) { return toReturn; } @@ -263,8 +263,7 @@ protected ConfiguredTargetValue getTargetConfiguredTarget(Label label) @Nullable @Override protected ConfiguredTargetValue getNullConfiguredTarget(Label label) throws InterruptedException { - return this.getConfiguredTargetValue( - ConfiguredTargetValue.key(label, /* configuration= */ null)); + return this.getConfiguredTargetValue(ConfiguredTargetKey.of(label, /* configuration= */ null)); } @Nullable diff --git a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java index 6d5eeb059b5735..1d0761801526f0 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java +++ b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetAccessor.java @@ -41,6 +41,7 @@ import com.google.devtools.build.lib.query2.engine.QueryExpression; import com.google.devtools.build.lib.query2.engine.QueryVisibility; import com.google.devtools.build.lib.skyframe.BuildConfigurationValue; +import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.skyframe.ConfiguredTargetValue; import com.google.devtools.build.lib.skyframe.PackageValue; import com.google.devtools.build.lib.skyframe.UnloadedToolchainContext; @@ -189,7 +190,7 @@ public RuleConfiguredTarget getGeneratingConfiguredTarget(OutputFileConfiguredTa return (RuleConfiguredTarget) ((ConfiguredTargetValue) walkableGraph.getValue( - ConfiguredTargetValue.key( + ConfiguredTargetKey.of( oct.getGeneratingRule().getLabel(), queryEnvironment.getConfiguration(oct)))) .getConfiguredTarget(); diff --git a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQueryEnvironment.java index c006b1577e049d..9b106004473ea4 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/cquery/ConfiguredTargetQueryEnvironment.java @@ -318,7 +318,7 @@ public QueryTaskFuture getTargetsMatchingPattern( @Nullable private ConfiguredTarget getConfiguredTarget(Label label, BuildConfiguration configuration) throws InterruptedException { - return getValueFromKey(ConfiguredTargetValue.key(label, configuration)); + return getValueFromKey(ConfiguredTargetKey.of(label, configuration)); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java index cd261c3f065675..7edefe3bdb8076 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java @@ -750,7 +750,7 @@ static ImmutableMap getConfigConditions( // Get the configured targets as ConfigMatchingProvider interfaces. for (Dependency entry : configConditionDeps) { - SkyKey baseKey = ConfiguredTargetValue.key(entry.getLabel(), entry.getConfiguration()); + SkyKey baseKey = ConfiguredTargetKey.of(entry.getLabel(), entry.getConfiguration()); ConfiguredTarget value = configValues.get(baseKey).getConfiguredTarget(); // The code above guarantees that value is non-null here and since the rule is a // config_setting, provider must also be non-null. @@ -795,8 +795,7 @@ private static Map resolveConfiguredTargetDepen Iterable depKeys = Iterables.concat( Iterables.transform( - deps, - input -> ConfiguredTargetValue.key(input.getLabel(), input.getConfiguration())), + deps, input -> ConfiguredTargetKey.of(input.getLabel(), input.getConfiguration())), Iterables.transform( deps, input -> PackageValue.key(input.getLabel().getPackageIdentifier()))); Map> depValuesOrExceptions = @@ -808,7 +807,7 @@ private static Map resolveConfiguredTargetDepen Collection depsToProcess = deps; for (int i = 0; i < 2; i++) { for (Dependency dep : depsToProcess) { - SkyKey key = ConfiguredTargetValue.key(dep.getLabel(), dep.getConfiguration()); + SkyKey key = ConfiguredTargetKey.of(dep.getLabel(), dep.getConfiguration()); try { ConfiguredTargetValue depValue = (ConfiguredTargetValue) depValuesOrExceptions.get(key).get(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java index 67e260b2accd0d..b65aa1377b5889 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java @@ -15,18 +15,12 @@ package com.google.devtools.build.lib.skyframe; import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.skyframe.SkyKey; /** * A {@link com/google/devtools/build/lib/skyframe/ConfiguredTargetValue.java used only in javadoc: * com.google.devtools.build.skyframe.SkyValue} for a {@link ConfiguredTarget}. */ public interface ConfiguredTargetValue extends ConfiguredObjectValue { - static SkyKey key(Label label, BuildConfiguration configuration) { - return ConfiguredTargetKey.of(label, configuration); - } /** Returns the configured target for this value. */ ConfiguredTarget getConfiguredTarget(); 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 8dbe78455ac691..e71742a284bebf 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 @@ -1755,7 +1755,7 @@ private ImmutableMultimap getConfiguredTarg continue; } for (BuildConfiguration depConfig : configs.get(key)) { - skyKeys.add(ConfiguredTargetValue.key(key.getLabel(), depConfig)); + skyKeys.add(ConfiguredTargetKey.of(key.getLabel(), depConfig)); for (AspectDescriptor aspectDescriptor : key.getAspects().getAllAspects()) { skyKeys.add( AspectValue.createAspectKey(key.getLabel(), depConfig, aspectDescriptor, depConfig)); @@ -1783,7 +1783,7 @@ private ImmutableMultimap getConfiguredTarg continue; } for (BuildConfiguration depConfig : configs.get(key)) { - SkyKey configuredTargetKey = ConfiguredTargetValue.key(key.getLabel(), depConfig); + SkyKey configuredTargetKey = ConfiguredTargetKey.of(key.getLabel(), depConfig); if (result.get(configuredTargetKey) == null) { continue; } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/util/SkyframeExecutorTestUtils.java b/src/test/java/com/google/devtools/build/lib/skyframe/util/SkyframeExecutorTestUtils.java index 0c12d8def4f467..ad2e4905e7fb57 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/util/SkyframeExecutorTestUtils.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/util/SkyframeExecutorTestUtils.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.Target; +import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.skyframe.ConfiguredTargetValue; import com.google.devtools.build.lib.skyframe.PackageValue; import com.google.devtools.build.lib.skyframe.SkyFunctions; @@ -88,7 +89,7 @@ public static EvaluationResult evaluate( public static ConfiguredTargetValue getExistingConfiguredTargetValue( SkyframeExecutor skyframeExecutor, Label label, BuildConfiguration config) throws InterruptedException { - SkyKey key = ConfiguredTargetValue.key(label, config); + SkyKey key = ConfiguredTargetKey.of(label, config); return (ConfiguredTargetValue) getExistingValue(skyframeExecutor, key); }