r221976 - clang-format: [Java] Improve formatting of generics.
Daniel Jasper
djasper at google.com
Fri Nov 14 08:42:26 PST 2014
Yes, intentional.. Should have mentioned in the patch description.
On Fri, Nov 14, 2014 at 5:28 PM, Nico Weber <thakis at chromium.org> wrote:
> On Fri, Nov 14, 2014 at 12:22 AM, Daniel Jasper <djasper at google.com>
> wrote:
>
>> Author: djasper
>> Date: Fri Nov 14 02:22:46 2014
>> New Revision: 221976
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221976&view=rev
>> Log:
>> clang-format: [Java] Improve formatting of generics.
>>
>> Before:
>> Function < F, ? extends T > function;
>>
>> After:
>> Function<F, ? extends T> function;
>>
>> Modified:
>> cfe/trunk/lib/Format/Format.cpp
>> cfe/trunk/lib/Format/TokenAnnotator.cpp
>> cfe/trunk/unittests/Format/FormatTestJava.cpp
>>
>> Modified: cfe/trunk/lib/Format/Format.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=221976&r1=221975&r2=221976&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/Format.cpp (original)
>> +++ cfe/trunk/lib/Format/Format.cpp Fri Nov 14 02:22:46 2014
>> @@ -415,6 +415,7 @@ FormatStyle getGoogleStyle(FormatStyle::
>> GoogleStyle.BreakBeforeBinaryOperators =
>> FormatStyle::BOS_NonAssignment;
>> GoogleStyle.ColumnLimit = 100;
>> GoogleStyle.SpaceAfterCStyleCast = true;
>> + GoogleStyle.SpacesBeforeTrailingComments = 1;
>>
>
> ^ Was this intentional? That looks unrelated.
>
>
>> } else if (Language == FormatStyle::LK_JavaScript) {
>> GoogleStyle.BreakBeforeTernaryOperators = false;
>> GoogleStyle.MaxEmptyLinesToKeep = 3;
>>
>> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=221976&r1=221975&r2=221976&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
>> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 14 02:22:46 2014
>> @@ -63,11 +63,13 @@ private:
>> next();
>> return true;
>> }
>> - if (CurrentToken->isOneOf(tok::r_paren, tok::r_square,
>> tok::r_brace,
>> - tok::colon))
>> - return false;
>> if (CurrentToken->is(tok::question) &&
>> - Style.Language != FormatStyle::LK_Java)
>> + Style.Language == FormatStyle::LK_Java) {
>> + next();
>> + continue;
>> + }
>> + if (CurrentToken->isOneOf(tok::r_paren, tok::r_square,
>> tok::r_brace,
>> + tok::colon, tok::question))
>> return false;
>> // If a && or || is found and interpreted as a binary operator,
>> this set
>> // of angles is likely part of something like "a < b && c > d". If
>> the
>> @@ -367,10 +369,6 @@ private:
>> }
>>
>> bool parseConditional() {
>> - if (Style.Language == FormatStyle::LK_Java &&
>> - CurrentToken->isOneOf(tok::comma, tok::greater))
>> - return true; // This is a generic "?".
>> -
>> while (CurrentToken) {
>> if (CurrentToken->is(tok::colon)) {
>> CurrentToken->Type = TT_ConditionalExpr;
>>
>> Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221976&r1=221975&r2=221976&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTestJava.cpp Fri Nov 14 02:22:46 2014
>> @@ -203,6 +203,7 @@ TEST_F(FormatTestJava, Generics) {
>>
>> verifyFormat("public static <R> ArrayList<R> get() {\n}");
>> verifyFormat("<T extends B> T getInstance(Class<T> type);");
>> + verifyFormat("Function<F, ? extends T> function;");
>> }
>>
>> TEST_F(FormatTestJava, StringConcatenation) {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141114/d7e1729a/attachment.html>
More information about the cfe-commits
mailing list