E.g. sort import {b, a} from 'x'; into import {a, b} from 'x';.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
In general, this is lacking test cases for imports that are wrapped over multiple lines to start with. Should probably add those both for the old and for the new behavior.
lib/Format/Format.cpp | ||
---|---|---|
1229 ↗ | (On Diff #59001) | I think it's not even worth storing this variable now. |
lib/Format/SortJavaScriptImports.cpp | ||
46 ↗ | (On Diff #59001) | Maybe add a comment on why you are ignoring 'Range' for comparison. |
168 ↗ | (On Diff #59001) | nit: no braces |
232 ↗ | (On Diff #59001) | I think it's safe to pass the symbols as const reference here. |
Comment Actions
Done regarding the tests. We do have an unrelated issue with formatting import {x as foo}, will send a fix later.
Comment Actions
Done regarding the tests. We do have an unrelated issue with formatting import {x as foo}, will send a fix later.
lib/Format/SortJavaScriptImports.cpp | ||
---|---|---|
248 ↗ | (On Diff #59070) | It's an implementation detail that the iterator of a SmallVector is a JsImportedSymbol*. Use auto. Also, I find this more readable: for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) { if (I != Symbols.begin()) Buffer += ","; Buffer += getSourceText(I->Range); } |