r221979 - clang-format: [Java] Improve generic return type formatting.
Nico Weber
thakis at chromium.org
Fri Nov 14 08:29:57 PST 2014
On Fri, Nov 14, 2014 at 1:05 AM, Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Fri Nov 14 03:05:32 2014
> New Revision: 221979
>
> URL: http://llvm.org/viewvc/llvm-project?rev=221979&view=rev
> Log:
> clang-format: [Java] Improve generic return type formatting.
>
> Before:
> public<R> ArrayList<R> get() {
>
> After:
> public <R> ArrayList<R> get() {
>
> 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=221979&r1=221978&r2=221979&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 14 03:05:32 2014
> @@ -1684,7 +1684,8 @@ bool TokenAnnotator::spaceRequiredBefore
> } else if (Style.Language == FormatStyle::LK_Java) {
> if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren))
> return Style.SpaceBeforeParens != FormatStyle::SBPO_Never;
> - if (Left.is(tok::kw_static) && Right.Type == TT_TemplateOpener)
> + if (Left.isOneOf(tok::kw_static, tok::kw_public) &&
>
Don't you want this for private and protected as well?
> + Right.Type == TT_TemplateOpener)
> return true;
> }
> if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
>
> Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221979&r1=221978&r2=221979&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTestJava.cpp Fri Nov 14 03:05:32 2014
> @@ -205,6 +205,7 @@ TEST_F(FormatTestJava, Generics) {
> verifyFormat("@Override\n"
> "public Map<String, ?> getAll() {\n}");
>
> + verifyFormat("public <R> ArrayList<R> get() {\n}");
> verifyFormat("public static <R> ArrayList<R> get() {\n}");
> verifyFormat("<T extends B> T getInstance(Class<T> type);");
> verifyFormat("Function<F, ? extends T> function;");
>
>
> _______________________________________________
> 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/199b74e8/attachment.html>
More information about the cfe-commits
mailing list