| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
llvm-svn: 239903
|
|
|
|
|
|
|
|
|
|
|
| |
This makes this consistent with non-typescript enums.
Also shuffle the language-dependent stuff in mustBreakBefore to a
single location.
Patch initiated by Martin Probst.
llvm-svn: 239894
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Patch by Martin Probst.
Before:
enum {
A,
B
} var x = 1;
After:
enum {
A,
B
}
var x = 1;
llvm-svn: 239893
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
var someVariable = SomeFuntion(aaaa, [
aaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccc
],
aaaa);
After:
var someVariable = SomeFuntion(aaaa,
[
aaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccc
],
aaaa);
llvm-svn: 239722
|
|
|
|
|
|
|
|
|
|
| |
Before, these would not properly detected because of the char/string
literal found when re-lexing after the first `:
var x = `'`; // comment with matching quote '
var x = `"`; // comment with matching quote "
llvm-svn: 239693
|
|
|
|
| |
llvm-svn: 239595
|
|
|
|
|
|
|
|
| |
by triggering automatic semicolon insertion changes.
NFC intended. Patch by Martin Probst.
llvm-svn: 239594
|
|
|
|
|
|
|
|
|
|
| |
Without it, it would do:
interface I {
x: string;
} var y;
llvm-svn: 239593
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
statement.
When an exported function would follow a class declaration, it would not
be recognized as a stand-alone function. That would then collapse the
following line with the current one, e.g.
class C {}
export function f() {} var x;
llvm-svn: 239592
|
|
|
|
|
|
|
|
|
|
| |
In the long run, these two might be independent or we might to only
allow specific combinations. Until we have a corresponding request,
however, it is hard to do the right thing and choose the right
configuration options. Thus, just don't touch the options yet and
just modify the behavior slightly.
llvm-svn: 239531
|
|
|
|
|
|
| |
And fix formatting issue discovered by that :-).
llvm-svn: 239530
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
assignments as enums.
Top level object literals are treated as enums, and their k/v pairs are put on
separate lines:
X.Y = {
A: 1,
B: 2
};
However assignments within blocks should not be affected:
function x() {
y = {a:1, b:2};
}
This change fixes the second case. Patch by Martin Probst.
llvm-svn: 239462
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a more correct representation than using "Equality" introduced
in r238942 which was a quick fix to solve an actual regression.
According to the typescript spec, arrows behave like "low-precedence"
assignments.
Before:
var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) &&
aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));
After:
var a = a.aaaaaaa((a: a) => aaaaaaaaaaaaaaaaaaaaa(bbbbbbbbb) &&
aaaaaaaaaaaaaaaaaaaaa(bbbbbbb));
llvm-svn: 239137
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a regression in literal formatting:
Before:
aaaaaaaaaaaaa = {
aaaaaaaaaaaaaaaaaaaaaaaaaaaa: (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
};
After:
var aaaaaaaaaaaaaaaaaaaa = {
aaaaaaaaaaaaaaaaaaaaaaaaaaaa:
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) =>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
};
Also apply no-else-after-return policy.
llvm-svn: 238942
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
var aaaaa: List<SomeThing> = [
new SomeThingAAAAAAAAAAAA(),
new SomeThingBBBBBBBBB()
];
After:
var aaaaa: List<SomeThing> =
[new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()];
llvm-svn: 238909
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, this couldn't be formatted at all:
class X {
subs = {
'b': {
'c': 1,
},
};
}
llvm-svn: 238907
|
|
|
|
|
|
|
|
|
|
| |
Before:
return () =>[];
After:
return () => [];
llvm-svn: 238875
|
|
|
|
| |
llvm-svn: 238873
|
|
|
|
| |
llvm-svn: 238845
|
|
|
|
| |
llvm-svn: 238841
|
|
|
|
| |
llvm-svn: 238839
|
|
|
|
| |
llvm-svn: 238835
|
|
|
|
| |
llvm-svn: 238832
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
someFunction(() =>
{
doSomething(); // break
})
.doSomethingElse( // break
);
After:
someFunction(() => {
doSomething(); // break
})
.doSomethingElse( // break
);
This is still bad, but at least it is consistent with what we do for other
function literals. Added corresponding tests.
llvm-svn: 238736
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
let foo = {
[someLongKeyHere]: 1,
someOtherLongKeyHere: 2, [keyLongEnoughToWrap]: 3,
lastLongKey: 4
};
After:
let foo = {
[someLongKeyHere]: 1,
someOtherLongKeyHere: 2,
[keyLongEnoughToWrap]: 3,
lastLongKey: 4
};
llvm-svn: 238671
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
var x = {
[a]: 1,
b: 2
};
After:
var x = {
[a]: 1,
b: 2
};
llvm-svn: 238544
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
method expressions and array literals. They should not bind stronger
than regular parentheses or the braces of braced lists.
Specific test case in JavaScript:
Before:
var aaaaa: List<
SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()];
After:
var aaaaa: List<SomeThing> = [
new SomeThingAAAAAAAAAAAA(),
new SomeThingBBBBBBBBB()
];
llvm-svn: 238400
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A definintion like this could not be formatted at all:
constructor({aa}: {
aa?: string,
aaaaaaaa?: string,
aaaaaaaaaaaaaaa?: boolean,
aaaaaa?: List<string>
}) {
}
llvm-svn: 238291
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Specifically, don't add a space before it.
Before:
someFunction(... a);
var x = [1, 2, ... a];
After:
someFunction(...a);
var x = [1, 2, ...a];
llvm-svn: 238183
|
|
|
|
|
|
|
|
|
|
|
|
| |
Assigns a token type (TT_JsFatArrow) to => tokens, and uses that to
more easily recognize and format fat arrow functions.
Improves function parsing to better recognize formal parameter
lists and return type declarations.
Recognizes arrow functions and parse function bodies as child blocks.
Patch by Martin Probst.
llvm-svn: 237895
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
export function foo() {} export function bar() {}
After:
export function foo() {
}
export function bar() {
}
llvm-svn: 236978
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
someLooooooooongFunction(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {
// code
});
After:
someLooooooooongFunction(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {
// code
});
llvm-svn: 236813
|
|
|
|
|
|
|
|
|
|
| |
Before:
var regex = /= / ;
After:
var regex = /=/;
llvm-svn: 236811
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Optional methods use ? tokens like this:
interface X { y?(): z; }
It seems easiest to detect and disambiguate these from ternary
expressions by checking if the code is in a declaration context. Turns
out that that didn't quite work properly for interfaces in Java and JS,
and for JS file root contexts.
Patch by Martin Probst, thank you.
llvm-svn: 236488
|
|
|
|
|
|
| |
Patch by Martin Probst.
llvm-svn: 236485
|
|
|
|
|
|
|
|
|
|
| |
OriginalColumn might not be set, so fall back to Location and SourceMgr
in case it is missing. Also initialize end column in case the token is
multi line, but it's the ` token itself that starts the multi line.
Patch by Martin Probst, thank you!
llvm-svn: 236383
|
|
|
|
|
|
|
|
|
|
| |
Parameters can have templated types and default values (= ...), which is
another location in which a template closer should be followed by
whitespace.
Patch by Martin Probst, thank you.
llvm-svn: 236382
|
|
|
|
|
|
| |
Patch by Martin Probst. Thank you.
llvm-svn: 235078
|
|
|
|
|
|
| |
Patch by Martin Probst.
llvm-svn: 234754
|
|
|
|
|
|
| |
Patch by Martin Probst. Thank you.
llvm-svn: 234753
|
|
|
|
|
|
| |
Patch by Martin Probst. Thank you.
llvm-svn: 234752
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
functionA(functionB({
int i;
int j;
}),
aaaa, bbbb, cccc);
After:
functionA(functionB({
int i;
int j;
}),
aaaa, bbbb, cccc);
llvm-svn: 234304
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
let theObject = {someMethodName() {
doTheThing();
doTheOtherThing();
},
someOtherMethodName() {
doSomething();
doSomethingElse();
}};
After:
let theObject = {
someMethodName() {
doTheThing();
doTheOtherThing();
},
someOtherMethodName() {
doSomething();
doSomethingElse();
}
};
llvm-svn: 234091
|
|
|
|
| |
llvm-svn: 233698
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before:
goog.scope(function() {
// test
var x = 0;
// test
});
After:
goog.scope(function() {
// test
var x = 0;
// test
});
llvm-svn: 233530
|
|
|
|
|
|
|
|
|
| |
Casts in TS syntax (foo = <type>bar;) should not be followed by
whitespace.
Patch by Martin Probst. Thank you.
llvm-svn: 232321
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current enum detection is overly aggressive. As NestingLevel only
applies per line (?) it classifies many if not most object literals as
enum declarations and adds superfluous line breaks into them. This
change narrows the heuristic by requiring an assignment just before the
open brace and requiring the line to start with an identifier.
Patch by Martin Probst. Thank you.
llvm-svn: 232320
|
|
|
|
|
|
|
|
|
| |
Merge template strings (marked by backticks ``).
Do not format any contents of template strings.
Patch by Martin Probst. Thank you.
llvm-svn: 230011
|
|
|
|
|
|
| |
Patch by Martin Probst, thank you!
llvm-svn: 229865
|
|
|
|
|
|
| |
Patch by Martin Probst.
llvm-svn: 229863
|