Skip to content

Commit

Permalink
fix: Revert "chore: merge main into autoconfig-gen-draft2" (#1083)
Browse files Browse the repository at this point in the history
* Revert "test: update golden files after annotations import fix"

This reverts commit 0bbfc59.

* Revert "fix(ast): add import generation for annotations on VariableExpr (#1076)"

This reverts commit 9e4721f.

* Revert "chore(main): release 2.10.3 (#1079)"

This reverts commit 63b9bce.

* Revert "fix: fixes regionTag breakage (#1068)"

This reverts commit cd35be8.

* Revert "fix: fix REST transport client creation generated javadoc sample (#1077)"

This reverts commit 5346eef.

* Revert "refactor: expose parsed api short name and version as fields in Service (#1075)"

This reverts commit 2ebe948.

* Revert "chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.4.1 (#1072)"

This reverts commit 6774245.

* Revert "chore(main): release 2.10.2 (#1067)"

This reverts commit e8ee82f.

* Revert "fix(deps): update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 (#1063)"

This reverts commit aa1782d.

* Revert "fix: update regionTag to use service name (#1047)"

This reverts commit 38010fd.

* Revert "chore(main): release 2.10.1 (#1036)"

This reverts commit 3282e0f.

* Revert "deps: Upgrade protobuf to 3.21.7 (#1048)"

This reverts commit c768691.

* Revert "fix: update sample region tag to parse host instead of proto package (#1040)"

This reverts commit eb94f30.

* Revert "chore(deps): update dependency com.google.auto.value:auto-value to v1.10 (#1058)"

This reverts commit bd5599f.

* Revert "fix: Get numeric value for Enum fields if it is configured as query param or path param (#1042)"

This reverts commit 4b5eadb.

* Revert "fix(deps): update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 (#1050)"

This reverts commit e58bf9d.

* Revert "fix(deps): update dependency org.yaml:snakeyaml to v1.33 (#1043)"

This reverts commit d615305.

* Revert "chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.4.0 (#1038)"

This reverts commit ce93705.

* Revert "fix(deps): update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 (#1039)"

This reverts commit dba69f4.

* Revert "fix(deps): update dependency org.yaml:snakeyaml to v1.32 (#1037)"

This reverts commit e754a7c.
  • Loading branch information
emmileaf authored Nov 3, 2022
1 parent 0bbfc59 commit a8dfd80
Show file tree
Hide file tree
Showing 915 changed files with 1,981 additions and 3,372 deletions.
29 changes: 0 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
# Changelog

## [2.10.3](https://github.com/googleapis/gapic-generator-java/compare/v2.10.2...v2.10.3) (2022-11-01)


### Bug Fixes

* Fix REST transport client creation generated javadoc sample ([#1077](https://github.com/googleapis/gapic-generator-java/issues/1077)) ([9ac0ca8](https://github.com/googleapis/gapic-generator-java/commit/9ac0ca80b09077f7880f0029b5d7b090a10a10b8))
* Fixes regionTag breakage ([#1068](https://github.com/googleapis/gapic-generator-java/issues/1068)) ([bed9f72](https://github.com/googleapis/gapic-generator-java/commit/bed9f721fbafb5f2e974b6f43f8455f2fdb581f7))

## [2.10.2](https://github.com/googleapis/gapic-generator-java/compare/v2.10.1...v2.10.2) (2022-10-24)


### Bug Fixes

* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 ([#1063](https://github.com/googleapis/gapic-generator-java/issues/1063)) ([80ed62c](https://github.com/googleapis/gapic-generator-java/commit/80ed62cf6aff395d150e394a44fb60da37e9a6ae))
* Update regionTag to use service name ([#1047](https://github.com/googleapis/gapic-generator-java/issues/1047)) ([68b33c2](https://github.com/googleapis/gapic-generator-java/commit/68b33c23948ffe7a2bf6acd53731d786257f6bd1))

## [2.10.1](https://github.com/googleapis/gapic-generator-java/compare/v2.10.0...v2.10.1) (2022-10-20)


### Bug Fixes

* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#1035](https://github.com/googleapis/gapic-generator-java/issues/1035)) ([f76634a](https://github.com/googleapis/gapic-generator-java/commit/f76634af8497ef2977376af570d175eb0fe91e6f))
* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#1039](https://github.com/googleapis/gapic-generator-java/issues/1039)) ([9d25e47](https://github.com/googleapis/gapic-generator-java/commit/9d25e477126db35efd111a2b8ee76332b549ce91))
* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#1050](https://github.com/googleapis/gapic-generator-java/issues/1050)) ([3b052e2](https://github.com/googleapis/gapic-generator-java/commit/3b052e27bb704124ae3214dd3e8708f8e32afe6c))
* **deps:** Update dependency org.yaml:snakeyaml to v1.32 ([#1037](https://github.com/googleapis/gapic-generator-java/issues/1037)) ([b520aa0](https://github.com/googleapis/gapic-generator-java/commit/b520aa0d35407daf96123d63c3112b9f29715115))
* **deps:** Update dependency org.yaml:snakeyaml to v1.33 ([#1043](https://github.com/googleapis/gapic-generator-java/issues/1043)) ([67a5dc5](https://github.com/googleapis/gapic-generator-java/commit/67a5dc5e4dd3302ececd212dd047f5731c4bf74d))
* Get numeric value for Enum fields if it is configured as query param or path param ([#1042](https://github.com/googleapis/gapic-generator-java/issues/1042)) ([0fdfa67](https://github.com/googleapis/gapic-generator-java/commit/0fdfa67fec84e1983c12b10c7b7ae7a0efa80f4d))
* Update sample region tag to parse host instead of proto package ([#1040](https://github.com/googleapis/gapic-generator-java/issues/1040)) ([01c14d4](https://github.com/googleapis/gapic-generator-java/commit/01c14d41d4195963c0ed46f310360f39eec6d420))

## [2.10.0](https://github.com/googleapis/gapic-generator-java/compare/v2.9.0...v2.10.0) (2022-09-06)


Expand Down
4 changes: 2 additions & 2 deletions PROPERTIES.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROPERTIES = {
"version.com_google_protobuf": "3.21.7",
"version.com_google_protobuf": "3.19.1",
# Version of google-java-format is downgraded from 1.8 to 1.7, because 1.8 supports java 11 minimum, while our JRE is java 8.
"version.google_java_format": "1.7",
"version.io_grpc_java": "1.42.1",
Expand All @@ -10,7 +10,7 @@ PROPERTIES = {
"maven.com_google_auto_value_auto_value": "com.google.auto.value:auto-value:1.7.2",
"maven.com_google_auto_value_auto_value_annotations": "com.google.auto.value:auto-value-annotations:1.7.2",
"maven.com_google_code_gson": "com.google.code.gson:gson:2.8.6",
"maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.21.7",
"maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.19.1",
"maven.io_github_java_diff_utils": "io.github.java-diff-utils:java-diff-utils:4.11",
"maven.javax_annotation_javax_annotation_api": "javax.annotation:javax.annotation-api:1.3.2",

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-dependencies</artifactId>
<version>3.0.5</version>
<version>3.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -42,7 +42,7 @@
<path>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.10</version>
<version>1.9</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down Expand Up @@ -155,7 +155,7 @@
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.21.7:exe:${os.detected.classifier}</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier}</protocArtifact>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -234,7 +234,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -311,7 +311,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
<version>1.31</version>
</dependency>
<dependency>
<groupId>com.google.googlejavaformat</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public void visit(TernaryExpr ternaryExpr) {
@Override
public void visit(VariableExpr variableExpr) {
variableExpr.variable().type().accept(this);
annotations(variableExpr.annotations());
if (variableExpr.exprReferenceExpr() != null) {
variableExpr.exprReferenceExpr().accept(this);
}
Expand Down
51 changes: 29 additions & 22 deletions src/main/java/com/google/api/generator/gapic/composer/Composer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.api.generator.gapic.composer;

import com.google.api.generator.engine.ast.ClassDefinition;
import com.google.api.generator.engine.ast.CommentStatement;
import com.google.api.generator.gapic.composer.comment.CommentComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposer;
Expand Down Expand Up @@ -48,7 +47,8 @@ public static List<GapicClass> composeServiceClasses(GapicContext context) {
clazzes.addAll(generateServiceClasses(context));
clazzes.addAll(generateMockClasses(context, context.mixinServices()));
clazzes.addAll(generateResourceNameHelperClasses(context));
return addApacheLicense(prepareExecutableSamples(clazzes));
return addApacheLicense(
prepareExecutableSamples(clazzes, context.gapicMetadata().getProtoPackage()));
}

public static GapicPackageInfo composePackageInfo(GapicContext context) {
Expand Down Expand Up @@ -190,30 +190,37 @@ public static List<GapicClass> generateTestClasses(GapicContext context) {
}

@VisibleForTesting
static List<GapicClass> prepareExecutableSamples(List<GapicClass> clazzes) {
// Include license header, apiShortName, and apiVersion
List<GapicClass> clazzesWithSamples = new ArrayList<>();
clazzes.forEach(
gapicClass -> {
List<Sample> samples = new ArrayList<>();
gapicClass
.samples()
.forEach(
sample ->
samples.add(
addRegionTagAndHeaderToSample(
sample, gapicClass.apiShortName(), gapicClass.apiVersion())));
clazzesWithSamples.add(gapicClass.withSamples(samples));
});
return clazzesWithSamples;
static List<GapicClass> prepareExecutableSamples(List<GapicClass> clazzes, String protoPackage) {
// parse protoPackage for apiVersion and apiShortName
String[] pakkage = protoPackage.split("\\.");
String apiVersion;
String apiShortName;
// e.g. v1, v2, v1beta1
if (pakkage[pakkage.length - 1].matches("v[0-9].*")) {
apiVersion = pakkage[pakkage.length - 1];
apiShortName = pakkage[pakkage.length - 2];
} else {
apiVersion = "";
apiShortName = pakkage[pakkage.length - 1];
}
// Include license header, apiShortName, and apiVersion
return clazzes.stream()
.map(
gapicClass -> {
List<Sample> samples =
gapicClass.samples().stream()
.map(
sample -> addRegionTagAndHeaderToSample(sample, apiShortName, apiVersion))
.collect(Collectors.toList());
return gapicClass.withSamples(samples);
})
.collect(Collectors.toList());
}

@VisibleForTesting
protected static Sample addRegionTagAndHeaderToSample(
private static Sample addRegionTagAndHeaderToSample(
Sample sample, String apiShortName, String apiVersion) {
final List<CommentStatement> header = Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT);
return sample
.withHeader(header)
.withHeader(Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT))
.withRegionTag(
sample.regionTag().withApiVersion(apiVersion).withApiShortName(apiShortName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ public GapicClass generate(GapicContext context, Service service) {
.build();

updateGapicMetadata(context, service, className, grpcRpcsToJavaMethodNames);
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
}

private static List<AnnotationNode> createClassAnnotations(Service service, TypeStore typeStore) {
Expand Down Expand Up @@ -200,11 +198,9 @@ protected List<CommentStatement> createClassHeaderComments(
ServiceClientHeaderSampleComposer.composeClassHeaderSample(
service, clientType, resourceNames, messageTypes);
Sample credentialsSampleCode =
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(
clientType, settingsType, service);
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(clientType, settingsType);
Sample endpointSampleCode =
ServiceClientHeaderSampleComposer.composeSetEndpointSample(
clientType, settingsType, service);
ServiceClientHeaderSampleComposer.composeSetEndpointSample(clientType, settingsType);
samples.addAll(Arrays.asList(classMethodSampleCode, credentialsSampleCode, endpointSampleCode));
return ServiceClientCommentComposer.createClassHeaderComments(
service,
Expand Down Expand Up @@ -582,8 +578,7 @@ private static List<MethodDefinition> createServiceMethods(
messageTypes,
typeStore,
resourceNames,
samples,
service);
samples);

// Collect data for gapic_metadata.json.
grpcRpcToJavaMethodMetadata
Expand All @@ -601,8 +596,7 @@ private static List<MethodDefinition> createServiceMethods(
messageTypes,
typeStore,
resourceNames,
samples,
service);
samples);

// Collect data for gapic_metadata.json.
grpcRpcToJavaMethodMetadata.get(method.name()).add(javaMethodNameFn.apply(generatedMethod));
Expand Down Expand Up @@ -642,8 +636,7 @@ private static List<MethodDefinition> createMethodVariants(
Map<String, Message> messageTypes,
TypeStore typeStore,
Map<String, ResourceName> resourceNames,
List<Sample> samples,
Service service) {
List<Sample> samples) {
List<MethodDefinition> javaMethods = new ArrayList<>();
String methodName = JavaStyle.toLowerCamelCase(method.name());
TypeNode methodInputType = method.inputType();
Expand Down Expand Up @@ -707,12 +700,7 @@ private static List<MethodDefinition> createMethodVariants(
Optional<Sample> methodSample =
Optional.of(
ServiceClientHeaderSampleComposer.composeShowcaseMethodSample(
method,
typeStore.get(clientName),
signature,
resourceNames,
messageTypes,
service));
method, typeStore.get(clientName), signature, resourceNames, messageTypes));
Optional<String> methodDocSample = Optional.empty();
if (methodSample.isPresent()) {
samples.add(methodSample.get());
Expand Down Expand Up @@ -756,8 +744,7 @@ private static MethodDefinition createMethodDefaultMethod(
Map<String, Message> messageTypes,
TypeStore typeStore,
Map<String, ResourceName> resourceNames,
List<Sample> samples,
Service service) {
List<Sample> samples) {
String methodName = JavaStyle.toLowerCamelCase(method.name());
TypeNode methodInputType = method.inputType();
TypeNode methodOutputType =
Expand Down Expand Up @@ -801,7 +788,7 @@ private static MethodDefinition createMethodDefaultMethod(
Optional<Sample> defaultMethodSample =
Optional.of(
ServiceClientMethodSampleComposer.composeCanonicalSample(
method, typeStore.get(clientName), resourceNames, messageTypes, service));
method, typeStore.get(clientName), resourceNames, messageTypes));
Optional<String> defaultMethodDocSample = Optional.empty();
if (defaultMethodSample.isPresent()) {
samples.add(defaultMethodSample.get());
Expand Down Expand Up @@ -943,17 +930,15 @@ private static MethodDefinition createCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes,
service));
messageTypes));
} else if (callableMethodKind.equals(CallableMethodKind.PAGED)) {
sampleCode =
Optional.of(
ServiceClientCallableMethodSampleComposer.composePagedCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes,
service));
messageTypes));
} else if (callableMethodKind.equals(CallableMethodKind.REGULAR)) {
if (method.stream().equals(Stream.NONE)) {
sampleCode =
Expand All @@ -962,17 +947,15 @@ private static MethodDefinition createCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes,
service));
messageTypes));
} else {
sampleCode =
Optional.of(
ServiceClientCallableMethodSampleComposer.composeStreamCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes,
service));
messageTypes));
}
}
Optional<String> sampleDocCode = Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ public GapicClass generate(GapicContext context, Service service) {
.setMethods(createClassMethods(service, typeStore))
.setNestedClasses(Arrays.asList(createNestedBuilderClass(service, typeStore)))
.build();
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
}

private static List<CommentStatement> createClassHeaderComments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ public GapicClass generate(GapicContext context, Service service) {
Arrays.asList(createNestedBuilderClass(service, serviceConfig, typeStore)))
.build();
return GapicClass.create(
GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
}

protected MethodDefinition createDefaultCredentialsProviderBuilderMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ protected List<CommentStatement> createClassHeaderComments(
ServiceClientHeaderSampleComposer.composeClassHeaderSample(
service, clientType, resourceNames, messageTypes);
Sample credentialsSampleCode =
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(
clientType, settingsType, service);
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(clientType, settingsType);
Sample endpointSampleCode =
ServiceClientHeaderSampleComposer.composeSetEndpointSample(
clientType, settingsType, service);
ServiceClientHeaderSampleComposer.composeSetEndpointSample(clientType, settingsType);
Sample transportSampleCode =
ServiceClientHeaderSampleComposer.composeTransportSample(
clientType, settingsType, "newHttpJsonBuilder", service);
clientType, settingsType, "defaultHttpJsonTransportProviderBuilder");
samples.addAll(
Arrays.asList(
classMethodSampleCode, credentialsSampleCode, endpointSampleCode, transportSampleCode));
Expand Down
Loading

0 comments on commit a8dfd80

Please sign in to comment.