Skip to content

Commit 22f2913

Browse files
authored
Merge pull request #3 from github/nested-files
Support nested proto files
2 parents 1d9e1e2 + bb08e7b commit 22f2913

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugin/src/main/java/com/flit/protoc/gen/server/TypeMapper.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.protobuf.DescriptorProtos;
44
import com.squareup.javapoet.ClassName;
55

6+
import java.io.File;
67
import java.util.HashMap;
78
import java.util.List;
89
import java.util.Map;
@@ -34,7 +35,8 @@ public static String getClassname(DescriptorProtos.FileDescriptorProto proto) {
3435

3536
if (clazz == null || clazz.isEmpty()) {
3637

37-
char[] classname = proto.getName().substring(0, proto.getName().lastIndexOf('.')).toCharArray();
38+
String basename = new File(proto.getName()).getName();
39+
char[] classname = basename.substring(0, basename.lastIndexOf('.')).toCharArray();
3840
StringBuilder sb = new StringBuilder();
3941

4042
char previous = '_';
@@ -70,7 +72,7 @@ public static String getClassname(DescriptorProtos.FileDescriptorProto proto) {
7072
}
7173
}
7274

73-
return clazz;
75+
return String.join(".", proto.getOptions().getJavaPackage(), clazz);
7476
}
7577

7678
}

0 commit comments

Comments
 (0)