| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
| |
See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10
llvm-svn: 286467
|
|
|
|
|
|
|
|
|
|
| |
Before:
var i = x!-1;
After:
var i = x! - 1;
llvm-svn: 286367
|
|
|
|
|
|
|
|
|
|
| |
Before:
aaaaa.as ();
After:
aaaaa.as();
llvm-svn: 285672
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
var x = {
a: function*
() {
//
}
}
After:
var x = {
a: function*() {
//
}
}
llvm-svn: 285670
|
|
|
|
|
|
|
|
|
|
| |
Before:
x.for () = 1;
After:
x.for() = 1;
llvm-svn: 285669
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
class X {
delete(val) {
return null;
}
* gen() {
yield[1, 2];
}
* gen() {
yield{a: 1};
}
};
After:
class X {
delete(val) {
return null;
}
* gen() {
yield [1, 2];
}
* gen() {
yield {a: 1};
}
};
llvm-svn: 285569
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Previously, automatic semicolon insertion would add an unwrapped line
when a template string contained a line break.
var x = `foo${
bar}`;
Would be formatted with `bar...` on a separate line and no indent.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D25675
llvm-svn: 284807
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Before:
class X {
delete () {
...
}
}
After:
class X {
delete() {
...
}
}
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D24804
llvm-svn: 282138
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
`// taze: ... from ...` comments are used help tools where a
specific global symbol comes from.
Before:
// taze: many, different, symbols from
// 'some_long_location_here'
After:
// taze: many, different, symbols from 'some_long_location_here'
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24477
llvm-svn: 281857
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Before when a semicolon was missing after a boolean literal:
a = true
return 1;
clang-format would parse this as one line and format as:
a = true return 1;
It turns out that C++ does not consider `true` and `false` to be literals, we
have to check for that explicitly.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24574
llvm-svn: 281856
|
|
|
|
| |
llvm-svn: 281816
|
|
|
|
|
|
| |
for Google style to "empty".
llvm-svn: 280878
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The attempt to fix requoting behavior in r280487 after changes to
tooling::Replacements are incomplete. We essentially need to add to
replacements at the same position, one to insert a line break and one to
change the quoting and that's incompatible with the new
tooling::Replacement API, which does not allow for order-dependent
Replacements. To make the order clear, Replacements::merge() has to be
used, but that requires the merged Replacement to actually refer to the
changed text, which is hard to reproduce for the requoting.
This change fixes the behavior by moving the requoting to a completely
separate pass. The added benefit is that no weird ColumnWidth
calculations are necessary anymore and this should just work even if we
implement string literal splitting in the future.
llvm-svn: 280874
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Before:
x!as string
After:
x! as string
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24272
llvm-svn: 280731
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
When code contains a comment between `return` and the value:
return /* lengthy comment here */ (
lengthyValueComesHere);
Do not wrap before the comment, as that'd break the code through JS' automatic
semicolon insertion.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24257
llvm-svn: 280730
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
When formatting source code that needs both requoting and reindentation,
merge the replacements to avoid erroring out for conflicting replacements.
Also removes the misleading Replacements parameter from the
TokenAnalyzer API.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D24155
llvm-svn: 280487
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
JavaScript template strings can be nested arbitrarily:
foo = `text ${es.map(e => { return `<${e}>`; })} text`;
This change lexes nested template strings using a stack of lexer states to
correctly switch back to template string lexing on closing braces.
Also, reuse the same stack for the token-stashed logic.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D22431
llvm-svn: 279727
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
x as{x: number}
After:
x as {x: number}
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D23761
llvm-svn: 279436
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: E.g. `{a: 1} as b`.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D23714
llvm-svn: 279250
|
|
|
|
|
|
|
|
| |
I am not sure exactly which test breakage Martin was trying to fix in
r273694. For now, fix the behavior for top-level conditionals, which
(surprisingly) are actually used somewhat commonly.
llvm-svn: 275183
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
llvm-svn: 275062
|
|
|
|
|
|
| |
Checking Line.MustBeDeclaration does actually break the field and param initializer use case.
llvm-svn: 273694
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21658
llvm-svn: 273619
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Includes parenthesized type expressions and type aliases.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21597
llvm-svn: 273603
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
'as' is a pseudo operator, so automatic semicolon insertion kicks in and the
code fails to part.
Reviewers: djasper
Subscribers: klimek
Differential Revision: http://reviews.llvm.org/D21576
llvm-svn: 273422
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, this could be formatted at all (with BracketAlignmentStyle
AlwaysBreak):
foo = <Bar[]>[
1, /* */
2
];
llvm-svn: 272668
|
|
|
|
| |
llvm-svn: 272654
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: There's no convention of avoiding the nested indentation.
Reviewers: djasper
Subscribers: klimek, alexeagle, cfe-commits
Differential Revision: http://reviews.llvm.org/D21275
llvm-svn: 272559
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
llvm-svn: 272558
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Do not insert whitespace preceding the "!" postfix operator. This is an
incomplete fix, but should cover common usage.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D21204
llvm-svn: 272524
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: This also fixes union type formatting in function parameter types.
Before: function x(path: number| string) {}
After: function x(path: number|string) {}
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21206
llvm-svn: 272330
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: ASI did not handle the ES6 `as` operator correctly.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20817
llvm-svn: 271401
|
|
|
|
| |
llvm-svn: 271191
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Shebang lines (`#!/bin/blah`) can be used in JavaScript scripts to indicate
they should be run using e.g. node. This change treats # lines on the first line
as line comments.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20632
llvm-svn: 271185
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Only treat the sequence `async function` as the start of a function expression,
as opposed to every occurrence of the token `async` (whoops).
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20737
llvm-svn: 271184
|
|
|
|
|
|
|
|
| |
Otherwise, clang-format can get confused with statements like:
x.for = 1;
llvm-svn: 270188
|
|
|
|
|
|
|
|
|
|
| |
Before:
const[a, b, c] = [1, 2, 3];
After:
const [a, b, c] = [1, 2, 3];
llvm-svn: 270029
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Simply looking at the final text greatly simplifies the algorithm and also
fixes a reported issue. This requires duplicating the "actual encoding width"
logic, but that seems cleaner than the column acrobatics before.
Reviewers: djasper, bkramer
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D20208
llvm-svn: 269747
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20200
llvm-svn: 269282
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For generators, see:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators
async functions are not quite in the spec yet, but stage 3 and already widely used:
http://tc39.github.io/ecmascript-asyncawait/
Reviewers: djasper
Subscribers: klimek
Differential Revision: http://reviews.llvm.org/D19204
llvm-svn: 267368
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
`interface` can be used as a fee standing identifier in JavaScript/TypeScript.
This change uses the heuristic of whether it's followed by another identifier
as an indication.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D19240
llvm-svn: 266789
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
clang-format: [JS] unit tests for type aliases.
Also adds a test for "foo as bar" casts.
Spec:
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.10
These are already handled correctly.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D19206
llvm-svn: 266744
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Change `import` and `export` parsing to special case the renaming
syntax (`import x, {y as bar} ...`, `export {x}`) and otherwise just
parse a regular structural element.
This simplifies the code a bit and should be more correct - it's easier
to recognise the specific import syntax than to recognise arbitrary
expressions and declarations.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D19242
llvm-svn: 266743
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Just to ensure no regressions, this already works fine.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D18950
llvm-svn: 265922
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: djasper
Subscribers: klimek
Differential Revision: http://reviews.llvm.org/D18943
llvm-svn: 265916
|
|
|
|
|
|
|
|
|
| |
"import ... from '...';" and "export ... from '...';" should be treated
the same as goog.require/provide/module/forwardDeclare calls.
Patch by Martin Probst.
llvm-svn: 264055
|
|
|
|
|
|
|
|
|
| |
The operators | and & in types, as opposed to the bitwise operators,
should not have whitespace around them (e.g. `Foo<Bar|Baz>`).
Patch by Martin Probst. Thank you.
llvm-svn: 263961
|
|
|
|
|
|
|
|
|
|
| |
Before:
x.of ();
After:
x.of();
llvm-svn: 263710
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Automatic Semicolon Insertion can only be properly handled by parsing
source code. However conservatively catching just a few, common
situations prevents breaking code during development, which greatly
improves usability.
JS code should still use semicolons, and ASI code should be flagged by
a compiler or linter.
Patch by Martin Probst. Thank you.
llvm-svn: 263470
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
for (let { a, b } of x) {
}
After:
for (let {a, b} of x) {
}
llvm-svn: 262776
|