clang-format: [JS] Sort imports case insensitive.

Summary: ASCII case sorting does not help finding imported symbols quickly, and it is common to have e.g. class Foo and function fooFactory exported/imported from the same file.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D22146

llvm-svn: 274977
This commit is contained in:
Martin Probst
2016-07-09 15:11:18 +00:00
parent a8c9d154b8
commit 2a19454a86
2 changed files with 24 additions and 3 deletions

View File

@@ -105,8 +105,8 @@ bool operator<(const JsModuleReference &LHS, const JsModuleReference &RHS) {
// Empty URLs sort *last* (for export {...};).
if (LHS.URL.empty() != RHS.URL.empty())
return LHS.URL.empty() < RHS.URL.empty();
if (LHS.URL != RHS.URL)
return LHS.URL < RHS.URL;
if (int Res = LHS.URL.compare_lower(RHS.URL))
return Res < 0;
// '*' imports (with prefix) sort before {a, b, ...} imports.
if (LHS.Prefix.empty() != RHS.Prefix.empty())
return LHS.Prefix.empty() < RHS.Prefix.empty();
@@ -245,7 +245,7 @@ private:
std::stable_sort(
Symbols.begin(), Symbols.end(),
[&](const JsImportedSymbol &LHS, const JsImportedSymbol &RHS) {
return LHS.Symbol < RHS.Symbol;
return LHS.Symbol.compare_lower(RHS.Symbol) < 0;
});
if (Symbols == Reference.Symbols) {
// No change in symbol order.