summaryrefslogtreecommitdiff
path: root/unittests/Format/SortImportsTestJS.cpp
AgeCommit message (Collapse)Author
2017-08-01clang-format: [JS] support default imports.Martin Probst
Summary: Formerly, `import {default as X} from y;` would not be recognized as an import. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36132 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309697 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18clang-format: [JS] Correctly format JavaScript imports with long module pathsMartin Probst
Currently the `UnwrappedLineParser` fails to correctly unwrap JavaScript imports where the module path is not on the same line as the `from` keyword. For example: import {A} from 'some/path/longer/than/column/limit/module.js';``` This causes issues when in the middle a list of imports because the formatter thinks it has reached the end of the imports, and therefore will not sort any imports lower in the list. The formatter will, however, split the `from` keyword and the module path if the path exceeds the column limit, which triggers the issue the next time the file is formatted. Patch originally by Jared Neil - thanks! Differential Revision: https://reviews.llvm.org/D34920 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308306 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19clang-format: [JS] Fix line breaks before comments when sorting imports.Martin Probst
Summary: Previously, clang-format would always insert an additional line break after the import block if the main body started with a comment, due to loosing track of the first non-import line. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24708 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281888 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-02clang-format: [JS] handle default bindings in imports.Martin Probst
Summary: Default imports appear outside of named bindings in curly braces: import A from 'a'; import A, {symbol} from 'a'; Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23973 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-02clang-format: [JS] Sort all JavaScript imports if any changed.Martin Probst
Summary: User feedback is that they expect *all* imports to be sorted if any import was affected by a change, not just imports up to the first non-affected line, as clang-format currently does. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23972 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280485 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11Make tooling::applyAllReplacements return llvm::Expected<string> instead of ↵Eric Liu
empty string to indicate potential error. Summary: return llvm::Expected<> to carry error status and error information. This is the first step towards introducing "Error" into tooling::Replacements. Reviewers: djasper, klimek Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21601 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09clang-format: [JS] Sort imports case insensitive.Martin Probst
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274977 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09clang-format: [JS] support trailing commas in imports.Martin Probst
Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D22147 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274976 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-13clang-format: [JS] Introduce JavaScriptWrapImports option.Martin Probst
Summary: When turned on, clang-format wraps JavaScript imports (and importing exports), instead of forcing the entire import statement onto one line. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21273 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272558 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08clang-format: [JS] fix an assertion failure caused by shrinking sources.Martin Probst
Summary: The JavaScript import sorter has a corner condition that can cause the overall source text length to shrink. This change circumvents the issue by appending trailing space in the line after the import blocks to match at least the previous source code length. This needs a better long term fix, but this fixes the immediate issue. Reviewers: alexeagle, djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D21108 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272142 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01clang-format: [JS] Sort imported symbols.Martin Probst
Summary: E.g. sort `import {b, a} from 'x';` into `import {a, b} from 'x';`. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20798 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@271400 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20clang-format: [JS] sort ES6 imports.Martin Probst
Summary: This change automatically sorts ES6 imports and exports into four groups: absolute imports, parent imports, relative imports, and then exports. Exports are sorted in the same order, but not grouped further. To keep JS import sorting out of Format.cpp, this required extracting the TokenAnalyzer infrastructure to separate header and implementation files. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20198 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270203 91177308-0d34-0410-b5e6-96231b3b80d8