Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ static String getDefaultFileClassName(
FileDescriptorProtoOrBuilder file, boolean useOldOuterClassnameDefault) {
// Replicates the logic of ClassNameResolver::GetFileDefaultImmutableClassName.
String name = file.getName();
name = name.substring(name.lastIndexOf('/'));
// The `+ 1` includes the case where no '/' is present.
name = name.substring(name.lastIndexOf('/') + 1);
name = underscoresToCamelCase(stripProto(name));
return useOldOuterClassnameDefault ? name : name + "Proto";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,15 @@ public void getFileClassName_weirdExtension() {
.isEqualTo("BarNotproto");
}

@Test
public void getFileClassName_noDirectory() {
// This isn't exercisable in blazel because all our tests are in a directory.
assertThat(
GeneratorNames.getFileClassName(
FileDescriptorProto.newBuilder().setName("bar.proto").build()))
.isEqualTo("Bar");
}

@Test
public void getFileClassName_conflictingName2024() {
// This isn't exercisable in blazel because conflicts trigger a protoc error in edition 2024.
Expand Down
Loading