Skip to content

Commit 51d6869

Browse files
kluevercopybara-github
authored andcommitted
Annotate rhino_ast APIs with @CanIgnoreReturnValue as appropriate.
PiperOrigin-RevId: 848259924
1 parent 162b920 commit 51d6869

File tree

10 files changed

+37
-1
lines changed

10 files changed

+37
-1
lines changed

src/com/google/javascript/rhino/JSDocInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ private static Builder copyFromAndReplaceNames(JSDocInfo info, Set<String> oldNa
16401640
* instantiating the builder if documentation should be included, since it enables various
16411641
* operations to do work that would otherwise be no-ops.
16421642
*/
1643+
@CanIgnoreReturnValue
16431644
public Builder parseDocumentation() {
16441645
setBit(Bit.INCLUDE_DOCUMENTATION, true);
16451646
return this;

src/com/google/javascript/rhino/jstype/EnumType.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import static com.google.javascript.jscomp.base.Tri.FALSE;
4343
import static com.google.javascript.jscomp.base.Tri.TRUE;
4444

45+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4546
import com.google.javascript.jscomp.base.Tri;
4647
import com.google.javascript.rhino.ErrorReporter;
4748
import com.google.javascript.rhino.Node;
@@ -90,18 +91,21 @@ public Builder setName(String x) {
9091
}
9192

9293
/** The object literal that creates the enum, a reference to another enum, or null. */
94+
@CanIgnoreReturnValue
9395
public Builder setSource(Node x) {
9496
this.source = x;
9597
return this;
9698
}
9799

98100
/** The ID of the goog.module in which this enum was declared. */
101+
@CanIgnoreReturnValue
99102
public Builder setGoogModuleId(String x) {
100103
this.googModuleId = x;
101104
return this;
102105
}
103106

104107
/** The base type of the individual elements. */
108+
@CanIgnoreReturnValue
105109
public Builder setElementType(JSType x) {
106110
this.elementType = x;
107111
return this;

src/com/google/javascript/rhino/jstype/EqualityChecker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static com.google.javascript.jscomp.base.JSCompObjects.identical;
4545

4646
import com.google.common.collect.ImmutableList;
47+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4748
import com.google.javascript.rhino.jstype.FunctionType.Parameter;
4849
import com.google.javascript.rhino.jstype.JSType.MatchStatus;
4950
import java.util.LinkedHashMap;
@@ -104,6 +105,7 @@ enum EqMethod {
104105
private int recursionDepth = 0;
105106
private boolean hasRun = false;
106107

108+
@CanIgnoreReturnValue
107109
EqualityChecker setEqMethod(EqMethod x) {
108110
this.checkHasNotRun();
109111
checkState(this.eqMethod == null);

src/com/google/javascript/rhino/jstype/InstanceObjectType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import static com.google.common.base.Preconditions.checkNotNull;
4343

4444
import com.google.common.collect.ImmutableList;
45+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4546
import com.google.javascript.rhino.Node;
4647

4748
/** An object type that is an instance of some function constructor. */
@@ -64,6 +65,7 @@ static final class Builder extends PrototypeObjectType.Builder<Builder> {
6465
super(registry);
6566
}
6667

68+
@CanIgnoreReturnValue
6769
Builder setConstructor(FunctionType x) {
6870
this.constructor = x;
6971
return this;

src/com/google/javascript/rhino/jstype/PrototypeObjectType.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import static com.google.javascript.jscomp.base.JSCompObjects.identical;
4545

4646
import com.google.common.collect.ImmutableList;
47+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4748
import com.google.javascript.rhino.ErrorReporter;
4849
import com.google.javascript.rhino.JSDocInfo;
4950
import com.google.javascript.rhino.Node;
@@ -147,37 +148,44 @@ static class Builder<T extends Builder<T>> {
147148
this.templateTypeMap = registry.getEmptyTemplateTypeMap();
148149
}
149150

151+
@CanIgnoreReturnValue
150152
T setName(String x) {
151153
this.className = x;
152154
return castThis();
153155
}
154156

157+
@CanIgnoreReturnValue
155158
final T setImplicitPrototype(ObjectType x) {
156159
this.implicitPrototype = x;
157160
return castThis();
158161
}
159162

163+
@CanIgnoreReturnValue
160164
final T setNative(boolean x) {
161165
this.nativeType = x;
162166
return castThis();
163167
}
164168

169+
@CanIgnoreReturnValue
165170
final T setAnonymous(boolean x) {
166171
this.anonymousType = x;
167172
return castThis();
168173
}
169174

175+
@CanIgnoreReturnValue
170176
final T setTemplateTypeMap(TemplateTypeMap x) {
171177
this.templateTypeMap = x;
172178
return castThis();
173179
}
174180

181+
@CanIgnoreReturnValue
175182
final T setTemplateParamCount(int x) {
176183
this.templateParamCount = x;
177184
return castThis();
178185
}
179186

180187
@SuppressWarnings("unchecked")
188+
@CanIgnoreReturnValue
181189
final T castThis() {
182190
return (T) this;
183191
}

src/com/google/javascript/rhino/jstype/RecordTypeBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
package com.google.javascript.rhino.jstype;
4141

4242
import com.google.common.collect.ImmutableSortedMap;
43+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4344
import com.google.javascript.rhino.Node;
4445
import java.util.LinkedHashMap;
4546

@@ -71,6 +72,7 @@ void setSynthesized(boolean synthesized) {
7172
* @param propertyNode the node that holds this property definition
7273
* @return The builder itself for chaining purposes.
7374
*/
75+
@CanIgnoreReturnValue
7476
public RecordTypeBuilder addProperty(String name, JSType type, Node propertyNode) {
7577
isEmpty = false;
7678
properties.put(name, new RecordProperty(type, propertyNode));

src/com/google/javascript/rhino/jstype/SubtypeChecker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import static com.google.javascript.rhino.jstype.JSTypeIterations.anyTypeMatches;
4747

4848
import com.google.common.collect.ImmutableSet;
49+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4950
import com.google.javascript.rhino.jstype.JSType.MatchStatus;
5051
import com.google.javascript.rhino.jstype.JSType.SubtypingMode;
5152
import java.util.Iterator;
@@ -89,27 +90,31 @@ final class SubtypeChecker {
8990
private boolean hasRun = false;
9091
private int recursionDepth = 0;
9192

93+
@CanIgnoreReturnValue
9294
SubtypeChecker setSupertype(JSType value) {
9395
checkHasNotRun();
9496
checkState(this.initialSupertype == null);
9597
this.initialSupertype = checkNotNull(value);
9698
return this;
9799
}
98100

101+
@CanIgnoreReturnValue
99102
SubtypeChecker setSubtype(JSType value) {
100103
checkHasNotRun();
101104
checkState(this.initialSubtype == null);
102105
this.initialSubtype = checkNotNull(value);
103106
return this;
104107
}
105108

109+
@CanIgnoreReturnValue
106110
SubtypeChecker setUsingStructuralSubtyping(boolean value) {
107111
checkHasNotRun();
108112
checkState(this.isUsingStructuralTyping == null);
109113
this.isUsingStructuralTyping = value;
110114
return this;
111115
}
112116

117+
@CanIgnoreReturnValue
113118
SubtypeChecker setSubtypingMode(SubtypingMode value) {
114119
checkHasNotRun();
115120
checkState(this.subtypingMode == null);

src/com/google/javascript/rhino/jstype/TypeStringBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
package com.google.javascript.rhino.jstype;
4141

42+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
43+
4244
/**
4345
* Visits types to assemble an associated stringification.
4446
*
@@ -58,16 +60,19 @@ boolean isForAnnotations() {
5860
return this.isForAnnotations;
5961
}
6062

63+
@CanIgnoreReturnValue
6164
TypeStringBuilder append(String x) {
6265
this.builder.append(x);
6366
return this;
6467
}
6568

69+
@CanIgnoreReturnValue
6670
TypeStringBuilder append(JSType x) {
6771
x.appendTo(this);
6872
return this;
6973
}
7074

75+
@CanIgnoreReturnValue
7176
TypeStringBuilder appendAll(Iterable<?> elements, String separator) {
7277
boolean separate = false;
7378
for (Object e : elements) {
@@ -87,7 +92,7 @@ TypeStringBuilder appendAll(Iterable<?> elements, String separator) {
8792
return this;
8893
}
8994

90-
95+
@CanIgnoreReturnValue
9196
TypeStringBuilder appendNonNull(JSType type) {
9297
if (this.isForAnnotations
9398
&& type.isObject()
@@ -102,11 +107,13 @@ TypeStringBuilder appendNonNull(JSType type) {
102107
return this.append(type);
103108
}
104109

110+
@CanIgnoreReturnValue
105111
TypeStringBuilder breakLineAndIndent() {
106112
this.builder.append("\n").append(this.indentation);
107113
return this;
108114
}
109115

116+
@CanIgnoreReturnValue
110117
TypeStringBuilder indent(Runnable cb) {
111118
String lastIndent = this.indentation;
112119
this.indentation = lastIndent + " ";

src/com/google/javascript/rhino/testing/TestErrorReporter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import static com.google.common.truth.Truth.assertThat;
4343

44+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4445
import com.google.javascript.rhino.ErrorReporter;
4546
import java.util.ArrayList;
4647
import java.util.Collections;
@@ -68,11 +69,13 @@ public void warning(String message, String sourceName, int line, int lineOffset)
6869
seenWarnings.put(fmtDiagnosticKey(message, sourceName, line, lineOffset), message);
6970
}
7071

72+
@CanIgnoreReturnValue
7173
public TestErrorReporter expectAllErrors(String... errors) {
7274
Collections.addAll(this.expectedErrors, errors);
7375
return this;
7476
}
7577

78+
@CanIgnoreReturnValue
7679
public TestErrorReporter expectAllWarnings(String... warnings) {
7780
Collections.addAll(this.expectedWarnings, warnings);
7881
return this;

src/com/google/javascript/rhino/testing/TypeSubject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.google.common.collect.ImmutableList;
4949
import com.google.common.truth.FailureMetadata;
5050
import com.google.common.truth.Subject;
51+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5152
import com.google.errorprone.annotations.CheckReturnValue;
5253
import com.google.javascript.rhino.ClosurePrimitive;
5354
import com.google.javascript.rhino.jstype.FunctionType;
@@ -151,6 +152,7 @@ public FunctionTypeSubject isFunctionTypeThat() {
151152
return new FunctionTypeSubject();
152153
}
153154

155+
@CanIgnoreReturnValue
154156
public TypeSubject isObjectTypeWithProperty(String propName) {
155157
isLiteralObject();
156158
withTypeOfProp(propName).isNotNull();

0 commit comments

Comments
 (0)