[PATCH] D20198: clang-format: [JS] sort ES6 imports.
Manuel Klimek via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 07:56:05 PDT 2016
klimek added a comment.
We're getting there. Couple of nits left.
================
Comment at: lib/Format/SortJavaScriptImports.cpp:94-97
@@ +93,6 @@
+ // Side effect imports might be ordering sensitive. Consider them equal so
+ // that they maintain their relative order in the stable sort below.
+ // This retains transitivity because LHS.Category == RHS.Category here.
+ return false;
+ // Empty URLs sort *last* (for export {...};).
+ if (LHS.URL.empty() != RHS.URL.empty())
----------------
Yea, completely missed that the != above.
================
Comment at: lib/Format/SortJavaScriptImports.cpp:128
@@ +127,3 @@
+ SmallVector<JsModuleReference, 16> References;
+ parseModuleReferences(Keywords, AnnotatedLines, References);
+
----------------
Return by value.
================
Comment at: lib/Format/SortJavaScriptImports.cpp:216-217
@@ +215,4 @@
+ break;
+ Current = Line->First;
+ LineEnd = Line->Last;
+ skipComments();
----------------
Both of these are used only once, perhaps inline?
================
Comment at: lib/Format/SortJavaScriptImports.cpp:229
@@ +228,3 @@
+ Reference.Range.setBegin(Start);
+ Start = SourceLocation();
+ if (!parseModuleReference(Keywords, Reference))
----------------
I'd put that down after References.push_back so calculating the Reference is at least a single flow.
http://reviews.llvm.org/D20198
More information about the cfe-commits
mailing list