Skip to content

Commit 84c04c9

Browse files
committed
chore: Address PR feedback
1 parent 0cf77b5 commit 84c04c9

9 files changed

Lines changed: 22 additions & 30 deletions

repositories.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ def gapic_generator_java_repositories():
6565
],
6666
)
6767

68-
# TODO: replace with upstream googleapis-discovery link once
69-
# https://github.com/googleapis/googleapis-discovery/pull/59 is merged
7068
_maybe(
7169
http_archive,
7270
name = "com_google_googleapis_discovery",
73-
strip_prefix = "googleapis-discovery-bb8a053b93ef8698297c41634aa9201f7e075277",
71+
strip_prefix = "googleapis-discovery-34478e2969042ed837d33684360f1ee3be7d2f74",
7472
urls = [
75-
"https://github.com/vam-google/googleapis-discovery/archive/bb8a053b93ef8698297c41634aa9201f7e075277.zip",
73+
"https://github.com/googleapis/googleapis-discovery/archive/34478e2969042ed837d33684360f1ee3be7d2f74.zip",
7674
],
7775
)
7876

src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceCallableFactoryClassComposer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public GapicClass generate(GapicContext context, Service service) {
7878
commentComposer.createTransportServiceCallableFactoryClassHeaderComments(
7979
service.name(), service.isDeprecated()))
8080
.setAnnotations(createClassAnnotations(service, typeStore))
81-
.setImplementsTypes(createClassImplements(typeStore, service))
81+
.setImplementsTypes(createClassImplements(service, typeStore))
8282
.setName(className)
8383
.setMethods(createClassMethods(service, typeStore))
8484
.setScope(ScopeNode.PUBLIC)
@@ -111,7 +111,7 @@ protected List<AnnotationNode> createClassAnnotations(Service service, TypeStore
111111
* @return {@code TypeNode} containing the interface to be implemented by the generated callable
112112
* factory class.
113113
*/
114-
protected abstract List<TypeNode> createClassImplements(TypeStore typeStore, Service service);
114+
protected abstract List<TypeNode> createClassImplements(Service service, TypeStore typeStore);
115115

116116
protected List<MethodDefinition> createClassMethods(Service service, TypeStore typeStore) {
117117
return Arrays.asList(
@@ -297,11 +297,11 @@ protected MethodDefinition createGenericCallableMethod(
297297
}
298298

299299
protected TypeNode getOperationsStubType(Service service) {
300-
TypeNode opeationsStubType = service.operationServiceStubType();
301-
if (opeationsStubType == null) {
302-
opeationsStubType = getTransportContext().operationsStubTypes().get(0);
300+
TypeNode operationsStubType = service.operationServiceStubType();
301+
if (operationsStubType == null) {
302+
operationsStubType = getTransportContext().operationsStubTypes().get(0);
303303
}
304-
return opeationsStubType;
304+
return operationsStubType;
305305
}
306306

307307

src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ private static MethodDefinition createMethodDefaultMethod(
752752
.copyAndSetGenerics(
753753
Arrays.asList(
754754
lro.responseType().reference(), lro.metadataType().reference())));
755-
if (method.hasLro() && method.lro().operationServiceStubType() != null) {
755+
if (method.lro().operationServiceStubType() != null) {
756756
annotations.add(
757757
AnnotationNode.withTypeAndDescription(
758758
typeStore.get("BetaApi"),

src/main/java/com/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import java.util.function.Function;
7777
import java.util.stream.Collectors;
7878
import javax.annotation.Generated;
79+
import javax.annotation.Nullable;
7980

8081
public abstract class AbstractTransportServiceStubClassComposer implements ClassComposer {
8182
private static final Statement EMPTY_LINE_STATEMENT = EmptyLineStatement.create();
@@ -152,13 +153,13 @@ public GapicClass generate(GapicContext context, Service service) {
152153
.build()));
153154
if (generateOperationsStubLogic(service)) {
154155
// Transport-specific service stub may have only one element of the following, thus get(0).
155-
TypeNode opeationsStubType = getTransportOperationsStubType(service);
156+
TypeNode operationsStubType = getTransportOperationsStubType(service);
156157
classMemberVarExprs.put(
157158
getTransportContext().transportOperationsStubNames().get(0),
158159
VariableExpr.withVariable(
159160
Variable.builder()
160161
.setName(getTransportContext().transportOperationsStubNames().get(0))
161-
.setType(opeationsStubType)
162+
.setType(operationsStubType)
162163
.build()));
163164
}
164165

@@ -741,6 +742,7 @@ protected List<Statement> createLongRunningClient(Service service, TypeStore typ
741742
return ImmutableList.of();
742743
}
743744

745+
@Nullable
744746
protected VariableExpr declareLongRunningClient() {
745747
return null;
746748
}
@@ -1001,12 +1003,7 @@ private List<MethodDefinition> createStubOverrideMethods(
10011003
}
10021004

10031005
private boolean checkOperationPollingMethod(Service service) {
1004-
for (Method method : service.methods()) {
1005-
if (method.isOperationPollingMethod()) {
1006-
return true;
1007-
}
1008-
}
1009-
return false;
1006+
return service.methods().stream().anyMatch(Method::isOperationPollingMethod);
10101007
}
10111008

10121009
protected List<MethodDefinition> createLongRunningClientGetters() {

src/main/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceCallableFactoryClassComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static GrpcServiceCallableFactoryClassComposer instance() {
4242
}
4343

4444
@Override
45-
protected List<TypeNode> createClassImplements(TypeStore typeStore, Service service) {
45+
protected List<TypeNode> createClassImplements(Service service, TypeStore typeStore) {
4646
return Arrays.asList(getTransportContext().stubCallableFactoryType());
4747
}
4848

src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceCallableFactoryClassComposer.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected List<AnnotationNode> createClassAnnotations(Service service, TypeStore
7070
}
7171

7272
@Override
73-
protected List<TypeNode> createClassImplements(TypeStore typeStore, Service service) {
73+
protected List<TypeNode> createClassImplements(Service service, TypeStore typeStore) {
7474
TypeNode operationsStubType = getOperationsStubType(service);
7575

7676
TypeNode operationType = service.operationType();
@@ -186,12 +186,7 @@ protected MethodDefinition createOperationCallableMethod(Service service, TypeSt
186186
VariableExpr initialCallableVarExpr =
187187
VariableExpr.builder()
188188
.setVariable(
189-
Variable.builder()
190-
.setName("initialCallable")
191-
.setType(
192-
initialCallableType) // TypeNode.withReference(ConcreteReference.withClazz(UnaryCallable.class)))
193-
.build())
194-
// .setTemplateObjects(Arrays.asList(requestTemplateName, "OperationSnapshot"))
189+
Variable.builder().setName("initialCallable").setType(initialCallableType).build())
195190
.build();
196191
MethodInvocationExpr getMethodDescriptorExpr =
197192
MethodInvocationExpr.builder()

src/main/java/com/google/api/generator/gapic/composer/rest/HttpJsonServiceStubClassComposer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -985,12 +985,12 @@ protected List<Expr> createOperationsStubInitExpr(
985985
VariableExpr operationsStubClassVarExpr,
986986
VariableExpr clientContextVarExpr,
987987
VariableExpr callableFactoryVarExpr) {
988-
TypeNode opeationsStubType = getTransportOperationsStubType(service);
988+
TypeNode operationsStubType = getTransportOperationsStubType(service);
989989
String standardOpStub = HttpJsonOperationsStub.class.getName();
990990

991991
List<Expr> arguments =
992992
new ArrayList<>(Arrays.asList(clientContextVarExpr, callableFactoryVarExpr));
993-
if (standardOpStub.equals(opeationsStubType.reference().fullName())) {
993+
if (standardOpStub.equals(operationsStubType.reference().fullName())) {
994994
arguments.add(TYPE_REGISTRY_VAR_EXPR);
995995
}
996996

@@ -1000,7 +1000,7 @@ protected List<Expr> createOperationsStubInitExpr(
10001000
operationsStubClassVarExpr.toBuilder().setExprReferenceExpr(thisExpr).build())
10011001
.setValueExpr(
10021002
MethodInvocationExpr.builder()
1003-
.setStaticReferenceType(opeationsStubType)
1003+
.setStaticReferenceType(operationsStubType)
10041004
.setMethodName("create")
10051005
.setArguments(arguments)
10061006
.setReturnType(operationsStubClassVarExpr.type())

src/test/java/com/google/api/generator/gapic/testdata/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ proto_library(
5656
"@com_google_googleapis//google/api:client_proto",
5757
"@com_google_googleapis//google/api:field_behavior_proto",
5858
"@com_google_googleapis//google/api:resource_proto",
59+
"@com_google_googleapis//google/cloud:extended_operations_proto",
5960
"@com_google_googleapis//google/longrunning:operations_proto",
6061
"@com_google_googleapis//google/rpc:error_details_proto",
6162
"@com_google_googleapis//google/rpc:status_proto",

src/test/java/com/google/api/generator/gapic/testdata/compliance.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ syntax = "proto3";
1616

1717
import "google/api/annotations.proto";
1818
import "google/api/client.proto";
19+
import "google/cloud/extended_operations.proto";
1920

2021
package google.showcase.v1beta1;
2122

0 commit comments

Comments
 (0)