Skip to content

Commit

Permalink
grpc-protoc fix missing javadoc (#2144)
Browse files Browse the repository at this point in the history
Motivation:
`addService(BlockingX)` was deprecated and javadocs were
added to indicate this. However we need to add javadocs for
all params/return value or else javadoc lint warnings will
be generated.

Co-authored-by: Idel Pivnitskiy <idel.pivnitskiy@apple.com>
  • Loading branch information
Scottmitch and idelpivnitskiy authored Mar 10, 2022
1 parent 9c3ed5a commit 3a9ed56
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ private TypeSpec.Builder addServiceFactory(final State state, final TypeSpec.Bui
serviceBuilderSpecBuilder.addMethod(methodBuilder(addService)
.addModifiers(PUBLIC)
.addAnnotation(Deprecated.class)
.addJavadoc("Adds a {@link $T} implementation." + lineSeparator(), state.blockingServiceClass)
.addJavadoc(lineSeparator())
.addJavadoc(JAVADOC_PARAM + service + " the {@link $T} implementation to add." + lineSeparator(),
state.blockingServiceClass)
.addJavadoc(JAVADOC_RETURN + "this." + lineSeparator())
.addJavadoc(JAVADOC_DEPRECATED + "Use {@link #$L($T)}." + lineSeparator(), addBlockingService,
state.blockingServiceClass)
.returns(builderClass)
Expand Down Expand Up @@ -873,14 +878,13 @@ private TypeSpec.Builder addClientInterfaces(final State state, final TypeSpec.B
printJavaDocs, (methodName, b) -> {
ClassName inClass = messageTypesMap.get(clientMetaData.methodProto.getInputType());
b.addModifiers(ABSTRACT).addParameter(clientMetaData.className, metadata)
.addAnnotation(Deprecated.class)
.addJavadoc(JAVADOC_DEPRECATED + "Use {@link #$L($T,$T)}." + lineSeparator(),
methodName,
GrpcClientMetadata, clientMetaData.methodProto.getClientStreaming() ?
Publisher : inClass);
.addAnnotation(Deprecated.class);
if (printJavaDocs) {
extractJavaDocComments(state, methodIndex, b);
b.addJavadoc(JAVADOC_PARAM + metadata +
b.addJavadoc(JAVADOC_DEPRECATED + "Use {@link #$L($T,$T)}." + lineSeparator(),
methodName, GrpcClientMetadata,
clientMetaData.methodProto.getClientStreaming() ? Publisher : inClass)
.addJavadoc(JAVADOC_PARAM + metadata +
" the metadata associated with this client call." + lineSeparator());
}
return b;
Expand Down Expand Up @@ -910,13 +914,13 @@ private TypeSpec.Builder addClientInterfaces(final State state, final TypeSpec.B
printJavaDocs, (methodName, b) -> {
ClassName inClass = messageTypesMap.get(clientMetaData.methodProto.getInputType());
b.addModifiers(ABSTRACT).addParameter(clientMetaData.className, metadata)
.addAnnotation(Deprecated.class)
.addJavadoc(JAVADOC_DEPRECATED + "Use {@link #$L($T,$T)}." + lineSeparator(),
methodName, GrpcClientMetadata, clientMetaData.methodProto.getClientStreaming() ?
Types.Iterable : inClass);
.addAnnotation(Deprecated.class);
if (printJavaDocs) {
extractJavaDocComments(state, methodIndex, b);
b.addJavadoc(JAVADOC_PARAM + metadata +
b.addJavadoc(JAVADOC_DEPRECATED + "Use {@link #$L($T,$T)}." + lineSeparator(),
methodName, GrpcClientMetadata,
clientMetaData.methodProto.getClientStreaming() ? Types.Iterable : inClass)
.addJavadoc(JAVADOC_PARAM + metadata +
" the metadata associated with this client call." + lineSeparator());
}
return b;
Expand Down Expand Up @@ -1041,8 +1045,7 @@ private static MethodSpec newRpcMethodSpec(
if (flags.contains(BLOCKING)) {
if (clientSteaming) {
if (flags.contains(CLIENT)) {
methodSpecBuilder.addParameter(ParameterizedTypeName.get(ClassName.get(Iterable.class),
inClass), request, mods);
methodSpecBuilder.addParameter(ParameterizedTypeName.get(Types.Iterable, inClass), request, mods);
if (printJavaDocs) {
methodSpecBuilder.addJavadoc(JAVADOC_PARAM + request +
" used to send a stream of type {@link $T} to the server." + lineSeparator(), inClass);
Expand Down

0 comments on commit 3a9ed56

Please sign in to comment.