Skip to content

Commit 61a6636

Browse files
authored
Re-introduce constructor tear-off support and fix analyzer constraint. (#1059)
Fix #1051.
1 parent 7660eaa commit 61a6636

9 files changed

+93
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.2.0
2+
3+
* Fix analyzer dependency constraint (#1051).
4+
15
# 2.1.1
26

37
* Republish 2.0.3 as 2.1.1 in order to avoid users getting 2.1.0, which has a

lib/src/cli/formatter_options.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'show.dart';
1313
import 'summary.dart';
1414

1515
// Note: The following line of code is modified by tool/grind.dart.
16-
const dartStyleVersion = '2.1.1';
16+
const dartStyleVersion = '2.2.0';
1717

1818
/// Global options that affect how the formatter produces and uses its outputs.
1919
class FormatterOptions {

lib/src/dart_formatter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class DartFormatter {
8989
var featureSet = FeatureSet.fromEnableFlags2(
9090
sdkLanguageVersion: Version(2, 13, 0),
9191
flags: [
92+
'constructor-tearoffs',
9293
'generic-metadata',
9394
'nonfunction-type-aliases',
9495
'triple-shift'

lib/src/source_visitor.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,12 @@ class SourceVisitor extends ThrowingAstVisitor {
18051805
builder.endSpan();
18061806
}
18071807

1808+
@override
1809+
void visitFunctionReference(FunctionReference node) {
1810+
visit(node.function);
1811+
visit(node.typeArguments);
1812+
}
1813+
18081814
@override
18091815
void visitFunctionTypeAlias(FunctionTypeAlias node) {
18101816
visitMetadata(node.metadata);

pubspec.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ packages:
77
name: _fe_analyzer_shared
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "22.0.0"
10+
version: "26.0.0"
1111
analyzer:
1212
dependency: "direct main"
1313
description:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.7.2"
17+
version: "2.3.0"
1818
args:
1919
dependency: "direct main"
2020
description:
2121
name: args
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "2.1.1"
24+
version: "2.3.0"
2525
async:
2626
dependency: transitive
2727
description:
2828
name: async
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "2.7.0"
31+
version: "2.8.2"
3232
boolean_selector:
3333
dependency: transitive
3434
description:
@@ -91,7 +91,7 @@ packages:
9191
name: frontend_server_client
9292
url: "https://pub.dartlang.org"
9393
source: hosted
94-
version: "2.1.0"
94+
version: "2.1.2"
9595
glob:
9696
dependency: transitive
9797
description:
@@ -140,14 +140,14 @@ packages:
140140
name: logging
141141
url: "https://pub.dartlang.org"
142142
source: hosted
143-
version: "1.0.1"
143+
version: "1.0.2"
144144
matcher:
145145
dependency: transitive
146146
description:
147147
name: matcher
148148
url: "https://pub.dartlang.org"
149149
source: hosted
150-
version: "0.12.10"
150+
version: "0.12.11"
151151
meta:
152152
dependency: transitive
153153
description:
@@ -175,7 +175,7 @@ packages:
175175
name: package_config
176176
url: "https://pub.dartlang.org"
177177
source: hosted
178-
version: "2.0.0"
178+
version: "2.0.2"
179179
path:
180180
dependency: "direct main"
181181
description:
@@ -203,7 +203,7 @@ packages:
203203
name: pub_semver
204204
url: "https://pub.dartlang.org"
205205
source: hosted
206-
version: "2.0.0"
206+
version: "2.1.0"
207207
shelf:
208208
dependency: transitive
209209
description:
@@ -287,21 +287,21 @@ packages:
287287
name: test
288288
url: "https://pub.dartlang.org"
289289
source: hosted
290-
version: "1.17.9"
290+
version: "1.17.12"
291291
test_api:
292292
dependency: transitive
293293
description:
294294
name: test_api
295295
url: "https://pub.dartlang.org"
296296
source: hosted
297-
version: "0.4.1"
297+
version: "0.4.3"
298298
test_core:
299299
dependency: transitive
300300
description:
301301
name: test_core
302302
url: "https://pub.dartlang.org"
303303
source: hosted
304-
version: "0.3.29"
304+
version: "0.4.2"
305305
test_descriptor:
306306
dependency: "direct dev"
307307
description:
@@ -329,7 +329,7 @@ packages:
329329
name: vm_service
330330
url: "https://pub.dartlang.org"
331331
source: hosted
332-
version: "7.1.0"
332+
version: "7.3.0"
333333
watcher:
334334
dependency: transitive
335335
description:

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dart_style
22
# Note: See tool/grind.dart for how to bump the version.
3-
version: 2.1.1
3+
version: 2.2.0
44
description: >-
55
Opinionated, automatic Dart source code formatter.
66
Provides an API and a CLI tool.
@@ -10,7 +10,7 @@ environment:
1010
sdk: '>=2.12.0-0 <3.0.0'
1111

1212
dependencies:
13-
analyzer: '>=1.3.0 <3.0.0'
13+
analyzer: '>=2.0.0 <3.0.0'
1414
args: '>=1.0.0 <3.0.0'
1515
path: ^1.0.0
1616
pub_semver: '>=1.4.4 <3.0.0'

test/splitting/mixed.stmt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,12 @@ var longVariableName = identifierSoLongItWraps is SomeClassName;
222222
<<<
223223
var longVariableName =
224224
identifierSoLongItWraps
225-
is SomeClassName;
225+
is SomeClassName;
226+
>>> generic function reference nested inside expression
227+
veryLongFunction(argument, ConstructorTearOff<First, Second, Third, Fourth>, argument);
228+
<<<
229+
veryLongFunction(
230+
argument,
231+
ConstructorTearOff<First, Second,
232+
Third, Fourth>,
233+
argument);

test/splitting/type_arguments.stmt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,43 @@ new SomeClass<
9494
fifth,
9595
sixth,
9696
seventh,
97-
eighth);
97+
eighth);
98+
>>> generic instantiation all fit on one line
99+
Foo<A,B,C,D>;
100+
<<<
101+
Foo<A, B, C, D>;
102+
>>> generic instantiation split between args
103+
LongClassName<First, Second, Third, Fourth>;
104+
<<<
105+
LongClassName<First, Second, Third,
106+
Fourth>;
107+
>>> generic instantiation split before first if needed
108+
LongClassName<FirstTypeArgumentIsTooLong, Second>;
109+
<<<
110+
LongClassName<
111+
FirstTypeArgumentIsTooLong, Second>;
112+
>>> generic instantiation split in middle if fit in two lines
113+
LongClassName<First, Second, Third, Fourth, Fifth, Sixth, Seventh>;
114+
<<<
115+
LongClassName<First, Second, Third,
116+
Fourth, Fifth, Sixth, Seventh>;
117+
>>> generic instantiation split one per line if they don't fit in two lines
118+
LongClassName<First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>;
119+
<<<
120+
LongClassName<
121+
First,
122+
Second,
123+
Third,
124+
Fourth,
125+
Fifth,
126+
Sixth,
127+
Seventh,
128+
Eighth>;
129+
>>> generic instantiation indent nested type arguments
130+
LongClassName<First, Inner<Second, Third, Fourth, Fifth, Sixth, Seventh>, Eighth>;
131+
<<<
132+
LongClassName<
133+
First,
134+
Inner<Second, Third, Fourth, Fifth,
135+
Sixth, Seventh>,
136+
Eighth>;

test/whitespace/expressions.stmt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,20 @@ obj?[foo];
170170
>>> generic function expression
171171
var generic = < T,S >(){};
172172
<<<
173-
var generic = <T, S>() {};
173+
var generic = <T, S>() {};
174+
>>> generic method instantiation
175+
void main() => id < int > ;
176+
<<<
177+
void main() => id<int>;
178+
>>> generic method instantiation
179+
void main() => id < int , String , bool > ;
180+
<<<
181+
void main() => id<int, String, bool>;
182+
>>> generic constructor tear-off
183+
var x = Class < int >;
184+
<<<
185+
var x = Class<int>;
186+
>>> generic name constructor tear-off
187+
var x = Class < int > . named;
188+
<<<
189+
var x = Class<int>.named;

0 commit comments

Comments
 (0)