r225839 - clang-format: [Java] Detect `native` keyword.

Daniel Jasper djasper at google.com
Wed Jan 14 01:11:26 PST 2015


Thanks!

On Tue, Jan 13, 2015 at 11:32 PM, Nico Weber <nicolasweber at gmx.de> wrote:

> Author: nico
> Date: Tue Jan 13 16:32:50 2015
> New Revision: 225839
>
> URL: http://llvm.org/viewvc/llvm-project?rev=225839&view=rev
> Log:
> clang-format: [Java] Detect `native` keyword.
>
> Before:
>   public native<X> Foo foo();
>
> After:
>   public native <X> Foo foo();
>
>
> Modified:
>     cfe/trunk/lib/Format/FormatToken.h
>     cfe/trunk/lib/Format/TokenAnnotator.cpp
>     cfe/trunk/unittests/Format/FormatTestJava.cpp
>
> Modified: cfe/trunk/lib/Format/FormatToken.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=225839&r1=225838&r2=225839&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Format/FormatToken.h (original)
> +++ cfe/trunk/lib/Format/FormatToken.h Tue Jan 13 16:32:50 2015
> @@ -551,6 +551,7 @@ struct AdditionalKeywords {
>      kw_implements = &IdentTable.get("implements");
>      kw_instanceof = &IdentTable.get("instanceof");
>      kw_interface = &IdentTable.get("interface");
> +    kw_native = &IdentTable.get("native");
>      kw_package = &IdentTable.get("package");
>      kw_synchronized = &IdentTable.get("synchronized");
>      kw_throws = &IdentTable.get("throws");
> @@ -581,6 +582,7 @@ struct AdditionalKeywords {
>    IdentifierInfo *kw_implements;
>    IdentifierInfo *kw_instanceof;
>    IdentifierInfo *kw_interface;
> +  IdentifierInfo *kw_native;
>    IdentifierInfo *kw_package;
>    IdentifierInfo *kw_synchronized;
>    IdentifierInfo *kw_throws;
>
> Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=225839&r1=225838&r2=225839&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jan 13 16:32:50 2015
> @@ -1749,7 +1749,8 @@ bool TokenAnnotator::spaceRequiredBefore
>        return Style.SpaceBeforeParens != FormatStyle::SBPO_Never;
>      if ((Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private,
>                        tok::kw_protected) ||
> -         Left.isOneOf(Keywords.kw_final, Keywords.kw_abstract)) &&
> +         Left.isOneOf(Keywords.kw_final, Keywords.kw_abstract,
> +                      Keywords.kw_native)) &&
>          Right.is(TT_TemplateOpener))
>        return true;
>    }
>
> Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=225839&r1=225838&r2=225839&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Jan 13 16:32:50 2015
> @@ -292,6 +292,7 @@ TEST_F(FormatTestJava, Generics) {
>    verifyFormat("protected <R> ArrayList<R> get() {}");
>    verifyFormat("private <R> ArrayList<R> get() {}");
>    verifyFormat("public static <R> ArrayList<R> get() {}");
> +  verifyFormat("public static native <R> ArrayList<R> get();");
>    verifyFormat("public final <X> Foo foo() {}");
>    verifyFormat("public abstract <X> Foo foo();");
>    verifyFormat("<T extends B> T getInstance(Class<T> type);");
>
>
> _______________________________________________
> 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/20150114/e9eccdb6/attachment.html>


More information about the cfe-commits mailing list