MyDeveloperDay created this revision. MyDeveloperDay added reviewers: krasimir, curdeius, JakeMerdichAMD, JVApen. MyDeveloperDay added projects: clang, clang-format. MyDeveloperDay requested review of this revision.
https://bugs.llvm.org/show_bug.cgi?id=48539 Add support for Qt Translator Comments to reflow When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D93490 Files: clang/lib/Format/BreakableToken.cpp clang/unittests/Format/FormatTestComments.cpp Index: clang/unittests/Format/FormatTestComments.cpp =================================================================== --- clang/unittests/Format/FormatTestComments.cpp +++ clang/unittests/Format/FormatTestComments.cpp @@ -702,6 +702,22 @@ " // long 1 2 3 4 5 6\n" "}", getLLVMStyleWithColumns(20))); + + EXPECT_EQ("//: A comment that\n" + "//: doesn't fit on\n" + "//: one line", + format("//: A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//= A comment that\n" + "//= doesn't fit on\n" + "//= one line", + format("//= A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//~ A comment that\n" + "//~ doesn't fit on\n" + "//~ one line", + format("//~ A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); } TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) { Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -41,8 +41,8 @@ static StringRef getLineCommentIndentPrefix(StringRef Comment, const FormatStyle &Style) { - static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//", - "//!"}; + static const char *const KnownCStylePrefixes[] = { + "///<", "//!<", "///", "//", "//!", "//:", "//=", "//~"}; static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###", "####"}; ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);
Index: clang/unittests/Format/FormatTestComments.cpp =================================================================== --- clang/unittests/Format/FormatTestComments.cpp +++ clang/unittests/Format/FormatTestComments.cpp @@ -702,6 +702,22 @@ " // long 1 2 3 4 5 6\n" "}", getLLVMStyleWithColumns(20))); + + EXPECT_EQ("//: A comment that\n" + "//: doesn't fit on\n" + "//: one line", + format("//: A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//= A comment that\n" + "//= doesn't fit on\n" + "//= one line", + format("//= A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); + EXPECT_EQ("//~ A comment that\n" + "//~ doesn't fit on\n" + "//~ one line", + format("//~ A comment that doesn't fit on one line", + getLLVMStyleWithColumns(20))); } TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) { Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -41,8 +41,8 @@ static StringRef getLineCommentIndentPrefix(StringRef Comment, const FormatStyle &Style) { - static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///", "//", - "//!"}; + static const char *const KnownCStylePrefixes[] = { + "///<", "//!<", "///", "//", "//!", "//:", "//=", "//~"}; static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###", "####"}; ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits