Skip to content

Commit 6dbd4bb

Browse files
jingwJing Wang
and
Jing Wang
authored
Add txtpb to the list of supported TextProto extensions (#88355)
According to https://protobuf.dev/reference/protobuf/textformat-spec/#text-format-files, txtpb is the canonical extension Co-authored-by: Jing Wang <[email protected]>
1 parent a9111d4 commit 6dbd4bb

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

clang/docs/ClangFormat.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
5454
Objective-C: .m .mm
5555
Proto: .proto .protodevel
5656
TableGen: .td
57-
TextProto: .textpb .pb.txt .textproto .asciipb
57+
TextProto: .txtpb .textpb .pb.txt .textproto .asciipb
5858
Verilog: .sv .svh .v .vh
5959
--cursor=<uint> - The position of the cursor when invoking
6060
clang-format from an editor integration

clang/lib/Format/Format.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3891,7 +3891,11 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
38913891
FileName.ends_with_insensitive(".protodevel")) {
38923892
return FormatStyle::LK_Proto;
38933893
}
3894-
if (FileName.ends_with_insensitive(".textpb") ||
3894+
// txtpb is the canonical extension, and textproto is the legacy canonical
3895+
// extension
3896+
// https://protobuf.dev/reference/protobuf/textformat-spec/#text-format-files
3897+
if (FileName.ends_with_insensitive(".txtpb") ||
3898+
FileName.ends_with_insensitive(".textpb") ||
38953899
FileName.ends_with_insensitive(".pb.txt") ||
38963900
FileName.ends_with_insensitive(".textproto") ||
38973901
FileName.ends_with_insensitive(".asciipb")) {

clang/test/Format/lit.local.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config.suffixes = [
1212
".proto",
1313
".protodevel",
1414
".pb.txt",
15+
".txtpb",
1516
".textproto",
1617
".textpb",
1718
".asciipb",

clang/tools/clang-format/ClangFormat.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static cl::opt<std::string> AssumeFileName(
9292
" Objective-C: .m .mm\n"
9393
" Proto: .proto .protodevel\n"
9494
" TableGen: .td\n"
95-
" TextProto: .textpb .pb.txt .textproto .asciipb\n"
95+
" TextProto: .txtpb .textpb .pb.txt .textproto .asciipb\n"
9696
" Verilog: .sv .svh .v .vh"),
9797
cl::init("<stdin>"), cl::cat(ClangFormatCategory));
9898

0 commit comments

Comments
 (0)