r221112 - clang-format: [Java] Don't break imports.
Daniel Jasper
djasper at google.com
Sun Nov 2 14:13:03 PST 2014
Author: djasper
Date: Sun Nov 2 16:13:03 2014
New Revision: 221112
URL: http://llvm.org/viewvc/llvm-project?rev=221112&view=rev
Log:
clang-format: [Java] Don't break imports.
This fixes llvm.org/PR21453.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=221112&r1=221111&r2=221112&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Nov 2 16:13:03 2014
@@ -541,8 +541,8 @@ private:
}
} else {
while (CurrentToken) {
- if (CurrentToken->is(tok::string_literal))
- // Mark these string literals as "implicit" literals, too, so that
+ if (CurrentToken->isNot(tok::comment))
+ // Mark these tokens as "implicit" string literals, so that
// they are not split or line-wrapped.
CurrentToken->Type = TT_ImplicitStringLiteral;
next();
@@ -622,7 +622,7 @@ public:
// should not break the line).
IdentifierInfo *Info = CurrentToken->Tok.getIdentifierInfo();
if (Info && Info->getPPKeywordID() == tok::pp_import &&
- CurrentToken->Next && CurrentToken->Next->is(tok::string_literal)) {
+ CurrentToken->Next) {
next();
parseIncludeDirective();
return LT_Other;
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221112&r1=221111&r2=221112&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Sun Nov 2 16:13:03 2014
@@ -163,5 +163,10 @@ TEST_F(FormatTestJava, SynchronizedKeywo
"}");
}
+TEST_F(FormatTestJava, ImportDeclarations) {
+ verifyFormat("import some.really.loooooooooooooooooooooong.imported.Class;",
+ getStyleWithColumns(50));
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list