[PATCH] D32532: clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

Martin Probst via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 05:49:45 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL301399: clang-format: [JS/Java] ignore Objective-C constructs in JS & Java. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32532?vs=96710&id=96720#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32532

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1120,7 +1120,11 @@
                 Current.Type = TT_FunctionAnnotationRParen;
           }
         }
-    } else if (Current.is(tok::at) && Current.Next) {
+    } else if (Current.is(tok::at) && Current.Next &&
+               Style.Language != FormatStyle::LK_JavaScript &&
+               Style.Language != FormatStyle::LK_Java) {
+      // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+      // marks declarations and properties that need special formatting.
       switch (Current.Next->Tok.getObjCKeywordID()) {
       case tok::objc_interface:
       case tok::objc_implementation:
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1239,6 +1239,9 @@
                "}");
   verifyFormat("class X {}\n"
                "class Y {}");
+  verifyFormat("class X {\n"
+               "  @property() private isReply = false;\n"
+               "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32532.96720.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170426/445cbb4d/attachment.bin>


More information about the cfe-commits mailing list