diff --git a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/ClassCache.java b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/ClassCache.java index e2368f28259900..917fb33212c0e0 100644 --- a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/ClassCache.java +++ b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/ClassCache.java @@ -29,6 +29,7 @@ import com.google.devtools.build.importdeps.AbstractClassEntryState.MissingState; import com.google.devtools.build.importdeps.ClassInfo.MemberInfo; import org.objectweb.asm.Opcodes; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; @@ -412,11 +413,13 @@ void setNames(String name, String superName, String[] interfaces) { superClasses = combineWithoutNull(superName, interfaces); } + @CanIgnoreReturnValue public ClassInfoBuilder setJarPath(Path jarPath) { this.jarPath = jarPath; return this; } + @CanIgnoreReturnValue public ClassInfoBuilder setDirect(boolean direct) { this.directDep = direct; return this; diff --git a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/DepsCheckerClassVisitor.java b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/DepsCheckerClassVisitor.java index c648ceb702e6fd..c941053337f1bf 100644 --- a/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/DepsCheckerClassVisitor.java +++ b/src/java_tools/import_deps_checker/java/com/google/devtools/build/importdeps/DepsCheckerClassVisitor.java @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableSet; import com.google.devtools.build.importdeps.ClassInfo.MemberInfo; import org.objectweb.asm.Opcodes; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Optional; import javax.annotation.Nullable; import org.objectweb.asm.AnnotationVisitor; @@ -233,6 +234,7 @@ private class DepsCheckerAnnotationVisitor extends AnnotationVisitor { super(Opcodes.ASM9); } + @CanIgnoreReturnValue @Override public AnnotationVisitor visitAnnotation(String name, String desc) { checkDescriptor(desc); diff --git a/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/FakeZipFile.java b/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/FakeZipFile.java index ec4924065d94f6..05eaa07970dcbe 100644 --- a/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/FakeZipFile.java +++ b/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/FakeZipFile.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static java.nio.charset.StandardCharsets.UTF_8; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -135,56 +136,65 @@ public void assertNext(ZipInputStream zipInput) throws IOException { private final List entries = new ArrayList<>(); + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, String content) { entries.add(new FakeZipEntry(name, null, content, null, EntryMode.DONT_CARE)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, String content, boolean compressed) { entries.add(new FakeZipEntry(name, null, content, null, compressed ? EntryMode.EXPECT_DEFLATE : EntryMode.EXPECT_STORED)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, Date date, String content) { entries.add(new FakeZipEntry(name, date, content, null, EntryMode.DONT_CARE)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, Date date, String content, boolean compressed) { entries.add(new FakeZipEntry(name, date, content, null, compressed ? EntryMode.EXPECT_DEFLATE : EntryMode.EXPECT_STORED)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, ByteValidator content) { entries.add(new FakeZipEntry(name, null, content, null, EntryMode.DONT_CARE)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, ByteValidator content, boolean compressed) { entries.add(new FakeZipEntry(name, null, content, null, compressed ? EntryMode.EXPECT_DEFLATE : EntryMode.EXPECT_STORED)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, Date date, ByteValidator content) { entries.add(new FakeZipEntry(name, date, content, null, EntryMode.DONT_CARE)); return this; } - public FakeZipFile addEntry(String name, Date date, ByteValidator content, - boolean compressed) { + @CanIgnoreReturnValue + public FakeZipFile addEntry(String name, Date date, ByteValidator content, boolean compressed) { entries.add(new FakeZipEntry(name, date, content, null, compressed ? EntryMode.EXPECT_DEFLATE : EntryMode.EXPECT_STORED)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, byte[] extra) { entries.add(new FakeZipEntry(name, null, (String) null, extra, EntryMode.DONT_CARE)); return this; } + @CanIgnoreReturnValue public FakeZipFile addEntry(String name, byte[] extra, boolean compressed) { entries.add(new FakeZipEntry(name, null, (String) null, extra, compressed ? EntryMode.EXPECT_DEFLATE : EntryMode.EXPECT_STORED)); @@ -193,6 +203,7 @@ public FakeZipFile addEntry(String name, byte[] extra, boolean compressed) { private byte[] preamble = null; + @CanIgnoreReturnValue public FakeZipFile addPreamble(byte[] contents) { preamble = Arrays.copyOf(contents, contents.length); return this; diff --git a/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/ZipFactory.java b/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/ZipFactory.java index e102d8a435aa30..da87d08b7d39cc 100644 --- a/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/ZipFactory.java +++ b/src/java_tools/singlejar/javatests/com/google/devtools/build/singlejar/ZipFactory.java @@ -16,6 +16,7 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -49,21 +50,25 @@ private void addEntry(String name, byte[] content, boolean compressed) { entries.add(new Entry(name, content, compressed)); } + @CanIgnoreReturnValue public ZipFactory addFile(String name, String content) { addEntry(name, content.getBytes(ISO_8859_1), true); return this; } + @CanIgnoreReturnValue public ZipFactory addFile(String name, byte[] content) { addEntry(name, content.clone(), true); return this; } + @CanIgnoreReturnValue public ZipFactory addFile(String name, String content, boolean compressed) { addEntry(name, content.getBytes(ISO_8859_1), compressed); return this; } + @CanIgnoreReturnValue public ZipFactory addFile(String name, byte[] content, boolean compressed) { addEntry(name, content.clone(), compressed); return this; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java index d1d5795a6f1ab7..b9d655e0208dd8 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java @@ -42,6 +42,7 @@ import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParsingResult; import com.google.devtools.common.options.OptionsProvider; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -89,51 +90,61 @@ public static final class Builder { private Builder() {} + @CanIgnoreReturnValue public Builder setId(UUID id) { this.id = id; return this; } + @CanIgnoreReturnValue public Builder setOptions(OptionsParsingResult options) { this.options = options; return this; } + @CanIgnoreReturnValue public Builder setStartupOptions(OptionsParsingResult startupOptions) { this.startupOptions = startupOptions; return this; } + @CanIgnoreReturnValue public Builder setCommandName(String commandName) { this.commandName = commandName; return this; } + @CanIgnoreReturnValue public Builder setOutErr(OutErr outErr) { this.outErr = outErr; return this; } + @CanIgnoreReturnValue public Builder setTargets(List targets) { this.targets = targets; return this; } + @CanIgnoreReturnValue public Builder setStartTimeMillis(long startTimeMillis) { this.startTimeMillis = startTimeMillis; return this; } + @CanIgnoreReturnValue public Builder setNeedsInstrumentationFilter(boolean needsInstrumentationFilter) { this.needsInstrumentationFilter = needsInstrumentationFilter; return this; } + @CanIgnoreReturnValue public Builder setRunTests(boolean runTests) { this.runTests = runTests; return this; } + @CanIgnoreReturnValue public Builder setCheckforActionConflicts(boolean checkForActionConflicts) { this.checkForActionConflicts = checkForActionConflicts; return this; @@ -148,6 +159,7 @@ public Builder setCheckforActionConflicts(boolean checkForActionConflicts) { * output) and false for queries (where users want to understand target relationships or * diagnose why incompatible targets are incompatible). */ + @CanIgnoreReturnValue public Builder setReportIncompatibleTargets(boolean report) { this.reportIncompatibleTargets = report; return this; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java index d4133be7511567..02f92b80214b2c 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java @@ -33,6 +33,7 @@ import com.google.devtools.build.lib.util.ExitCode; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.vfs.Path; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.protobuf.ByteString; import java.util.ArrayList; import java.util.Collection; @@ -281,6 +282,7 @@ public static final class BuildToolLogCollection { private final List localFiles = new ArrayList<>(); private boolean frozen; + @CanIgnoreReturnValue public BuildToolLogCollection freeze() { frozen = true; return this; @@ -291,18 +293,21 @@ public List getLocalFiles() { return localFiles; } + @CanIgnoreReturnValue public BuildToolLogCollection addDirectValue(String name, byte[] data) { Preconditions.checkState(!frozen); this.directValues.add(Pair.of(name, ByteString.copyFrom(data))); return this; } + @CanIgnoreReturnValue public BuildToolLogCollection addUri(String name, String uri) { Preconditions.checkState(!frozen); this.futureUris.add(Pair.of(name, Futures.immediateFuture(uri))); return this; } + @CanIgnoreReturnValue public BuildToolLogCollection addUriFuture(String name, ListenableFuture uriFuture) { Preconditions.checkState(!frozen); this.futureUris.add(Pair.of(name, uriFuture)); @@ -313,6 +318,7 @@ public BuildToolLogCollection addLocalFile(String name, Path path) { return addLocalFile(name, path, LocalFileType.LOG, LocalFileCompression.NONE); } + @CanIgnoreReturnValue public BuildToolLogCollection addLocalFile( String name, Path path, LocalFileType localFileType, LocalFileCompression compression) { Preconditions.checkState(!frozen); diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java b/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java index f368cb97937b95..f36eb6893347b7 100644 --- a/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/concurrent/ForkJoinQuiescingExecutor.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.concurrent; import com.google.common.base.Preconditions; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; @@ -43,10 +44,11 @@ private Builder() { } /** - * Sets the {@link ForkJoinPool} that will be used by the to-be-built - * {@link ForkJoinQuiescingExecutor}. The given {@link ForkJoinPool} will be shut down on - * completion of the {@link ForkJoinQuiescingExecutor}. + * Sets the {@link ForkJoinPool} that will be used by the to-be-built {@link + * ForkJoinQuiescingExecutor}. The given {@link ForkJoinPool} will be shut down on completion of + * the {@link ForkJoinQuiescingExecutor}. */ + @CanIgnoreReturnValue public Builder withOwnershipOf(ForkJoinPool forkJoinPool) { Preconditions.checkState(this.forkJoinPool == null); this.forkJoinPool = forkJoinPool; @@ -54,9 +56,10 @@ public Builder withOwnershipOf(ForkJoinPool forkJoinPool) { } /** - * Sets the {@link ErrorClassifier} that will be used by the to-be-built - * {@link ForkJoinQuiescingExecutor}. + * Sets the {@link ErrorClassifier} that will be used by the to-be-built {@link + * ForkJoinQuiescingExecutor}. */ + @CanIgnoreReturnValue public Builder setErrorClassifier(ErrorClassifier errorClassifier) { this.errorClassifier = errorClassifier; return this; diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/MultisetSemaphore.java b/src/main/java/com/google/devtools/build/lib/concurrent/MultisetSemaphore.java index 471a6dff5bad03..b0de2034bafb3a 100644 --- a/src/main/java/com/google/devtools/build/lib/concurrent/MultisetSemaphore.java +++ b/src/main/java/com/google/devtools/build/lib/concurrent/MultisetSemaphore.java @@ -17,6 +17,7 @@ import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Set; import java.util.concurrent.Semaphore; @@ -83,6 +84,7 @@ private Builder() { * Sets the maximum number of unique values for which permits can be held at once in the * to-be-constructed {@link MultisetSemaphore}. */ + @CanIgnoreReturnValue public Builder maxNumUniqueValues(int maxNumUniqueValues) { Preconditions.checkState( maxNumUniqueValues > 0, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/ObjectCodecTester.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/ObjectCodecTester.java index 4969cb4df81b6b..d57a0111e77ed4 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/ObjectCodecTester.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/ObjectCodecTester.java @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec; import com.google.devtools.build.lib.skyframe.serialization.SerializationContext; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.protobuf.CodedInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -156,12 +157,14 @@ public final Builder addSubjects(T... subjects) { } /** Add subjects to be tested for serialization/deserialization. */ + @CanIgnoreReturnValue public Builder addSubjects(ImmutableList subjects) { subjectsBuilder.addAll(subjects); return this; } /** Add subjects to be tested for serialization/deserialization. */ + @CanIgnoreReturnValue public final Builder addDependency(Class type, D dependency) { dependenciesBuilder.put(type, dependency); return this; @@ -171,21 +174,24 @@ public final Builder addDependency(Class type, D dependency) { * Skip tests that check for the ability to detect bad data. This may be useful for simpler * codecs which don't do any error verification. */ + @CanIgnoreReturnValue public Builder skipBadDataTest() { this.skipBadDataTest = true; return this; } /** - * Sets {@link ObjectCodecTester.VerificationFunction} for verifying deserialization. Default - * is simple equality assertion, a custom version may be provided for more, or less, detailed + * Sets {@link ObjectCodecTester.VerificationFunction} for verifying deserialization. Default is + * simple equality assertion, a custom version may be provided for more, or less, detailed * checks. */ + @CanIgnoreReturnValue public Builder verificationFunction(VerificationFunction verificationFunction) { this.verificationFunction = Preconditions.checkNotNull(verificationFunction); return this; } + @CanIgnoreReturnValue public Builder setRepetitions(int repetitions) { this.repetitions = repetitions; return this; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/SerializationTester.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/SerializationTester.java index 0022d663ebe405..4fc5565d0a0b3e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/SerializationTester.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/testutils/SerializationTester.java @@ -28,6 +28,7 @@ import com.google.devtools.build.lib.skyframe.serialization.ObjectCodecRegistry; import com.google.devtools.build.lib.skyframe.serialization.ObjectCodecs; import com.google.devtools.build.lib.skyframe.serialization.SerializationException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.protobuf.ByteString; import java.util.ArrayList; import java.util.Random; @@ -78,37 +79,44 @@ public SerializationTester(ImmutableList subjects) { this.subjects = subjects; } + @CanIgnoreReturnValue public SerializationTester addDependency(Class type, D dependency) { dependenciesBuilder.put(type, dependency); return this; } + @CanIgnoreReturnValue public SerializationTester addDependencies(ClassToInstanceMap dependencies) { dependenciesBuilder.putAll(dependencies); return this; } + @CanIgnoreReturnValue public SerializationTester addCodec(ObjectCodec codec) { additionalCodecs.add(codec); return this; } + @CanIgnoreReturnValue public SerializationTester makeMemoizing() { this.memoize = true; return this; } + @CanIgnoreReturnValue public SerializationTester makeMemoizingAndAllowFutureBlocking(boolean allowFutureBlocking) { makeMemoizing(); this.allowFutureBlocking = allowFutureBlocking; return this; } + @CanIgnoreReturnValue public SerializationTester setObjectCodecs(ObjectCodecs objectCodecs) { this.objectCodecs = objectCodecs; return this; } + @CanIgnoreReturnValue public SerializationTester setVerificationFunction( VerificationFunction verificationFunction) { this.verificationFunction = verificationFunction; @@ -116,6 +124,7 @@ public SerializationTester setVerificationFunction( } /** Sets the number of times to repeat serialization and deserialization. */ + @CanIgnoreReturnValue public SerializationTester setRepetitions(int repetitions) { this.repetitions = repetitions; return this; diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ModifiedFileSet.java b/src/main/java/com/google/devtools/build/lib/vfs/ModifiedFileSet.java index 7a8db52c6ae993..500cd9d5b4dbaf 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/ModifiedFileSet.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/ModifiedFileSet.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.vfs; import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Objects; import javax.annotation.Nullable; @@ -118,11 +119,13 @@ public ModifiedFileSet build() { return modified.isEmpty() ? NOTHING_MODIFIED : new ModifiedFileSet(modified); } + @CanIgnoreReturnValue public Builder modify(PathFragment pathFragment) { setBuilder.add(pathFragment); return this; } + @CanIgnoreReturnValue public Builder modifyAll(Iterable pathFragments) { setBuilder.addAll(pathFragments); return this; diff --git a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java index 7d1e464cf963a3..2ae12c4990ff83 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/UnixGlob.java @@ -31,6 +31,7 @@ import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.ProfilerTask; import com.google.devtools.build.lib.profiler.SilentCloseable; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -302,6 +303,7 @@ public Builder(Path base, SyscallCache syscallCache) { * *

For a description of the syntax of the patterns, see {@link UnixGlob}. */ + @CanIgnoreReturnValue public Builder addPattern(String pattern) { this.patterns.add(pattern); return this; @@ -312,6 +314,7 @@ public Builder addPattern(String pattern) { * *

For a description of the syntax of the patterns, see {@link UnixGlob}. */ + @CanIgnoreReturnValue public Builder addPatterns(String... patterns) { Collections.addAll(this.patterns, patterns); return this; @@ -322,6 +325,7 @@ public Builder addPatterns(String... patterns) { * *

For a description of the syntax of the patterns, see {@link UnixGlob}. */ + @CanIgnoreReturnValue public Builder addPatterns(Collection patterns) { this.patterns.addAll(patterns); return this; @@ -331,6 +335,7 @@ public Builder addPatterns(Collection patterns) { * Sets the executor to use for parallel glob evaluation. If unset, evaluation is done * in-thread. */ + @CanIgnoreReturnValue public Builder setExecutor(Executor pool) { this.executor = pool; return this; @@ -348,6 +353,7 @@ public Builder setExecutor(Executor pool) { * exclude files from the glob and decide which directories to traverse, like skipping sub-dirs * containing BUILD files. */ + @CanIgnoreReturnValue public Builder setPathDiscriminator(UnixGlobPathDiscriminator pathDiscriminator) { this.pathDiscriminator = pathDiscriminator; return this; diff --git a/src/test/java/com/google/devtools/build/lib/remote/FakeExecutionService.java b/src/test/java/com/google/devtools/build/lib/remote/FakeExecutionService.java index 47f5201f90ee92..4c9d93989449dc 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/FakeExecutionService.java +++ b/src/test/java/com/google/devtools/build/lib/remote/FakeExecutionService.java @@ -18,6 +18,7 @@ import build.bazel.remote.execution.v2.ExecutionGrpc.ExecutionImplBase; import build.bazel.remote.execution.v2.WaitExecutionRequest; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.longrunning.Operation; import com.google.protobuf.Any; import com.google.rpc.Code; @@ -93,6 +94,7 @@ public OnetimeOperationSupplierBuilder(OperationProvider provider, ExecuteReques this.request = request; } + @CanIgnoreReturnValue public OnetimeOperationSupplierBuilder thenAck() { Operation operation = ackOperation(request); operations.add(() -> operation); diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoStarlarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoStarlarkApiTest.java index 484dc774755072..c4379cdb3f0dac 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoStarlarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoStarlarkApiTest.java @@ -28,6 +28,7 @@ import com.google.devtools.build.lib.packages.StructImpl; import com.google.devtools.build.lib.rules.cpp.LibraryToLink; import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.JavaOutput; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -865,21 +866,25 @@ private class RuleBuilder { private boolean neverLink = false; private boolean sourceFiles = false; + @CanIgnoreReturnValue private RuleBuilder withIJar() { useIJar = true; return this; } + @CanIgnoreReturnValue private RuleBuilder withStampJar() { stampJar = true; return this; } + @CanIgnoreReturnValue private RuleBuilder withNeverLink() { neverLink = true; return this; } + @CanIgnoreReturnValue private RuleBuilder withSourceFiles() { sourceFiles = true; return this; diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTestCase.java index d39f4c828e1579..c42bb19ef158dd 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/PlatformTestCase.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.analysis.platform.PlatformProviderUtils; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -60,12 +61,14 @@ public ConstraintBuilder(String name) { this.label = Label.parseAbsoluteUnchecked(name); } + @CanIgnoreReturnValue public ConstraintBuilder defaultConstraintValue(String defaultConstraintValue) { this.defaultConstraintValue = defaultConstraintValue; this.constraintValues.add(defaultConstraintValue); return this; } + @CanIgnoreReturnValue public ConstraintBuilder addConstraintValue(String constraintValue) { this.constraintValues.add(constraintValue); return this; @@ -111,21 +114,25 @@ public PlatformBuilder(String name) { this.label = Label.parseAbsoluteUnchecked(name); } + @CanIgnoreReturnValue public PlatformBuilder setParent(String parentLabel) { this.parentLabel = Label.parseAbsoluteUnchecked(parentLabel); return this; } + @CanIgnoreReturnValue public PlatformBuilder addConstraint(String value) { this.constraintValues.add(value); return this; } + @CanIgnoreReturnValue public PlatformBuilder setRemoteExecutionProperties(String value) { this.remoteExecutionProperties = value; return this; } + @CanIgnoreReturnValue public PlatformBuilder setExecProperties(ImmutableMap value) { this.execProperties = value; return this; diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/LocalDiffAwarenessTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/LocalDiffAwarenessTest.java index cf907b6b2010e8..12bf59558ce75a 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/LocalDiffAwarenessTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/LocalDiffAwarenessTest.java @@ -31,6 +31,7 @@ import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.common.options.OptionsProvider; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.nio.file.Paths; import java.util.Set; @@ -342,6 +343,7 @@ public void checkEverythingModified(OptionsProvider options) throws Exception { assertThat(modifiedFileSet.treatEverythingAsModified()).isTrue(); } + @CanIgnoreReturnValue public ModifiedFileSetChecker modify(String filename) { modified.add(PathFragment.create(filename)); return this; diff --git a/src/test/java/com/google/devtools/build/lib/starlark/util/BazelEvaluationTestCase.java b/src/test/java/com/google/devtools/build/lib/starlark/util/BazelEvaluationTestCase.java index 81a5e6d5b98b91..3728124b04467b 100644 --- a/src/test/java/com/google/devtools/build/lib/starlark/util/BazelEvaluationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/starlark/util/BazelEvaluationTestCase.java @@ -34,6 +34,7 @@ import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.common.options.Options; import com.google.devtools.common.options.OptionsParsingException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; import net.starlark.java.eval.EvalException; @@ -92,6 +93,7 @@ final Expression parseExpression(String... lines) throws SyntaxError.Exception { /** Updates a global binding in the module. */ // TODO(adonovan): rename setGlobal. + @CanIgnoreReturnValue public BazelEvaluationTestCase update(String varname, Object value) throws Exception { getModule().setGlobal(varname, value); return this; @@ -197,11 +199,13 @@ public void checkEvalErrorDoesNotContain(String msg, String... input) throws Exc } // Forward relevant methods to the EventCollectionApparatus + @CanIgnoreReturnValue public BazelEvaluationTestCase setFailFast(boolean failFast) { eventCollectionApparatus.setFailFast(failFast); return this; } + @CanIgnoreReturnValue public BazelEvaluationTestCase assertNoWarningsOrErrors() { eventCollectionApparatus.assertNoWarningsOrErrors(); return this; @@ -223,6 +227,7 @@ public Event assertContainsDebug(String expectedMessage) { return eventCollectionApparatus.assertContainsDebug(expectedMessage); } + @CanIgnoreReturnValue public BazelEvaluationTestCase clearEvents() { eventCollectionApparatus.clear(); return this; @@ -251,6 +256,7 @@ private void run(Testable testable) throws Exception { } /** Allows the execution of several statements before each following test. */ + @CanIgnoreReturnValue public Scenario setUp(String... lines) { setup.registerExec(lines); return this; @@ -263,6 +269,7 @@ public Scenario setUp(String... lines) { * @param value The new value of the variable * @return This {@code Scenario} */ + @CanIgnoreReturnValue public Scenario update(String name, Object value) { setup.registerUpdate(name, value); return this; @@ -276,36 +283,42 @@ public Scenario update(String name, Object value) { * @return This {@code Scenario} * @throws Exception */ + @CanIgnoreReturnValue public Scenario testEval(String src, String expectedEvalString) throws Exception { runTest(createComparisonTestable(src, expectedEvalString, true)); return this; } /** Evaluates an expression and compares its result to the expected object. */ + @CanIgnoreReturnValue public Scenario testExpression(String src, Object expected) throws Exception { runTest(createComparisonTestable(src, expected, false)); return this; } /** Evaluates an expression and compares its result to the ordered list of expected objects. */ + @CanIgnoreReturnValue public Scenario testExactOrder(String src, Object... items) throws Exception { runTest(collectionTestable(src, items)); return this; } /** Evaluates an expression and checks whether it fails with the expected error. */ + @CanIgnoreReturnValue public Scenario testIfExactError(String expectedError, String... lines) throws Exception { runTest(errorTestable(true, expectedError, lines)); return this; } /** Evaluates the expression and checks whether it fails with the expected error. */ + @CanIgnoreReturnValue public Scenario testIfErrorContains(String expectedError, String... lines) throws Exception { runTest(errorTestable(false, expectedError, lines)); return this; } /** Looks up the value of the specified variable and compares it to the expected value. */ + @CanIgnoreReturnValue public Scenario testLookup(String name, Object expected) throws Exception { runTest(createLookUpTestable(name, expected)); return this; diff --git a/src/test/java/com/google/devtools/build/lib/worker/SandboxHelper.java b/src/test/java/com/google/devtools/build/lib/worker/SandboxHelper.java index e0ccb0041299a6..c286f6278dac61 100644 --- a/src/test/java/com/google/devtools/build/lib/worker/SandboxHelper.java +++ b/src/test/java/com/google/devtools/build/lib/worker/SandboxHelper.java @@ -21,6 +21,7 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -57,6 +58,7 @@ public SandboxHelper(Path execRoot, Path workDir) { * Adds a regular input file at relativePath under {@code workDir}, with the real file at {@code * workspacePath} under {@code execRoot}. */ + @CanIgnoreReturnValue public SandboxHelper addInputFile(String relativePath, String workspacePath) { inputs.put( PathFragment.create(relativePath), @@ -69,6 +71,7 @@ public SandboxHelper addInputFile(String relativePath, String workspacePath) { * {@code workspacePath} under {@code execRoot}. The real file gets created immediately and filled * with {@code contents}, which is assumed to be ASCII text. */ + @CanIgnoreReturnValue public SandboxHelper addAndCreateInputFile( String relativePath, String workspacePath, String contents) throws IOException { addInputFile(relativePath, workspacePath); @@ -79,24 +82,28 @@ public SandboxHelper addAndCreateInputFile( } /** Adds a virtual input with some contents, which is assumed to be ASCII text. */ + @CanIgnoreReturnValue public SandboxHelper addAndCreateVirtualInput(String relativePath, String contents) { virtualInputs.put(PathFragment.create(relativePath), contents); return this; } /** Adds a symlink to the inputs. */ + @CanIgnoreReturnValue public SandboxHelper addSymlink(String relativePath, String linkTo) { symlinks.put(PathFragment.create(relativePath), PathFragment.create(linkTo)); return this; } /** Adds an output file without creating it. */ + @CanIgnoreReturnValue public SandboxHelper addOutput(String relativePath) { outputFiles.add(PathFragment.create(relativePath)); return this; } /** Adds an output directory without creating it. */ + @CanIgnoreReturnValue public SandboxHelper addOutputDir(String relativePath) { outputDirs.add( PathFragment.create(relativePath.endsWith("/") ? relativePath : relativePath + "/")); @@ -107,6 +114,7 @@ public SandboxHelper addOutputDir(String relativePath) { * Adds a worker file that is created under {@code execRoot} and referenced under the {@code * workDir}. */ + @CanIgnoreReturnValue public SandboxHelper addWorkerFile(String relativePath) { Path absPath = execRoot.getRelative(relativePath); workerFiles.put(PathFragment.create(relativePath), absPath); @@ -117,6 +125,7 @@ public SandboxHelper addWorkerFile(String relativePath) { * Adds a worker file that is created under {@code execRoot} and referenced under the {@code * workDir}. Writes the content, which is assumed to be ASCII text, under {@code execRoot}. */ + @CanIgnoreReturnValue public SandboxHelper addAndCreateWorkerFile(String relativePath, String contents) throws IOException { addWorkerFile(relativePath); @@ -130,6 +139,7 @@ public SandboxHelper addAndCreateWorkerFile(String relativePath, String contents * Creates a file with {@code contents}, which is assumed to be ASCII text, at {@code relPath} * under the {@code workDir}. */ + @CanIgnoreReturnValue public SandboxHelper createExecRootFile(String relativePath, String contents) throws IOException { Path absPath = workDir.getRelative(relativePath); absPath.getParentDirectory().createDirectoryAndParents(); @@ -141,6 +151,7 @@ public SandboxHelper createExecRootFile(String relativePath, String contents) th * Creates a file with {@code contents}, which is assumed to be ASCII text, at {@code relPath} * under the {@code workDir}. */ + @CanIgnoreReturnValue public SandboxHelper createWorkspaceDirFile(String workspaceDirPath, String contents) throws IOException { Path absPath = execRoot.getRelative(workspaceDirPath); @@ -153,6 +164,7 @@ public SandboxHelper createWorkspaceDirFile(String workspaceDirPath, String cont * Creates a symlink from within the {@code workDir}. The destination is just what's written into * the symlink and thus relative to the created symlink. */ + @CanIgnoreReturnValue public SandboxHelper createSymlink(String relativePath, String relativeDestination) throws IOException { Path fromPath = workDir.getRelative(relativePath); @@ -165,6 +177,7 @@ public SandboxHelper createSymlink(String relativePath, String relativeDestinati * given contents, which is assumed to be ASCII text. The destination is just what's written into * the symlink and thus relative to the created symlink. */ + @CanIgnoreReturnValue public SandboxHelper createSymlinkWithContents( String relativePath, String relativeDestination, String contents) throws IOException { createSymlink(relativePath, relativeDestination); diff --git a/src/test/java/net/starlark/java/eval/EvaluationTestCase.java b/src/test/java/net/starlark/java/eval/EvaluationTestCase.java index a589f7f8e94657..85588328f18aa9 100644 --- a/src/test/java/net/starlark/java/eval/EvaluationTestCase.java +++ b/src/test/java/net/starlark/java/eval/EvaluationTestCase.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.LinkedList; import java.util.List; import net.starlark.java.syntax.FileOptions; @@ -53,6 +54,7 @@ private final void setSemantics(StarlarkSemantics semantics) { /** Updates a global binding in the module. */ // TODO(adonovan): rename setGlobal. + @CanIgnoreReturnValue final EvaluationTestCase update(String varname, Object value) throws Exception { getModule().setGlobal(varname, value); return this; @@ -184,6 +186,7 @@ private void run(Testable testable) throws Exception { } /** Allows the execution of several statements before each following test. */ + @CanIgnoreReturnValue Scenario setUp(String... lines) { setup.registerExec(lines); return this; @@ -196,6 +199,7 @@ Scenario setUp(String... lines) { * @param value The new value of the variable * @return This {@code Scenario} */ + @CanIgnoreReturnValue Scenario update(String name, Object value) { setup.registerUpdate(name, value); return this; @@ -209,24 +213,28 @@ Scenario update(String name, Object value) { * @return This {@code Scenario} * @throws Exception */ + @CanIgnoreReturnValue Scenario testEval(String src, String expectedEvalString) throws Exception { runTest(createComparisonTestable(src, expectedEvalString, true)); return this; } /** Evaluates an expression and compares its result to the expected object. */ + @CanIgnoreReturnValue Scenario testExpression(String src, Object expected) throws Exception { runTest(createComparisonTestable(src, expected, false)); return this; } /** Evaluates an expression and compares its result to the ordered list of expected objects. */ + @CanIgnoreReturnValue Scenario testExactOrder(String src, Object... items) throws Exception { runTest(collectionTestable(src, items)); return this; } /** Evaluates an expression and checks whether it fails with the expected error. */ + @CanIgnoreReturnValue Scenario testIfExactError(String expectedError, String... lines) throws Exception { runTest(errorTestable(true, expectedError, lines)); return this; @@ -241,6 +249,7 @@ Scenario testIfExactError(String expectedError, String... lines) throws Exceptio * @param failingLine 1-based line where the error is expected. * @param failingColumn 1-based column where the error is expected. */ + @CanIgnoreReturnValue Scenario testIfExactErrorAtLocation( String expectedError, int failingLine, int failingColumn, String... lines) throws Exception { @@ -249,12 +258,14 @@ Scenario testIfExactErrorAtLocation( } /** Evaluates the expresson and checks whether it fails with the expected error. */ + @CanIgnoreReturnValue Scenario testIfErrorContains(String expectedError, String... lines) throws Exception { runTest(errorTestable(false, expectedError, lines)); return this; } /** Looks up the value of the specified variable and compares it to the expected value. */ + @CanIgnoreReturnValue Scenario testLookup(String name, Object expected) throws Exception { runTest(createLookUpTestable(name, expected)); return this; diff --git a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java index 0e255ecc79c544..de247842a900b8 100644 --- a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java +++ b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java @@ -57,6 +57,7 @@ import com.google.devtools.build.android.ziputils.LocalFileHeader; import com.google.devtools.build.android.ziputils.ZipIn; import com.google.devtools.build.android.ziputils.ZipOut; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -169,63 +170,75 @@ public static ResourceLinker create( return new ResourceLinker(aapt2, executorService, workingDirectory); } + @CanIgnoreReturnValue public ResourceLinker includeGeneratedLocales(boolean generatePseudoLocale) { this.generatePseudoLocale = generatePseudoLocale; return this; } + @CanIgnoreReturnValue public ResourceLinker profileUsing(Profiler profiler) { this.profiler = profiler; return this; } /** Dependent static libraries to be linked to. */ + @CanIgnoreReturnValue public ResourceLinker dependencies(List libraries) { this.linkAgainst = libraries; return this; } /** Dependent compiled resources to be included in the binary. */ + @CanIgnoreReturnValue public ResourceLinker include(List include) { this.include = include; return this; } + @CanIgnoreReturnValue public ResourceLinker withAssets(List assetDirs) { this.assetDirs = assetDirs; return this; } + @CanIgnoreReturnValue public ResourceLinker buildVersion(Revision buildToolsVersion) { this.buildToolsVersion = buildToolsVersion; return this; } + @CanIgnoreReturnValue public ResourceLinker debug(boolean debug) { this.debug = debug; return this; } + @CanIgnoreReturnValue public ResourceLinker conditionalKeepRules(boolean conditionalKeepRules) { this.conditionalKeepRules = conditionalKeepRules; return this; } + @CanIgnoreReturnValue public ResourceLinker customPackage(String customPackage) { this.customPackage = customPackage; return this; } + @CanIgnoreReturnValue public ResourceLinker packageId(Optional packageId) { this.packageId = packageId; return this; } + @CanIgnoreReturnValue public ResourceLinker filterToDensity(List densities) { this.densities = densities; return this; } + @CanIgnoreReturnValue public ResourceLinker outputAsProto(boolean outputAsProto) { this.outputAsProto = outputAsProto; return this; @@ -687,16 +700,19 @@ public Path convertProtoApkToBinary(ProtoApk protoApk) { } } + @CanIgnoreReturnValue public ResourceLinker storeUncompressed(List uncompressedExtensions) { this.uncompressedExtensions = uncompressedExtensions; return this; } + @CanIgnoreReturnValue public ResourceLinker includeOnlyConfigs(List resourceConfigs) { this.resourceConfigs = resourceConfigs; return this; } + @CanIgnoreReturnValue public ResourceLinker includeProguardLocationReferences( boolean includeProguardLocationReferences) { this.includeProguardLocationReferences = includeProguardLocationReferences; diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java b/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java index 7c4ff7d9cad74d..00c045cca33bb5 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java @@ -16,6 +16,7 @@ import static com.google.common.base.Preconditions.checkState; import com.google.devtools.build.android.desugar.io.BitFlags; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.LinkedHashMap; import javax.annotation.Nullable; import org.objectweb.asm.ClassReader; @@ -31,6 +32,7 @@ public ClassVsInterface(ClassReaderFactory classpath) { this.classpath = classpath; } + @CanIgnoreReturnValue public ClassVsInterface addKnownClass(@Nullable String internalName) { if (internalName != null) { Boolean previous = known.put(internalName, false); @@ -39,6 +41,7 @@ public ClassVsInterface addKnownClass(@Nullable String internalName) { return this; } + @CanIgnoreReturnValue public ClassVsInterface addKnownInterfaces(String... internalNames) { for (String internalName : internalNames) { Boolean previous = known.put(internalName, true); diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/retarget/ClassMemberRetargetConfig.java b/src/tools/android/java/com/google/devtools/build/android/desugar/retarget/ClassMemberRetargetConfig.java index 7428552de984cc..37190a3aa471ee 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/retarget/ClassMemberRetargetConfig.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/retarget/ClassMemberRetargetConfig.java @@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; import com.google.devtools.build.android.desugar.langmodel.MethodInvocationSite; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.TextFormat; import java.io.IOError; @@ -117,21 +118,25 @@ public abstract static class Builder { public abstract ImmutableSet.Builder enabledInvocationReplacementRangesBuilder(); + @CanIgnoreReturnValue public Builder addInvocationReplacementConfigUrl(URL value) { invocationReplacementConfigUrlsBuilder().add(value); return this; } + @CanIgnoreReturnValue public Builder addInProcessReplacement(MethodInvocationReplacement value) { inProcessReplacementsBuilder().add(value); return this; } + @CanIgnoreReturnValue public Builder addEnabledInvocationReplacementRange(ReplacementRange value) { enabledInvocationReplacementRangesBuilder().add(value); return this; } + @CanIgnoreReturnValue public Builder addAllEnabledInvocationReplacementRange(Collection value) { enabledInvocationReplacementRangesBuilder().addAll(value); return this; diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/typehierarchy/TypeHierarchy.java b/src/tools/android/java/com/google/devtools/build/android/desugar/typehierarchy/TypeHierarchy.java index 939c6698ac5b12..b72dbf1e358b0f 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/typehierarchy/TypeHierarchy.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/typehierarchy/TypeHierarchy.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; import com.google.devtools.build.android.desugar.langmodel.MethodDeclInfo; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.Nullable; @@ -107,18 +108,21 @@ abstract static class TypeHierarchyBuilder { abstract ImmutableMap.Builder methodMetadataBuilder(); + @CanIgnoreReturnValue final TypeHierarchyBuilder putDirectSuperClass( HierarchicalTypeKey declaredType, HierarchicalTypeKey superclass) { directSuperClassByTypeBuilder().put(declaredType, superclass); return this; } + @CanIgnoreReturnValue final TypeHierarchyBuilder putDirectInterfaces( HierarchicalTypeKey declaredType, ImmutableSet directInterfaces) { directInterfacesByTypeBuilder().putAll(declaredType, directInterfaces); return this; } + @CanIgnoreReturnValue final TypeHierarchyBuilder putMethod(MethodDeclInfo methodDecl) { checkState(!methodDecl.isPrivateAccess()); HierarchicalTypeKey typeKey = HierarchicalTypeKey.create(methodDecl.owner()); diff --git a/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java b/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java index f32035a301d119..d9d3929ee8d780 100644 --- a/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java +++ b/src/tools/android/java/com/google/devtools/build/android/xml/Namespaces.java @@ -18,6 +18,7 @@ import com.google.devtools.build.android.DataResourceXml; import com.google.devtools.build.android.XmlResourceValue; import com.google.devtools.build.android.XmlResourceValues; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -60,6 +61,7 @@ public Namespaces toNamespaces() { * @param start The element to collect prefix and uris from. * @return The current namespace builder. */ + @CanIgnoreReturnValue public Collector collectFrom(StartElement start) { Iterator attributes = XmlResourceValues.iterateAttributesFrom(start); Iterator localNamespaces = XmlResourceValues.iterateNamespacesFrom(start);