Exemple #1
0
 CodeGeneratorResponse generate(CodeGeneratorRequest request) {
   CodeGeneratorResponse.Builder builder = CodeGeneratorResponse.newBuilder();
   for (FileDescriptorProto file : request.getProtoFileList()) {
     String javaFilename = getJavaFilename(file.getPackage(), file.getName());
     for (DescriptorProto msg : file.getMessageTypeList()) {
       for (EnumDescriptorProto en : msg.getEnumTypeList()) {
         File.Builder f = File.newBuilder();
         f.setName(javaFilename);
         f.setInsertionPoint(
             format("enum_scope:%s.%s.%s", file.getPackage(), msg.getName(), en.getName()));
         f.setContent(getEnumVisitor(en));
         builder.addFile(f);
       }
     }
     // insert visitors at outer_class_scope
   }
   return builder.build();
 }
Exemple #2
0
 private String getEnumVisitor(EnumDescriptorProto en) {
   return format("// create a %sVisitor", en.getName());
 }