Skip to content

Commit

Permalink
Remove import generator
Browse files Browse the repository at this point in the history
  • Loading branch information
disc99 committed Nov 21, 2021
1 parent c2aaaff commit e1231fe
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ protected String getPluginName() {
return "protoc-gen-spring-webflux";
}

/**
* {@inheritDoc}
*/
@Override
@Nonnull
protected String generateImports() {
return apply("imports", null);
}

@Nonnull
@Override
protected FileGenerationUnit getFileGenerationUnit() {
Expand All @@ -54,7 +45,6 @@ protected Optional<GenerateCode> generateServiceCode(@Nonnull final ServiceDescr

HashMap<String, Object> context = new HashMap<>();
context.put("pluginName", this.getPluginName());
context.put("imports", this.generateImports());
context.put("pkgName", serviceDescriptor.getJavaPkgName());
context.put("protoSourceName", serviceDescriptor.getProtoSourceName());
context.put("serviceName", serviceDescriptor.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public List<String> getOuters() {
public List<File> generateFile() {
HashMap<String, Object> context = new HashMap<>();
context.put("pluginName", generator.getPluginName());
context.put("imports", generator.generateImports());
context.put("protoSourceName", fileDescriptorProto.getName());
context.put("pkgName", getJavaPackage());
context.put("outerClassName", outerClass.getPluginJavaClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ protected String generatePluginJavaClass(@Nonnull final String protoJavaClass) {
return protoJavaClass;
};

/**
* Generate the Java imports required by the generated code in your plugin.
* @return A string, listing all the imports. e.g: "import java.util.List;import java.util.Map;"
*/
@Nonnull
protected abstract String generateImports();

/**
* Generate the Java code for a particular {@link EnumDescriptor}.
*
Expand Down
29 changes: 0 additions & 29 deletions plugin/src/main/resources/imports.hbs

This file was deleted.

30 changes: 29 additions & 1 deletion plugin/src/main/resources/service.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@
// source: {{protoSourceName}}
package {{pkgName}};

{{imports}}
import com.google.common.base.Strings;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Message;
import com.google.protobuf.MessageOrBuilder;
import com.google.protobuf.util.JsonFormat;
import io.grpc.Metadata;
import io.grpc.stub.MetadataUtils;
import io.grpc.stub.StreamObserver;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.server.ServerWebInputException;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Mono;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

@javax.annotation.Generated(
value = "by {{pluginName}} compiler plugin",
Expand Down

0 comments on commit e1231fe

Please sign in to comment.