summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: clang-format (NFC)Daniel Jasper2015-06-171-6/+3
| | | | llvm-svn: 239903
* clang-format: [JS] Don't put top-level typescript enums on a single line.Daniel Jasper2015-06-171-0/+8
| | | | | | | | | | | 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
* clang-format: [JS] Fix typescript enum formatting.Daniel Jasper2015-06-171-0/+8
| | | | | | | | | | | | | | | | | | | Patch by Martin Probst. Before: enum { A, B } var x = 1; After: enum { A, B } var x = 1; llvm-svn: 239893
* clang-format: [JS] Tweak behavior for multiline array initializer parametersDaniel Jasper2015-06-151-0/+7
| | | | | | | | | | | | | | | | | | | | | Before: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); After: var someVariable = SomeFuntion(aaaa, [ aaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbb, ccccccccccccccccccccccccccc ], aaaa); llvm-svn: 239722
* clang-format: [JS] Fix corner case in template string parsing.Daniel Jasper2015-06-141-0/+5
| | | | | | | | | | 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
* clang-format: [JS] Support "export enum" declarations.Daniel Jasper2015-06-121-0/+5
| | | | llvm-svn: 239595
* clang-format: [JS] Add tests to ensure clang-format doesn't break codeDaniel Jasper2015-06-121-0/+12
| | | | | | | | by triggering automatic semicolon insertion changes. NFC intended. Patch by Martin Probst. llvm-svn: 239594
* clang-format: [JS] Fix regression caused by r239592.Daniel Jasper2015-06-121-1/+2
| | | | | | | | | | Without it, it would do: interface I { x: string; } var y; llvm-svn: 239593
* clang-format: [JS] fix incorrectly collapsed lines after exportDaniel Jasper2015-06-121-0/+3
| | | | | | | | | | | | | 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
* clang-format: Make SFS_Inline imply SFS_Empty.Daniel Jasper2015-06-111-11/+8
| | | | | | | | | | 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
* clang-format: [JS] Ensure that formatting actually takes place in tests.Daniel Jasper2015-06-111-1/+4
| | | | | | And fix formatting issue discovered by that :-). llvm-svn: 239530
* clang-format: [JS] Only special case top level object literalDaniel Jasper2015-06-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Let fat arrows have 'Assignment' precedence.Daniel Jasper2015-06-051-1/+8
| | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Let fat arrows have 'Equality' precedence.Daniel Jasper2015-06-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] More aggressively keep array literals on one line.Daniel Jasper2015-06-031-4/+3
| | | | | | | | | | | | | | Before: var aaaaa: List<SomeThing> = [ new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB() ]; After: var aaaaa: List<SomeThing> = [new SomeThingAAAAAAAAAAAA(), new SomeThingBBBBBBBBB()]; llvm-svn: 238909
* clang-format: [JS] Fix bug in type colon detection.Daniel Jasper2015-06-031-0/+9
| | | | | | | | | | | | | Before, this couldn't be formatted at all: class X { subs = { 'b': { 'c': 1, }, }; } llvm-svn: 238907
* clang-format: [JS] Always add space after fat arrow.Daniel Jasper2015-06-021-0/+1
| | | | | | | | | | Before: return () =>[]; After: return () => []; llvm-svn: 238875
* clang-format: [JS] Array literal detection fix #4.Daniel Jasper2015-06-021-0/+5
| | | | llvm-svn: 238873
* clang-format: Don't try to detect C++ lambdas in other languages.Daniel Jasper2015-06-021-0/+2
| | | | llvm-svn: 238845
* clang-format: [JS] Fix incorrect line length calculation.Daniel Jasper2015-06-021-1/+2
| | | | llvm-svn: 238841
* clang-format: [JS] Array literal detection fix #3.Daniel Jasper2015-06-021-0/+3
| | | | llvm-svn: 238839
* clang-format: [JS] Fix another regression when detecting array literals.Daniel Jasper2015-06-021-0/+5
| | | | llvm-svn: 238835
* clang-format: [JS] Fix regression of detecting array literals.Daniel Jasper2015-06-021-0/+5
| | | | llvm-svn: 238832
* clang-format: [JS] Making arrow function wrapping more consistent.Daniel Jasper2015-06-011-1/+16
| | | | | | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Fix line breaks in computed property names.Daniel Jasper2015-05-311-0/+3
| | | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Support ES6 computed property names.Daniel Jasper2015-05-291-0/+5
| | | | | | | | | | | | | | | | Before: var x = { [a]: 1, b: 2 }; After: var x = { [a]: 1, b: 2 }; llvm-svn: 238544
* clang-format: Lower binding strengths created by the [] created by ObjCDaniel Jasper2015-05-281-0/+7
| | | | | | | | | | | | | | | | | | 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
* clang-format: [JS] Fix incorrect detection of ternary expressions.Daniel Jasper2015-05-271-0/+7
| | | | | | | | | | | | | A definintion like this could not be formatted at all: constructor({aa}: { aa?: string, aaaaaaaa?: string, aaaaaaaaaaaaaaa?: boolean, aaaaaa?: List<string> }) { } llvm-svn: 238291
* clang-format: [JS] Support ES6 spread operator.Daniel Jasper2015-05-261-0/+4
| | | | | | | | | | | | | | 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
* clang-format: [JS] Better support for fat arrows.Manuel Klimek2015-05-211-1/+24
| | | | | | | | | | | | 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
* clang-format: [JS] Parse exported functions as free-standing.Daniel Jasper2015-05-111-0/+6
| | | | | | | | | | | | | Before: export function foo() {} export function bar() {} After: export function foo() { } export function bar() { } llvm-svn: 236978
* clang-format: [JS] Avoid bad line-warp around "function".Daniel Jasper2015-05-081-0/+6
| | | | | | | | | | | | | | | | | | | | Before: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function( aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); After: someLooooooooongFunction( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa) { // code }); llvm-svn: 236813
* clang-format: [JS] Fix regex literal detection.Daniel Jasper2015-05-081-0/+1
| | | | | | | | | | Before: var regex = /= / ; After: var regex = /=/; llvm-svn: 236811
* clang-format: [JS] support optional methods.Daniel Jasper2015-05-051-0/+4
| | | | | | | | | | | | | | | 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
* clang-format: [JS] Do not collapse short interfaces.Daniel Jasper2015-05-051-0/+6
| | | | | | Patch by Martin Probst. llvm-svn: 236485
* clang-format: [JS] Fix calculation of template string width.Daniel Jasper2015-05-021-0/+6
| | | | | | | | | | 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
* clang-format: [JS] Fix templated parameter default values.Daniel Jasper2015-05-021-0/+2
| | | | | | | | | | 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
* clang-format: [JS] handle comments in template strings.Daniel Jasper2015-04-161-0/+27
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 235078
* clang-format: [JS] Support index signature types.Daniel Jasper2015-04-131-0/+4
| | | | | | Patch by Martin Probst. llvm-svn: 234754
* clang-format: [JS] support optionality markers in JS types.Daniel Jasper2015-04-131-0/+8
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234753
* clang-format: [JS] Allow periods and commata in class declarations.Daniel Jasper2015-04-131-0/+1
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 234752
* clang-format: Improve nested block formatting.Daniel Jasper2015-04-071-4/+3
| | | | | | | | | | | | | | | | | | Before: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); After: functionA(functionB({ int i; int j; }), aaaa, bbbb, cccc); llvm-svn: 234304
* clang-format: [JS] Understand object literals with only methods.Daniel Jasper2015-04-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Before: let theObject = {someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); }}; After: let theObject = { someMethodName() { doTheThing(); doTheOtherThing(); }, someOtherMethodName() { doSomething(); doSomethingElse(); } }; llvm-svn: 234091
* clang-format: [JS] Support getters, setters and methods in object literals.Daniel Jasper2015-03-311-0/+21
| | | | llvm-svn: 233698
* clang-format: [JS] Fix comment formatting in goog.scopes.Daniel Jasper2015-03-301-0/+5
| | | | | | | | | | | | | | | | | | Before: goog.scope(function() { // test var x = 0; // test }); After: goog.scope(function() { // test var x = 0; // test }); llvm-svn: 233530
* clang-format: [JS] support cast syntax and type arguments.Daniel Jasper2015-03-151-0/+12
| | | | | | | | | Casts in TS syntax (foo = <type>bar;) should not be followed by whitespace. Patch by Martin Probst. Thank you. llvm-svn: 232321
* clang-format: [JS] more precisely detect enums.Daniel Jasper2015-03-151-5/+8
| | | | | | | | | | | | 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
* clang-format: [js] Support template strings.Daniel Jasper2015-02-201-0/+41
| | | | | | | | | Merge template strings (marked by backticks ``). Do not format any contents of template strings. Patch by Martin Probst. Thank you. llvm-svn: 230011
* clang-format: [js] Support ES6 module exports.Daniel Jasper2015-02-191-1/+22
| | | | | | Patch by Martin Probst, thank you! llvm-svn: 229865
* clang-format: [js] Support ES6 module imports.Daniel Jasper2015-02-191-0/+26
| | | | | | Patch by Martin Probst. llvm-svn: 229863
OpenPOWER on IntegriCloud