summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Re-enable comment re-indentation for Java/JS.Daniel Jasper2015-01-041-6/+6
| | | | | | This was broken by r224120. llvm-svn: 225130
* Don't break single-line raw string literals.Alexander Kornienko2014-12-141-20/+1
| | | | | | | | | | | | Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D6636 llvm-svn: 224223
* Don't break string literals in Java and JavaScript.Alexander Kornienko2014-12-121-0/+6
| | | | | | | | The proper way to break string literals in these languages is by inserting a "+" between parts which we don't support yet. So we disable string literal breaking until then. llvm-svn: 224120
* clang-format: Revamp nested block formatting.Daniel Jasper2014-12-121-74/+30
| | | | | | | | | | | | | | | | | | | | | | This fixed llvm.org/PR21804 and hopefully a few other strange cases. Before: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } After: if (blah_blah(whatever, whatever, [] { doo_dah(); doo_dah(); })) { } } llvm-svn: 224112
* clang-format: Remove a few else after return statements.Daniel Jasper2014-12-101-19/+12
| | | | | | | They are against the LLVM coding conventions. No functional changes intended. llvm-svn: 223930
* clang-format: Indent correctly in conditional expressions after return.Daniel Jasper2014-12-081-1/+2
| | | | | | | | | | | | | | | | | | | This only applies when not aligning after the return itself (which is commonly done for C++. Before: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) // This is indented relative to aaaaaaaaaa. : b; After: return aaaaaaaaaa ? bbbbbbbbbb( bbbbbb) : b; llvm-svn: 223694
* clang-format: [Java] Always break after annotations of multiline decls.Daniel Jasper2014-12-081-3/+6
| | | | | | | | | | | | | Before: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; After: @Mock DataLoader loooooooooooooooooooooooader = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; llvm-svn: 223688
* clang-format: Add option to suppress operator alignment.Daniel Jasper2014-12-021-4/+8
| | | | | | | | | | | | | | | | With alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; Without alignment: int aaaaaa = aa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb * cccccccccccccccccccccccccccccccc; This fixes llvm.org/PR21666. llvm-svn: 223117
* clang-format: precedence-based indentation when breaking before operators.Daniel Jasper2014-12-021-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; After: bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > ccccccccccccccccccccccccccccccccccccccccc; Not particularly pretty, but can probably help to uncover bugs. And if this bugs somebody, parentheses can help. llvm-svn: 223111
* clang-format: Refactoring.Daniel Jasper2014-11-251-99/+83
| | | | | | Re-apply r222638 and r222641 without variadic templates. llvm-svn: 222747
* Reverting r222638; it broke the MSVC build bots because Visual Studio 2012 ↵Aaron Ballman2014-11-241-83/+99
| | | | | | does not support variadic templates. Also reverting r222641 because it was relying on 222638. llvm-svn: 222656
* clang-format: Refactoring.Daniel Jasper2014-11-231-99/+83
| | | | | | | Provide more overloads to simplify testing the type of a token. No functional changes intended. llvm-svn: 222638
* clang-format: [JS] Support Closure's module statements.Daniel Jasper2014-11-231-2/+3
| | | | | | | These are like import statements and should not be line-wrapped. Minor restructuring of the handling of other import statements. llvm-svn: 222637
* clang-format: Use nested block special case for all languages.Daniel Jasper2014-11-211-23/+20
| | | | | | | | | | | | | | | | | | | Previously this was only used for JavaScript. Before: functionCall({ int i; int j; }, aaaa, bbbb, cccc); After: functionCall({ int i; int j; }, aaaa, bbbb, cccc); llvm-svn: 222531
* clang-format: [Java] Don't align after "return".Daniel Jasper2014-11-201-1/+2
| | | | | | | | | | | | | | | | | | Doesn't seem to be common practice in Java. Before: return aaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbb && ccccccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaa && bbbbbbbbbbbbbbbbbbb && ccccccccccccccccccc; Patch by Harry Terkelsen. llvm-svn: 222424
* clang-format: Add option to disable alignment after opening bracketsDaniel Jasper2014-11-181-5/+8
| | | | | | | | | | | | | | Before: SomeFunction(parameter, parameter); After: SomeFunction(parameter, parameter); Patch by Harry Terkelsen, thank you! llvm-svn: 222284
* clang-format: Improve function parameter packing.Daniel Jasper2014-11-141-1/+2
| | | | | | | | | | | | | | | Before: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); After: void SomeLoooooooooooongFunction( std::unique_ptr<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); llvm-svn: 221989
* clang-format: Improve indentation of comments in expressions.Daniel Jasper2014-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | Before: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; After: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; llvm-svn: 221985
* Revert "clang-format: [js] Updates to Google's JavaScript style."Daniel Jasper2014-11-051-1/+0
| | | | | | | | This reverts commit eefd2eaad43c5c2b17953ae7ed1e72b28e696f7b. Apparently, this change was a bit premature. llvm-svn: 221365
* clang-format: Use identifier table for keywords in other languages.Daniel Jasper2014-11-041-5/+6
| | | | | | | | | Slightly easier to write, more efficient and prevents bugs by misspelling them. No functional changes intended. llvm-svn: 221259
* clang-format: [Java] Fix class declaration formatting.Daniel Jasper2014-11-031-1/+3
| | | | | | | | | | | | | | | | Before: @SomeAnnotation() abstract class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb implements cccccccccccc { } After: @SomeAnnotation() abstract class aaaaaaaaaaaa extends bbbbbbbbbbbbbbb implements cccccccccccc { } llvm-svn: 221121
* clang-format: [Java] Don't break after extends/implements.Daniel Jasper2014-11-021-0/+7
| | | | | | | | | | | | Before: abstract class SomeClass extends SomeOtherClass implements SomeInterface {} After: abstract class SomeClass extends SomeOtherClass implements SomeInterface {} llvm-svn: 221103
* clang-format: [Java] Improve line breaks around annotations.Daniel Jasper2014-10-311-3/+6
| | | | | | | | | | | | | | | | | Before: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} After: @SomeAnnotation("With some really looooooooooooooong text") private static final long something = 0L; void SomeFunction(@Nullable String something) {} llvm-svn: 220984
* clang-format: [js] Updates to Google's JavaScript style.Daniel Jasper2014-10-311-0/+1
| | | | | | The style guide is changing.. llvm-svn: 220977
* clang-format: [ObjC] Add separate flag to control indentation in blocksDaniel Jasper2014-10-281-2/+2
| | | | | | | | | | Apparently, people are very much divided on what the "correct" indentation is. So, best to give them a choice. The new flag is called ObjCBlockIndentWidth and the default is now set to the same value as IndentWidth for the pre-defined styles. llvm-svn: 220784
* clang-format: Don't break after very short return types.Daniel Jasper2014-10-271-0/+6
| | | | | | | | | | | | | | Before: void SomeFunction(int parameter); After: void SomeFunction( int parameter); (Unless AlwaysBreakAfterDefinitionReturnType after type is set). llvm-svn: 220686
* clang-format: [Proto] Change formatting text-formatted options.Daniel Jasper2014-10-271-2/+1
| | | | | | | | | | | | | | Before: optional Type type = 1 [(mutate_options) = {vital : true abc : false}]; After: optional Type type = 1 [(mutate_options) = { vital : true abc : false }]; llvm-svn: 220679
* clang-format: [Java] Wrap after each function annotation.Daniel Jasper2014-10-211-1/+3
| | | | | | | | | | | Before: @Override public String toString() { .. } After: @Override public String toString() { .. } llvm-svn: 220274
* clang-format: Add option to control call argument bin-packing separatelyDaniel Jasper2014-10-091-5/+7
| | | | | | | This is desirable for the Chromium style guide: http://www.chromium.org/developers/coding-style llvm-svn: 219400
* clang-format: Fix bug with comments between non-trival parameters.Daniel Jasper2014-10-071-3/+4
| | | | | | | | | | | | | | Before: SomeFunction(a, a, // comment b + x); After: SomeFunction(a, a, // comment b + x); llvm-svn: 219209
* clang-format: [JS] Improve formatting of function literals in chainsDaniel Jasper2014-09-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before: getSomeLongPromise(.....) .then( function(value) { body(); body(); }) .thenCatch(function(error) { body(); body(); }); After: getSomeLongPromise(.....) .then(function(value) { body(); body(); }) .thenCatch(function(error) { body(); body(); }); llvm-svn: 218595
* clang-format: Undo r216377.Daniel Jasper2014-09-191-4/+3
| | | | | | It has proven to not be a food idea in many case. llvm-svn: 218107
* clang-format: Improve line breaks at function calls.Daniel Jasper2014-09-121-0/+12
| | | | | | | | | | | | | Before: EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly( Return(SomeValue)); After: EXPECT_CALL(SomeObject, SomeFunction(Parameter)) .Times(2) .WillRepeatedly(Return(SomeValue)); llvm-svn: 217687
* clang-format: [JS] Format embedded function literals more efficently.Daniel Jasper2014-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; After: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; llvm-svn: 217238
* clang-format: Improve formatting of nested builder-type calls.Daniel Jasper2014-08-251-3/+4
| | | | | | | | | | | | Before: f(FirstToken->WhitespaceRange.getBegin().getLocWithOffset( First->LastNewlineOffset)); After: f(FirstToken->WhitespaceRange.getBegin() .getLocWithOffset(First->LastNewlineOffset)); llvm-svn: 216377
* clang-format: Fix indentation in multi-line placement new.Daniel Jasper2014-08-061-0/+3
| | | | | | | | | | | | | | Before: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214964
* clang-format: [proto] Improve formatting of text-proto options.Daniel Jasper2014-07-281-1/+2
| | | | | | Initial patch and tests by Kaushik Sridharan, thank you! llvm-svn: 214084
* clang-format: Improve heuristic around avoiding bad line breaks.Daniel Jasper2014-07-151-1/+2
| | | | | | | | | | | Now, this can be properly formatted: static_cast<A< // B> *>( // ); Before, clang-format could end up, not formatting the code at all. llvm-svn: 213055
* clang-format: Add new option to indent wrapped function declarations.Daniel Jasper2014-07-091-2/+3
| | | | | | | | | Though not completely identical, make former IndentFunctionDeclarationAfterType change this flag for backwards compatibility (it is somewhat close in meaning and better the err'ing on an unknown config flag). llvm-svn: 212597
* clang-format: Revamp function declaration/definition indentation.Daniel Jasper2014-07-091-8/+7
| | | | | | | | | | | | | | Key changes: - Correctly (well ...) distinguish function declarations and variable declarations with ()-initialization. - Don't indent when breaking function declarations/definitions after the return type. - Indent variable declarations and typedefs when breaking after the type. This fixes llvm.org/PR17999. llvm-svn: 212591
* clang-format: [JS] Treat dict literals similar to objc method exprs.Daniel Jasper2014-06-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } } After: return { link: function() { f(); // } }; return { a: a, link: function() { f(); // } }; llvm-svn: 210537
* clang-format: Fix enum formatting with specific comment.Daniel Jasper2014-06-101-1/+3
| | | | | | | | | | | | | | | Before: enum Fruit { // APPLE, PEAR }; After: enum Fruit { // APPLE, PEAR }; llvm-svn: 210522
* clang-format: Handle multiline strings inside ternary expressions.Daniel Jasper2014-06-101-1/+2
| | | | | | | With AlwaysSplitBeforeMultilineStrings, clang-format would not find any valid solution. llvm-svn: 210513
* clang-format: Leave empty lines within UnwrappedLines.Daniel Jasper2014-06-041-4/+2
| | | | | | | | These are commonly used to structure things like enums or long braced lists. There doesn't seem to be a good reason to have the behavior in such structures be different from the behavior between statements. llvm-svn: 210183
* clang-format: Refactor indentation behavior for multiple nested blocks.Daniel Jasper2014-06-031-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a few oddities when formatting multiple nested JavaScript blocks, e.g.: Before: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); After: promise.then( function success() { doFoo(); doBar(); }, [], function error() { doFoo(); doBaz(); }); promise.then([], function success() { doFoo(); doBar(); }, function error() { doFoo(); doBaz(); }); llvm-svn: 210097
* clang-format: Format array and dict literals similar to blocks.Daniel Jasper2014-05-281-45/+59
| | | | | | | | | | | | | | | | | | | | | | | Especially, reduce the amount of indentation if it doesn't increase readability. Before: NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithDictionary:@{ aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb : bbbbb, cccccccccccccccc : ccccccccccccccc }]; After: NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithDictionary:@{ aaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbb : bbbbb, cccccccccccccccc : ccccccccccccccc }]; llvm-svn: 209720
* clang-format: Split up moveStateToNextToken.Daniel Jasper2014-05-261-120/+151
| | | | | | No functional changes intended. llvm-svn: 209626
* clang-format: Fix corner case working around one-per-line dict literals.Daniel Jasper2014-05-211-2/+4
| | | | | | | | | | | | | | | Before: var object_literal_with_long_name = { a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb' }; After: var object_literal_with_long_name = { a: 'aaaaaaaaaaaaaaaaaa', b: 'bbbbbbbbbbbbbbbbbb' }; llvm-svn: 209296
* clang-format: [JS] Support different function literal style.Daniel Jasper2014-05-211-2/+33
| | | | | | | | | | | | | | | | | Before: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); After: goog.array.forEach(array, function() { doSomething(); doSomething(); }, this); llvm-svn: 209291
* clang-format: Don't force line breaks in ObjC calls with ColumnLimit 0.Daniel Jasper2014-05-191-1/+1
| | | | | | | | | | | Before: [self.x a:b c:d]; Got reformatted toi (with ColumnLimit set to 0): [self.x a:b c:d]; llvm-svn: 209114
OpenPOWER on IntegriCloud