Skip to content

Commit

Permalink
Replace uses of Depset.of(ElementType, NestedSet) with Depset.of(Clas…
Browse files Browse the repository at this point in the history
…s, NestedSet)

The former method was deprecated.

Do only the trivial changes. Other changes will be done separately to make the review easier.

PiperOrigin-RevId: 514004311
Change-Id: Iacf51f3ef3e16c4dfb32158ae1d0ed3b0c899fe0
  • Loading branch information
comius authored and Copybara-Service committed Mar 6, 2023
1 parent 05253dc commit 0ce1748
Show file tree
Hide file tree
Showing 56 changed files with 156 additions and 191 deletions.
Expand Up @@ -684,12 +684,12 @@ public NestedSet<Artifact> getInputFilesForExtraAction(

@Override
public Depset getStarlarkInputs() {
return Depset.of(Artifact.TYPE, getInputs());
return Depset.of(Artifact.class, getInputs());
}

@Override
public Depset getStarlarkOutputs() {
return Depset.of(Artifact.TYPE, NestedSetBuilder.wrap(Order.STABLE_ORDER, getOutputs()));
return Depset.of(Artifact.class, NestedSetBuilder.wrap(Order.STABLE_ORDER, getOutputs()));
}

@Override
Expand Down
Expand Up @@ -147,7 +147,7 @@ private static class DelegatingDefaultInfo extends DefaultInfo {
@Nullable
@Override
public Depset getFiles() {
return Depset.of(Artifact.TYPE, target.getProvider(FileProvider.class).getFilesToBuild());
return Depset.of(Artifact.class, target.getProvider(FileProvider.class).getFilesToBuild());
}

@Nullable
Expand Down
Expand Up @@ -60,7 +60,7 @@ public boolean isImmutable() {
*/
@Override
public Depset /*<Artifact>*/ getFilesToBuildForStarlark() {
return Depset.of(Artifact.TYPE, filesToBuild);
return Depset.of(Artifact.class, filesToBuild);
}

public NestedSet<Artifact> getFilesToBuild() {
Expand Down
Expand Up @@ -287,7 +287,7 @@ public Object getIndex(StarlarkSemantics semantics, Object key) throws EvalExcep

NestedSet<Artifact> result = outputGroups.get(key);
if (result != null) {
return Depset.of(Artifact.TYPE, result);
return Depset.of(Artifact.class, result);
} else {
throw Starlark.errorf("Output group %s not present", key);
}
Expand All @@ -310,7 +310,7 @@ public Object getValue(String name) {
if (result == null) {
return null;
}
return Depset.of(Artifact.TYPE, result);
return Depset.of(Artifact.class, result);
}

@Override
Expand Down
Expand Up @@ -111,9 +111,6 @@ public Iterable<PathFragment> getExtraPaths(Set<PathFragment> manifestPaths) {
//
// Goodnight, prince(ss)?, and sweet dreams.
public static final class SymlinkEntry implements SymlinkEntryApi {

static final Depset.ElementType TYPE = Depset.ElementType.of(SymlinkEntry.class);

private final PathFragment path;
private final Artifact artifact;

Expand Down Expand Up @@ -270,7 +267,7 @@ public NestedSet<Artifact> getExtraMiddlemen() {
/** Returns the collection of runfiles as artifacts. */
@Override
public Depset /*<Artifact>*/ getArtifactsForStarlark() {
return Depset.of(Artifact.TYPE, artifacts);
return Depset.of(Artifact.class, artifacts);
}

public NestedSet<Artifact> getArtifacts() {
Expand All @@ -280,7 +277,7 @@ public NestedSet<Artifact> getArtifacts() {
/** Returns the symlinks. */
@Override
public Depset /*<SymlinkEntry>*/ getSymlinksForStarlark() {
return Depset.of(SymlinkEntry.TYPE, symlinks);
return Depset.of(SymlinkEntry.class, symlinks);
}

public NestedSet<SymlinkEntry> getSymlinks() {
Expand All @@ -289,7 +286,7 @@ public NestedSet<SymlinkEntry> getSymlinks() {

@Override
public Depset /*<String>*/ getEmptyFilenamesForStarlark() {
return Depset.of(Depset.ElementType.STRING, getEmptyFilenames());
return Depset.of(String.class, getEmptyFilenames());
}

public NestedSet<String> getEmptyFilenames() {
Expand Down Expand Up @@ -512,7 +509,7 @@ private static boolean isUnderWorkspace(PathFragment path) {
/** Returns the root symlinks. */
@Override
public Depset /*<SymlinkEntry>*/ getRootSymlinksForStarlark() {
return Depset.of(SymlinkEntry.TYPE, rootSymlinks);
return Depset.of(SymlinkEntry.class, rootSymlinks);
}

public NestedSet<SymlinkEntry> getRootSymlinks() {
Expand Down
Expand Up @@ -1120,7 +1120,7 @@ public Tuple resolveTools(Sequence<?> tools) throws EvalException {
.addToolDependencies(Sequence.cast(tools, TransitiveInfoCollection.class, "tools"))
.build();
return Tuple.pair(
Depset.of(Artifact.TYPE, helper.getResolvedTools()), helper.getToolsRunfilesSuppliers());
Depset.of(Artifact.class, helper.getResolvedTools()), helper.getToolsRunfilesSuppliers());
}

public StarlarkSemantics getStarlarkSemantics() {
Expand Down
Expand Up @@ -15,18 +15,13 @@
package com.google.devtools.build.lib.analysis.test;

import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.Depset;
import com.google.devtools.build.lib.starlarkbuildapi.test.AnalysisFailureApi;
import net.starlark.java.eval.Printer;

/**
* Encapsulates information about an analysis-phase error which would have occurred during a build.
*/
public class AnalysisFailure implements AnalysisFailureApi {

/** The Starlark type symbol for AnalysisFailure values. */
public static final Depset.ElementType TYPE = Depset.ElementType.of(AnalysisFailure.class);

private final Label label;
private final String message;

Expand Down
Expand Up @@ -67,7 +67,7 @@ public static AnalysisFailureInfo forAnalysisFailureSets(

@Override
public Depset /*<AnalysisFailure>*/ getCauses() {
return Depset.of(AnalysisFailure.TYPE, causes);
return Depset.of(AnalysisFailure.class, causes);
}

public NestedSet<AnalysisFailure> getCausesNestedSet() {
Expand Down
Expand Up @@ -77,7 +77,7 @@ public NestedSet<Artifact> getInstrumentedFiles() {

@Override
public Depset getInstrumentedFilesForStarlark() {
return Depset.of(Artifact.TYPE, getInstrumentedFiles());
return Depset.of(Artifact.class, getInstrumentedFiles());
}

/** Returns a collection of instrumentation metadata files. */
Expand All @@ -87,7 +87,7 @@ public NestedSet<Artifact> getInstrumentationMetadataFiles() {

@Override
public Depset getInstrumentationMetadataFilesForStarlark() {
return Depset.of(Artifact.TYPE, getInstrumentationMetadataFiles());
return Depset.of(Artifact.class, getInstrumentationMetadataFiles());
}

/**
Expand Down
Expand Up @@ -168,7 +168,7 @@ public Object getValue(String name) {
// A shortcut for files to build in Starlark. FileConfiguredTarget and RuleConfiguredTarget
// always has FileProvider and Error- and PackageGroupConfiguredTarget-s shouldn't be
// accessible in Starlark.
return Depset.of(Artifact.TYPE, getProvider(FileProvider.class).getFilesToBuild());
return Depset.of(Artifact.class, getProvider(FileProvider.class).getFilesToBuild());
}
return actual.getValue(name);
}
Expand Down
Expand Up @@ -114,7 +114,7 @@ public Artifact getValidationResult() {

@Override
public Depset /*<ParsedAndroidAssets>*/ getDirectParsedAssetsForStarlark() {
return Depset.of(ParsedAndroidAssets.TYPE, directParsedAssets);
return Depset.of(ParsedAndroidAssets.class, directParsedAssets);
}

public NestedSet<ParsedAndroidAssets> getDirectParsedAssets() {
Expand All @@ -135,7 +135,7 @@ public String getLocalAssetDir() {

@Override
public Depset /*<ParsedAndroidAssets>*/ getTransitiveParsedAssetsForStarlark() {
return Depset.of(ParsedAndroidAssets.TYPE, transitiveParsedAssets);
return Depset.of(ParsedAndroidAssets.class, transitiveParsedAssets);
}

public NestedSet<ParsedAndroidAssets> getTransitiveParsedAssets() {
Expand All @@ -144,7 +144,7 @@ public NestedSet<ParsedAndroidAssets> getTransitiveParsedAssets() {

@Override
public Depset /*<Artifact>*/ getAssetsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveAssets);
return Depset.of(Artifact.class, transitiveAssets);
}

public NestedSet<Artifact> getAssets() {
Expand All @@ -153,7 +153,7 @@ public NestedSet<Artifact> getAssets() {

@Override
public Depset /*<Artifact>*/ getSymbolsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveSymbols);
return Depset.of(Artifact.class, transitiveSymbols);
}

public NestedSet<Artifact> getSymbols() {
Expand All @@ -168,7 +168,7 @@ private Optional<ParsedAndroidAssets> getLocalParsedAndroidAssets() {

@Override
public Depset /*<Artifact>*/ getCompiledSymbolsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveCompiledSymbols);
return Depset.of(Artifact.class, transitiveCompiledSymbols);
}

NestedSet<Artifact> getCompiledSymbols() {
Expand Down
Expand Up @@ -57,7 +57,7 @@ public Dict<String, Depset> getNativeLibsStarlark() {
return null;
}
return Dict.immutableCopyOf(
Maps.transformValues(nativeLibs.getMap(), set -> Depset.of(Artifact.TYPE, set)));
Maps.transformValues(nativeLibs.getMap(), set -> Depset.of(Artifact.class, set)));
}

@Nullable
Expand All @@ -75,7 +75,7 @@ public Depset getTransitiveNativeLibsStarlark() {
if (transitiveNativeLibs == null) {
return null;
}
return Depset.of(Artifact.TYPE, transitiveNativeLibs);
return Depset.of(Artifact.class, transitiveNativeLibs);
}

@Nullable
Expand Down
Expand Up @@ -324,7 +324,7 @@ public ImmutableMap<String, NestedSet<Artifact>> getNativeLibs() {
public ImmutableMap<String, Depset> getNativeLibsStarlark() {
ImmutableMap.Builder<String, Depset> builder = ImmutableMap.builder();
for (Map.Entry<String, NestedSet<Artifact>> entry : getNativeLibs().entrySet()) {
builder.put(entry.getKey(), Depset.of(Artifact.TYPE, entry.getValue()));
builder.put(entry.getKey(), Depset.of(Artifact.class, entry.getValue()));
}
return builder.buildOrThrow();
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ public Provider getProvider() {

@Override
public Depset /*<String>*/ getTransitiveIdlImportRootsForStarlark() {
return Depset.of(Depset.ElementType.STRING, transitiveIdlImportRoots);
return Depset.of(String.class, transitiveIdlImportRoots);
}

NestedSet<String> getTransitiveIdlImportRoots() {
Expand All @@ -65,7 +65,7 @@ NestedSet<String> getTransitiveIdlImportRoots() {

@Override
public Depset /*<Artifact>*/ getTransitiveIdlImportsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveIdlImports);
return Depset.of(Artifact.class, transitiveIdlImports);
}

NestedSet<Artifact> getTransitiveIdlImports() {
Expand All @@ -74,7 +74,7 @@ NestedSet<Artifact> getTransitiveIdlImports() {

@Override
public Depset /*<Artifact>*/ getTransitiveIdlJarsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveIdlJars);
return Depset.of(Artifact.class, transitiveIdlJars);
}

NestedSet<Artifact> getTransitiveIdlJars() {
Expand All @@ -83,7 +83,7 @@ NestedSet<Artifact> getTransitiveIdlJars() {

@Override
public Depset /*<Artifact>*/ getTransitiveIdlPreprocessedForStarlark() {
return Depset.of(Artifact.TYPE, transitiveIdlPreprocessed);
return Depset.of(Artifact.class, transitiveIdlPreprocessed);
}

NestedSet<Artifact> getTransitiveIdlPreprocessed() {
Expand Down
Expand Up @@ -85,7 +85,7 @@ public NestedSet<Aar> getTransitiveAars() {

@Override
public Depset /*<Artifact>*/ getTransitiveAarArtifactsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveAarArtifacts);
return Depset.of(Artifact.class, transitiveAarArtifacts);
}

public NestedSet<Artifact> getTransitiveAarArtifacts() {
Expand Down
Expand Up @@ -57,7 +57,7 @@ public static AndroidLibraryResourceClassJarProvider create(

@Override
public Depset /*<Artifact>*/ getResourceClassJarsForStarlark() {
return Depset.of(Artifact.TYPE, resourceClassJars);
return Depset.of(Artifact.class, resourceClassJars);
}

public NestedSet<Artifact> getResourceClassJars() {
Expand Down
Expand Up @@ -47,7 +47,7 @@ public AndroidNativeLibsInfoProvider getProvider() {

@Override
public Depset /*<Artifact>*/ getNativeLibsForStarlark() {
return Depset.of(Artifact.TYPE, nativeLibs);
return Depset.of(Artifact.class, nativeLibs);
}

NestedSet<Artifact> getNativeLibs() {
Expand Down
Expand Up @@ -61,7 +61,7 @@ public NestedSet<Artifact> getTransitiveNeverLinkLibraries() {

@Override
public Depset /*<Artifact>*/ getTransitiveNeverLinkLibrariesForStarlark() {
return Depset.of(Artifact.TYPE, transitiveNeverLinkLibraries);
return Depset.of(Artifact.class, transitiveNeverLinkLibraries);
}

/** Provider class for {@link AndroidNeverLinkLibrariesProvider} objects. */
Expand Down
Expand Up @@ -116,7 +116,7 @@ public Artifact getRTxt() {

@Override
public Depset /*<ValidatedAndroidResources>*/ getTransitiveAndroidResourcesForStarlark() {
return Depset.of(ValidatedAndroidResources.TYPE, transitiveAndroidResources);
return Depset.of(ValidatedAndroidResources.class, transitiveAndroidResources);
}

public NestedSet<ValidatedAndroidResources> getTransitiveAndroidResources() {
Expand All @@ -125,7 +125,7 @@ public NestedSet<ValidatedAndroidResources> getTransitiveAndroidResources() {

@Override
public Depset /*<ValidatedAndroidResources>*/ getDirectAndroidResourcesForStarlark() {
return Depset.of(ValidatedAndroidResources.TYPE, directAndroidResources);
return Depset.of(ValidatedAndroidResources.class, directAndroidResources);
}

public NestedSet<ValidatedAndroidResources> getDirectAndroidResources() {
Expand All @@ -134,7 +134,7 @@ public NestedSet<ValidatedAndroidResources> getDirectAndroidResources() {

@Override
public Depset /*<Artifact>*/ getTransitiveResourcesForStarlark() {
return Depset.of(Artifact.TYPE, transitiveResources);
return Depset.of(Artifact.class, transitiveResources);
}

public NestedSet<Artifact> getTransitiveResources() {
Expand All @@ -143,7 +143,7 @@ public NestedSet<Artifact> getTransitiveResources() {

@Override
public Depset /*<Artifact>*/ getTransitiveManifestsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveManifests);
return Depset.of(Artifact.class, transitiveManifests);
}

public NestedSet<Artifact> getTransitiveManifests() {
Expand All @@ -152,7 +152,7 @@ public NestedSet<Artifact> getTransitiveManifests() {

@Override
public Depset /*<Artifact>*/ getTransitiveAapt2RTxtForStarlark() {
return Depset.of(Artifact.TYPE, transitiveAapt2RTxt);
return Depset.of(Artifact.class, transitiveAapt2RTxt);
}

public NestedSet<Artifact> getTransitiveAapt2RTxt() {
Expand All @@ -161,7 +161,7 @@ public NestedSet<Artifact> getTransitiveAapt2RTxt() {

@Override
public Depset /*<Artifact>*/ getTransitiveAapt2ValidationArtifactsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveAapt2ValidationArtifacts);
return Depset.of(Artifact.class, transitiveAapt2ValidationArtifacts);
}

NestedSet<Artifact> getTransitiveAapt2ValidationArtifacts() {
Expand All @@ -170,7 +170,7 @@ NestedSet<Artifact> getTransitiveAapt2ValidationArtifacts() {

@Override
public Depset /*<Artifact>*/ getTransitiveSymbolsBinForStarlark() {
return Depset.of(Artifact.TYPE, transitiveSymbolsBin);
return Depset.of(Artifact.class, transitiveSymbolsBin);
}

public NestedSet<Artifact> getTransitiveSymbolsBin() {
Expand All @@ -179,7 +179,7 @@ public NestedSet<Artifact> getTransitiveSymbolsBin() {

@Override
public Depset /*<Artifact>*/ getTransitiveCompiledSymbolsForStarlark() {
return Depset.of(Artifact.TYPE, transitiveCompiledSymbols);
return Depset.of(Artifact.class, transitiveCompiledSymbols);
}

NestedSet<Artifact> getTransitiveCompiledSymbols() {
Expand All @@ -188,7 +188,7 @@ NestedSet<Artifact> getTransitiveCompiledSymbols() {

@Override
public Depset /*<Artifact>*/ getTransitiveStaticLibForStarlark() {
return Depset.of(Artifact.TYPE, transitiveStaticLib);
return Depset.of(Artifact.class, transitiveStaticLib);
}

NestedSet<Artifact> getTransitiveStaticLib() {
Expand All @@ -197,7 +197,7 @@ NestedSet<Artifact> getTransitiveStaticLib() {

@Override
public Depset /*<Artifact>*/ getTransitiveRTxtForStarlark() {
return Depset.of(Artifact.TYPE, transitiveRTxt);
return Depset.of(Artifact.class, transitiveRTxt);
}

NestedSet<Artifact> getTransitiveRTxt() {
Expand Down

0 comments on commit 0ce1748

Please sign in to comment.