Skip to content

Commit

Permalink
chore: Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vam-google committed Oct 7, 2021
1 parent 0cf77b5 commit 84c04c9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 30 deletions.
6 changes: 2 additions & 4 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ def gapic_generator_java_repositories():
],
)

# TODO: replace with upstream googleapis-discovery link once
# https://github.com/googleapis/googleapis-discovery/pull/59 is merged
_maybe(
http_archive,
name = "com_google_googleapis_discovery",
strip_prefix = "googleapis-discovery-bb8a053b93ef8698297c41634aa9201f7e075277",
strip_prefix = "googleapis-discovery-34478e2969042ed837d33684360f1ee3be7d2f74",
urls = [
"https://github.com/vam-google/googleapis-discovery/archive/bb8a053b93ef8698297c41634aa9201f7e075277.zip",
"https://github.com/googleapis/googleapis-discovery/archive/34478e2969042ed837d33684360f1ee3be7d2f74.zip",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public GapicClass generate(GapicContext context, Service service) {
commentComposer.createTransportServiceCallableFactoryClassHeaderComments(
service.name(), service.isDeprecated()))
.setAnnotations(createClassAnnotations(service, typeStore))
.setImplementsTypes(createClassImplements(typeStore, service))
.setImplementsTypes(createClassImplements(service, typeStore))
.setName(className)
.setMethods(createClassMethods(service, typeStore))
.setScope(ScopeNode.PUBLIC)
Expand Down Expand Up @@ -111,7 +111,7 @@ protected List<AnnotationNode> createClassAnnotations(Service service, TypeStore
* @return {@code TypeNode} containing the interface to be implemented by the generated callable
* factory class.
*/
protected abstract List<TypeNode> createClassImplements(TypeStore typeStore, Service service);
protected abstract List<TypeNode> createClassImplements(Service service, TypeStore typeStore);

protected List<MethodDefinition> createClassMethods(Service service, TypeStore typeStore) {
return Arrays.asList(
Expand Down Expand Up @@ -297,11 +297,11 @@ protected MethodDefinition createGenericCallableMethod(
}

protected TypeNode getOperationsStubType(Service service) {
TypeNode opeationsStubType = service.operationServiceStubType();
if (opeationsStubType == null) {
opeationsStubType = getTransportContext().operationsStubTypes().get(0);
TypeNode operationsStubType = service.operationServiceStubType();
if (operationsStubType == null) {
operationsStubType = getTransportContext().operationsStubTypes().get(0);
}
return opeationsStubType;
return operationsStubType;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ private static MethodDefinition createMethodDefaultMethod(
.copyAndSetGenerics(
Arrays.asList(
lro.responseType().reference(), lro.metadataType().reference())));
if (method.hasLro() && method.lro().operationServiceStubType() != null) {
if (method.lro().operationServiceStubType() != null) {
annotations.add(
AnnotationNode.withTypeAndDescription(
typeStore.get("BetaApi"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import javax.annotation.Nullable;

public abstract class AbstractTransportServiceStubClassComposer implements ClassComposer {
private static final Statement EMPTY_LINE_STATEMENT = EmptyLineStatement.create();
Expand Down Expand Up @@ -152,13 +153,13 @@ public GapicClass generate(GapicContext context, Service service) {
.build()));
if (generateOperationsStubLogic(service)) {
// Transport-specific service stub may have only one element of the following, thus get(0).
TypeNode opeationsStubType = getTransportOperationsStubType(service);
TypeNode operationsStubType = getTransportOperationsStubType(service);
classMemberVarExprs.put(
getTransportContext().transportOperationsStubNames().get(0),
VariableExpr.withVariable(
Variable.builder()
.setName(getTransportContext().transportOperationsStubNames().get(0))
.setType(opeationsStubType)
.setType(operationsStubType)
.build()));
}

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

@Nullable
protected VariableExpr declareLongRunningClient() {
return null;
}
Expand Down Expand Up @@ -1001,12 +1003,7 @@ private List<MethodDefinition> createStubOverrideMethods(
}

private boolean checkOperationPollingMethod(Service service) {
for (Method method : service.methods()) {
if (method.isOperationPollingMethod()) {
return true;
}
}
return false;
return service.methods().stream().anyMatch(Method::isOperationPollingMethod);
}

protected List<MethodDefinition> createLongRunningClientGetters() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static GrpcServiceCallableFactoryClassComposer instance() {
}

@Override
protected List<TypeNode> createClassImplements(TypeStore typeStore, Service service) {
protected List<TypeNode> createClassImplements(Service service, TypeStore typeStore) {
return Arrays.asList(getTransportContext().stubCallableFactoryType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected List<AnnotationNode> createClassAnnotations(Service service, TypeStore
}

@Override
protected List<TypeNode> createClassImplements(TypeStore typeStore, Service service) {
protected List<TypeNode> createClassImplements(Service service, TypeStore typeStore) {
TypeNode operationsStubType = getOperationsStubType(service);

TypeNode operationType = service.operationType();
Expand Down Expand Up @@ -186,12 +186,7 @@ protected MethodDefinition createOperationCallableMethod(Service service, TypeSt
VariableExpr initialCallableVarExpr =
VariableExpr.builder()
.setVariable(
Variable.builder()
.setName("initialCallable")
.setType(
initialCallableType) // TypeNode.withReference(ConcreteReference.withClazz(UnaryCallable.class)))
.build())
// .setTemplateObjects(Arrays.asList(requestTemplateName, "OperationSnapshot"))
Variable.builder().setName("initialCallable").setType(initialCallableType).build())
.build();
MethodInvocationExpr getMethodDescriptorExpr =
MethodInvocationExpr.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,12 +985,12 @@ protected List<Expr> createOperationsStubInitExpr(
VariableExpr operationsStubClassVarExpr,
VariableExpr clientContextVarExpr,
VariableExpr callableFactoryVarExpr) {
TypeNode opeationsStubType = getTransportOperationsStubType(service);
TypeNode operationsStubType = getTransportOperationsStubType(service);
String standardOpStub = HttpJsonOperationsStub.class.getName();

List<Expr> arguments =
new ArrayList<>(Arrays.asList(clientContextVarExpr, callableFactoryVarExpr));
if (standardOpStub.equals(opeationsStubType.reference().fullName())) {
if (standardOpStub.equals(operationsStubType.reference().fullName())) {
arguments.add(TYPE_REGISTRY_VAR_EXPR);
}

Expand All @@ -1000,7 +1000,7 @@ protected List<Expr> createOperationsStubInitExpr(
operationsStubClassVarExpr.toBuilder().setExprReferenceExpr(thisExpr).build())
.setValueExpr(
MethodInvocationExpr.builder()
.setStaticReferenceType(opeationsStubType)
.setStaticReferenceType(operationsStubType)
.setMethodName("create")
.setArguments(arguments)
.setReturnType(operationsStubClassVarExpr.type())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ proto_library(
"@com_google_googleapis//google/api:client_proto",
"@com_google_googleapis//google/api:field_behavior_proto",
"@com_google_googleapis//google/api:resource_proto",
"@com_google_googleapis//google/cloud:extended_operations_proto",
"@com_google_googleapis//google/longrunning:operations_proto",
"@com_google_googleapis//google/rpc:error_details_proto",
"@com_google_googleapis//google/rpc:status_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/cloud/extended_operations.proto";

package google.showcase.v1beta1;

Expand Down

0 comments on commit 84c04c9

Please sign in to comment.