[PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 03:09:27 PDT 2016


djasper added inline comments.

================
Comment at: lib/Format/TokenAnnotator.cpp:760
@@ +759,3 @@
+      if (CurrentToken->is(tok::kw_export)) {
+        // Find the 'from' part of export {...} from '...';
+        // The difference here is that "export {...};" should not be treated as
----------------
Can you actually have:

  export {a as from};

?

================
Comment at: lib/Format/TokenAnnotator.cpp:763
@@ +762,3 @@
+        // an export.
+        while (CurrentToken) {
+          if (CurrentToken->is(tok::semi))
----------------
Not a big fan of the code duplication in this loop. How about doing:

  if (Style.Language == FormatStyle::LK_JavaScript &&
      ((Line.First->is(tok::kw_export) && CurrentToken->is(Keywords.kw_from)) ||
       isClosureImportStatement(*CurrentToken)))
    return LT_ImportStatement;

in the lower loop? The ImportStatement variable can likely go away then.


http://reviews.llvm.org/D17440





More information about the cfe-commits mailing list