Skip to content

Commit

Permalink
allow empty java package and proto package
Browse files Browse the repository at this point in the history
  • Loading branch information
Fadelis committed Feb 9, 2022
1 parent 02162e8 commit d3e6279
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.test.datatypes";

message NoPackageTestMessage {
message NoProtoPackageTestMessage {
message NestedTestMessage {
string string = 1;
optional string optional_string = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

option java_multiple_files = true;

message NoPackagesTestMessage {
message NestedTestMessage {
string string = 1;
optional string optional_string = 2;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ private Stream<File> handleMessage(
String protoPackage,
String javaPackage
) {
String filePath = javaPackage.replace(".", DIR_SEPARATOR) + DIR_SEPARATOR + fileName + JAVA_EXTENSION;
String fullMethodName = (protoPackage.isEmpty() ? "" : (protoPackage + ".")) + messageDescriptor.getName();
String javaPackagePath = javaPackage.isEmpty() ? "" : javaPackage.replace(".", DIR_SEPARATOR) + DIR_SEPARATOR;
String protoPackagePath = protoPackage.isEmpty() ? "" : protoPackage + ".";
String filePath = javaPackagePath + fileName + JAVA_EXTENSION;
String fullMethodName = protoPackagePath + messageDescriptor.getName();

return Stream.concat(
handleSingleMessage(messageDescriptor, filePath, fullMethodName),
Expand Down

0 comments on commit d3e6279

Please sign in to comment.