Skip to content

Commit

Permalink
Remove unused methods from JavaInfo.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 658721820
Change-Id: I9f22752eb8c40b6260936f6d9ca9fcc064a52251
  • Loading branch information
jin authored and copybara-github committed Aug 2, 2024
1 parent 273967f commit ff09423
Showing 1 changed file with 0 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.cmdline.Label;
Expand All @@ -40,11 +39,9 @@
import com.google.devtools.build.lib.starlarkbuildapi.java.JavaInfoApi;
import com.google.devtools.build.lib.starlarkbuildapi.java.JavaModuleFlagsProviderApi;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import net.starlark.java.eval.EvalException;
import net.starlark.java.eval.Sequence;
Expand Down Expand Up @@ -103,32 +100,12 @@ public static NestedSet<Artifact> bootClasspath(TransitiveInfoCollection target)
return NestedSetBuilder.emptySet(Order.STABLE_ORDER);
}

public static Optional<Artifact> genSourceJar(TransitiveInfoCollection target)
throws RuleErrorException, EvalException {
Optional<JavaGenJarsProvider> genJarsProviderOpt =
Optional.ofNullable(getJavaInfo(target)).map(javaInfo -> javaInfo.providerJavaGenJars);
if (genJarsProviderOpt.isPresent()) {
return Optional.ofNullable(genJarsProviderOpt.get().getGenSourceJar());
} else {
return Optional.empty();
}
}

public static Optional<JavaCompilationArgsProvider> getCompilationArgsProvider(
TransitiveInfoCollection target) throws RuleErrorException {
return Optional.ofNullable(getJavaInfo(target))
.map(javaInfo -> javaInfo.providerJavaCompilationArgs);
}

public static NestedSet<Artifact> transitiveFullCompileTimeJars(TransitiveInfoCollection target)
throws RuleErrorException {
JavaInfo javaInfo = JavaInfo.getJavaInfo(target);
if (javaInfo != null && javaInfo.providerJavaCompilationArgs != null) {
return javaInfo.providerJavaCompilationArgs.getTransitiveFullCompileTimeJars();
}
return NestedSetBuilder.emptySet(Order.STABLE_ORDER);
}

public static CcInfo ccInfo(TransitiveInfoCollection target) throws RuleErrorException {
JavaInfo javaInfo = JavaInfo.getJavaInfo(target);
if (javaInfo != null && javaInfo.providerJavaCcInfo != null) {
Expand All @@ -151,25 +128,6 @@ public static JavaGenJarsProvider genJarsProvider(TransitiveInfoCollection targe
return JavaGenJarsProvider.EMPTY;
}

public static JavaModuleFlagsProvider moduleFlagsProvider(TransitiveInfoCollection target)
throws RuleErrorException {
JavaInfo javaInfo = JavaInfo.getJavaInfo(target);
if (javaInfo != null && javaInfo.providerModuleFlags != null) {
return javaInfo.providerModuleFlags;
}
return JavaModuleFlagsProvider.EMPTY;
}

public static ImmutableList<NestedSet<LibraryToLink>> transitiveCcNativeLibraries(
Collection<? extends TransitiveInfoCollection> targets) throws RuleErrorException {
ImmutableList.Builder<NestedSet<LibraryToLink>> builder = ImmutableList.builder();
for (TransitiveInfoCollection target : targets) {
CcInfo ccInfo = ccInfo(target);
builder.add(ccInfo.getCcNativeLibraryInfo().getTransitiveCcNativeLibraries());
}
return builder.build();
}

public static ImmutableList<CcInfo> ccInfos(Iterable<? extends TransitiveInfoCollection> targets)
throws RuleErrorException {
ImmutableList.Builder<CcInfo> builder = ImmutableList.builder();
Expand All @@ -179,24 +137,6 @@ public static ImmutableList<CcInfo> ccInfos(Iterable<? extends TransitiveInfoCol
return builder.build();
}

public static ImmutableList<JavaInfo> wrapSequence(Sequence<?> sequence, String what)
throws EvalException {
ImmutableList.Builder<JavaInfo> builder = ImmutableList.builder();
Sequence<Info> infos = Sequence.cast(sequence, Info.class, what);
for (int i = 0; i < infos.size(); i++) {
try {
builder.add(PROVIDER.wrap(infos.get(i)));
} catch (RuleErrorException e) {
throw Starlark.errorf("at index %s of %s, %s", i, what, e.getMessage());
}
}
return builder.build();
}

public static boolean isJavaInfo(Object obj) {
return JavaStarlarkCommon.isInstanceOfProvider(obj, JavaInfo.PROVIDER);
}

public Optional<JavaCompilationArgsProvider> compilationArgsProvider() {
return Optional.ofNullable(providerJavaCompilationArgs);
}
Expand Down Expand Up @@ -242,17 +182,6 @@ public JavaPluginInfo getJavaPluginInfo() {
return providerJavaPlugin;
}

/**
* Returns a stream of providers of the specified class, fetched from the given list of {@link
* JavaInfo}.
*/
public static <C extends JavaInfoInternalProvider> Stream<C> streamProviders(
Iterable<JavaInfo> javaProviders, Class<C> providerClass) {
return Streams.stream(javaProviders)
.map(javaInfo -> javaInfo.getProvider(providerClass))
.filter(Objects::nonNull);
}

/** Returns the instance for the provided providerClass, or <tt>null</tt> if not present. */
// TODO(adonovan): rename these three overloads of getProvider to avoid
// confusion with the unrelated no-arg Info.getProvider method.
Expand Down Expand Up @@ -444,10 +373,6 @@ public ImmutableList<Artifact> getDirectRuntimeJars() {
return directRuntimeJars;
}

/*<Artifact>*/

/*<Artifact>*/

@Override
public Depset /*<Artifact>*/ getTransitiveSourceJars() {
return Depset.of(
Expand Down Expand Up @@ -525,7 +450,6 @@ public Sequence<String> getJavaConstraintsStarlark() {
* NestedSet. If provider is not null, then delegates to mapper all responsibility to fetch
* required NestedSet from provider.
*
* @see JavaInfo#getProviderAsNestedSet(Class, Function, Function)
* @param providerClass provider class. used as key to look up for provider.
* @param mapper Function used to convert provider to NesteSet&lt;S&gt;
* @param <P> type of Provider
Expand Down

0 comments on commit ff09423

Please sign in to comment.