OLD | NEW |
(Empty) | |
| 1 40 columns | |
| 2 >>> split all chained calls if they don't fit on one line |
| 3 compiler.something().something().something(); |
| 4 <<< |
| 5 compiler |
| 6 .something() |
| 7 .something() |
| 8 .something(); |
| 9 >>> do not split chained calls if not needed |
| 10 compiler.something().something().some(); |
| 11 <<< |
| 12 compiler.something().something().some(); |
| 13 >>> don't split before implicit receiver |
| 14 return |
| 15 call({'type': type, 'id': id}) |
| 16 .then(deserializeAsset); |
| 17 <<< |
| 18 return call({'type': type, 'id': id}) |
| 19 .then(deserializeAsset); |
| 20 >>> allows chained calls on one line with multi-line last argument list |
| 21 compiler |
| 22 .run(script) |
| 23 .then((_) { |
| 24 body; |
| 25 }); |
| 26 <<< |
| 27 compiler.run(script).then((_) { |
| 28 body; |
| 29 }); |
| 30 >>> allow inline chains before and after a hard newline |
| 31 compiler.a().b((_) { |
| 32 body; |
| 33 }).c().d(); |
| 34 <<< |
| 35 compiler.a().b((_) { |
| 36 body; |
| 37 }).c().d(); |
| 38 >>> allow an inline chain before a hard newline but not after |
| 39 compiler.a().b((_) { |
| 40 body; |
| 41 }).somethingLong().somethingLong().somethingLong(); |
| 42 <<< |
| 43 compiler.a().b((_) { |
| 44 body; |
| 45 }) |
| 46 .somethingLong() |
| 47 .somethingLong() |
| 48 .somethingLong(); |
| 49 >>> allow an inline chain after a hard newline but not before |
| 50 compiler.somethingLong().somethingLong().somethingLong((_) { |
| 51 body; |
| 52 }).a().b(); |
| 53 <<< |
| 54 compiler |
| 55 .somethingLong() |
| 56 .somethingLong() |
| 57 .somethingLong((_) { |
| 58 body; |
| 59 }).a().b(); |
| 60 >>> nest calls one more than target |
| 61 someVeryLongExpression = someVeryLongExpression.someLongMethod(); |
| 62 <<< |
| 63 someVeryLongExpression = |
| 64 someVeryLongExpression |
| 65 .someLongMethod(); |
| 66 >>> split properties after a method chain |
| 67 compiler.method().method().method().property.property; |
| 68 <<< |
| 69 compiler |
| 70 .method() |
| 71 .method() |
| 72 .method() |
| 73 .property |
| 74 .property; |
| 75 >>> split properties in a method chain |
| 76 compiler.method().property.method().property.method(); |
| 77 <<< |
| 78 compiler |
| 79 .method() |
| 80 .property |
| 81 .method() |
| 82 .property |
| 83 .method(); |
| 84 >>> do not split leading properties in a chain |
| 85 compiler.property.property.method().method().method(); |
| 86 <<< |
| 87 compiler.property.property |
| 88 .method() |
| 89 .method() |
| 90 .method(); |
| 91 >>> do not split leading properties even if others splits |
| 92 compiler.property.method().property.method(); |
| 93 <<< |
| 94 compiler.property |
| 95 .method() |
| 96 .property |
| 97 .method(); |
| 98 >>> split between a pair of properties |
| 99 avian.bovine.canine.equine.feline.piscine.orycteropodian.camelid; |
| 100 <<< |
| 101 avian.bovine.canine.equine.feline |
| 102 .piscine.orycteropodian.camelid; |
| 103 >>> split before all properties if they don't fit on two lines |
| 104 avian.bovine.canine.equine.feline.piscine.orycteropodian.camelid |
| 105 .rangiferine; |
| 106 <<< |
| 107 avian |
| 108 .bovine |
| 109 .canine |
| 110 .equine |
| 111 .feline |
| 112 .piscine |
| 113 .orycteropodian |
| 114 .camelid |
| 115 .rangiferine; |
| 116 >>> unsplit cascade unsplit method |
| 117 object.method().method()..c()..c(); |
| 118 <<< |
| 119 object.method().method()..c()..c(); |
| 120 >>> split cascade unsplit method |
| 121 object.method().method()..cascade()..cascade(); |
| 122 <<< |
| 123 object.method().method() |
| 124 ..cascade() |
| 125 ..cascade(); |
| 126 >>> unsplit cascade split method |
| 127 object.method().method().method().method()..cascade()..cascade(); |
| 128 <<< |
| 129 object |
| 130 .method() |
| 131 .method() |
| 132 .method() |
| 133 .method()..cascade()..cascade(); |
| 134 >>> split cascade split method |
| 135 object.method().method().method().method()..cascade()..cascade()..cascade(); |
| 136 <<< |
| 137 object |
| 138 .method() |
| 139 .method() |
| 140 .method() |
| 141 .method() |
| 142 ..cascade() |
| 143 ..cascade() |
| 144 ..cascade(); |
| 145 >>> cascade setters on method chain |
| 146 object.method().method().method().method()..x=1..y=2; |
| 147 <<< |
| 148 object |
| 149 .method() |
| 150 .method() |
| 151 .method() |
| 152 .method() |
| 153 ..x = 1 |
| 154 ..y = 2; |
| 155 >>> conditional invocation |
| 156 object?.method().method()?.method().method(); |
| 157 <<< |
| 158 object |
| 159 ?.method() |
| 160 .method() |
| 161 ?.method() |
| 162 .method(); |
OLD | NEW |