Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static CommentStatement createPackageInfoJavadoc(GapicContext context) {
javaDocCommentBuilder.addParagraph(
String.format("%s %s %s", DIVIDER, javaClientName, DIVIDER));

// TODO(miraleung): Replace this with a comment converter when we upport CommonMark.
// TODO(miraleung): Replace this with a comment converter when we support CommonMark.
if (service.hasDescription()) {
String[] descriptionParagraphs = service.description().split("\\n\\n");
for (int i = 0; i < descriptionParagraphs.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ private static MethodDefinition createEqualsMethod(
Set<String> tokenSet = getTokenSet(tokenHierarchies);
Iterator<String> itToken = tokenSet.iterator();
Expr curTokenExpr =
createObjectsEqualsForTokenMethodEpxr(
createObjectsEqualsForTokenMethodExpr(
thisValueExpr,
thatVariableExpr,
Variable.builder()
Expand All @@ -1208,7 +1208,7 @@ private static MethodDefinition createEqualsMethod(
.build());
while (itToken.hasNext()) {
Expr nextTokenExpr =
createObjectsEqualsForTokenMethodEpxr(
createObjectsEqualsForTokenMethodExpr(
thisValueExpr,
thatVariableExpr,
Variable.builder()
Expand Down Expand Up @@ -1252,7 +1252,7 @@ private static MethodDefinition createEqualsMethod(
.build();
}

private static MethodInvocationExpr createObjectsEqualsForTokenMethodEpxr(
private static MethodInvocationExpr createObjectsEqualsForTokenMethodExpr(
Expr thisExpr, Expr thatExpr, Variable tokenVar) {
VariableExpr varThisExpr =
VariableExpr.builder().setVariable(tokenVar).setExprReferenceExpr(thisExpr).build();
Expand All @@ -1267,7 +1267,7 @@ private static MethodInvocationExpr createObjectsEqualsForTokenMethodEpxr(
}

private static MethodDefinition createHashCodeMethod(List<List<String>> tokenHierarchies) {
List<Statement> asgmtBody = new ArrayList<>();
List<Statement> assignmentBody = new ArrayList<>();
// code: int h = 1;
Variable hVar = Variable.builder().setType(TypeNode.INT).setName("h").build();
VariableExpr hVarExpr = VariableExpr.builder().setVariable(hVar).build();
Expand All @@ -1278,20 +1278,20 @@ private static MethodDefinition createHashCodeMethod(List<List<String>> tokenHie
.setVariableExpr(hVarExpr.toBuilder().setIsDecl(true).build())
.setValueExpr(hValueExpr)
.build();
asgmtBody.add(ExprStatement.withExpr(hAssignmentExpr));
assignmentBody.add(ExprStatement.withExpr(hAssignmentExpr));
// code: h *= 1000003;
// code: h ^= Objects.hashCode(...);
ValueExpr numValueExpr =
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.INT).setValue("1000003").build());
AssignmentOperationExpr multiplyAsgmtOpExpr =
AssignmentOperationExpr multiplyAssignmentOpExpr =
AssignmentOperationExpr.multiplyAssignmentWithExprs(hVarExpr, numValueExpr);
// If it has variants, add the multiply and xor assignment operation exprs for fixedValue.
boolean hasVariants = tokenHierarchies.size() > 1;
if (hasVariants) {
VariableExpr fixedValueVarExpr = FIXED_CLASS_VARS.get("fixedValue");
asgmtBody.add(ExprStatement.withExpr(multiplyAsgmtOpExpr));
asgmtBody.add(
assignmentBody.add(ExprStatement.withExpr(multiplyAssignmentOpExpr));
assignmentBody.add(
ExprStatement.withExpr(
AssignmentOperationExpr.xorAssignmentWithExprs(
hVarExpr, createObjectsHashCodeForVarMethod(fixedValueVarExpr))));
Expand All @@ -1307,8 +1307,8 @@ private static MethodDefinition createHashCodeMethod(List<List<String>> tokenHie
.setName(JavaStyle.toLowerCamelCase(token))
.setType(TypeNode.STRING)
.build());
asgmtBody.add(ExprStatement.withExpr(multiplyAsgmtOpExpr));
asgmtBody.add(
assignmentBody.add(ExprStatement.withExpr(multiplyAssignmentOpExpr));
assignmentBody.add(
ExprStatement.withExpr(
AssignmentOperationExpr.xorAssignmentWithExprs(
hVarExpr, createObjectsHashCodeForVarMethod(tokenVarExpr))));
Expand All @@ -1319,7 +1319,7 @@ private static MethodDefinition createHashCodeMethod(List<List<String>> tokenHie
.setScope(ScopeNode.PUBLIC)
.setReturnType(TypeNode.INT)
.setName("hashCode")
.setBody(asgmtBody)
.setBody(assignmentBody)
.setReturnExpr(hVarExpr)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static CommentStatement toSimpleComment(String comment) {
return CommentStatement.withComment(JavaDocComment.withComment(comment));
}

// TODO(miraleung): Replace this with a comment converter when we upport CommonMark.
// TODO(miraleung): Replace this with a comment converter when we support CommonMark.
private static JavaDocComment.Builder processProtobufComment(
String rawComment, JavaDocComment.Builder originalCommentBuilder, String firstPattern) {
JavaDocComment.Builder commentBuilder = originalCommentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ private static MethodDefinition createRpcTestMethod(
.build());

if (method.isPaged()) {
// Assign the resources variaqble.
// Assign the resources variable.
VariableExpr resourcesVarExpr =
VariableExpr.withVariable(
Variable.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ private static Expr createPagedListDescriptorAssignExpr(
VariableExpr pageSizeVarExpr =
VariableExpr.withVariable(
Variable.builder().setType(TypeNode.INT).setName("pageSize").build());
// Re-declare for clarity and easier readeability.
// Re-declare for clarity and easier readability.
returnType = method.inputType();
returnExpr =
MethodInvocationExpr.builder()
Expand Down Expand Up @@ -1431,7 +1431,7 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
.setBody(ctorBodyStatements)
.build());

// Third constructor that takes a ServivceStubSettings.
// Third constructor that takes a ServiceStubSettings.
TypeNode outerSettingsType = types.get(getThisClassName(service.name()));
VariableExpr settingsVarExpr =
VariableExpr.withVariable(
Expand Down Expand Up @@ -1882,7 +1882,7 @@ private static TypeNode getCallSettingsType(
: typeMakerFn.apply(
isSettingsBuilder ? UnaryCallSettings.Builder.class : UnaryCallSettings.class);

// Streaming takes precendence over paging, as per the monolith's existing behavior.
// Streaming takes precedence over paging, as per the monolith's existing behavior.
switch (method.stream()) {
case SERVER:
callSettingsType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static List<Method> parseMethods(
.setIsPaged(parseIsPaged(protoMethod, messageTypes))
.build());

// Any input type that has a resource reference will need a resource name helper calss.
// Any input type that has a resource reference will need a resource name helper class.
Message inputMessage = messageTypes.get(inputType.reference().name());
for (Field field : inputMessage.fields()) {
if (field.hasResourceReference()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_numericWithBooleanType() {

@Test
public void invalidMultiplyAndAssignmentOperationExpr_numericWithReferenceType() {
// Swap test case in "invalidMultiplyAndAssignmentOperationExpr_feferencedWithNumericType".
// Swap test case in "invalidMultiplyAndAssignmentOperationExpr_referencedWithNumericType".
VariableExpr lhsExpr = createVariableExpr(TypeNode.INT, "x");
VariableExpr rhsExpr = createVariableExpr(TypeNode.STRING, "y");
assertThrows(
Expand Down Expand Up @@ -470,7 +470,7 @@ public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithNullType()
}

@Test
public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithOjectType() {
public void invalidMultiplyAndAssignmentOperationExpr_doubleBoxedWithObjectType() {
// No need swap test.
VariableExpr lhsExpr = createVariableExpr(TypeNode.DOUBLE_OBJECT, "x");
NewObjectExpr rhsExpr = NewObjectExpr.withType(TypeNode.OBJECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void createJavaDocComment_throwsAndDeprecated() {
}

@Test
public void createavaDocComment_allComponents() {
public void createJavaDocComment_allComponents() {
// No matter what order `setThrows`, `setDeprecated` are called,
// They will be printed at the end. And `@param` should be grouped,
// they should always be printed right before `@throws` and `@deprecated`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void defaultValue_mapField() {

writerVisitor.clear();

// isMap() and isRepeated() will be set by protoc simulataneoulsy, but we check this edge case
// isMap() and isRepeated() will be set by protoc simultaneously, but we check this edge case.
// for completeness.
field = Field.builder().setName("foobar").setType(TypeNode.STRING).setIsMap(true).build();
expr = DefaultValueComposer.createDefaultValue(field);
Expand Down