Re-introduce constructor tear-off support and fix analyzer constraint. (#1059)
Fix #1051.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2cbe5ac..aa9918c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 2.2.0
+
+* Fix analyzer dependency constraint (#1051).
+
# 2.1.1
* Republish 2.0.3 as 2.1.1 in order to avoid users getting 2.1.0, which has a
diff --git a/lib/src/cli/formatter_options.dart b/lib/src/cli/formatter_options.dart
index 2f7072e..8d7b120 100644
--- a/lib/src/cli/formatter_options.dart
+++ b/lib/src/cli/formatter_options.dart
@@ -13,7 +13,7 @@
import 'summary.dart';
// Note: The following line of code is modified by tool/grind.dart.
-const dartStyleVersion = '2.1.1';
+const dartStyleVersion = '2.2.0';
/// Global options that affect how the formatter produces and uses its outputs.
class FormatterOptions {
diff --git a/lib/src/dart_formatter.dart b/lib/src/dart_formatter.dart
index 7f437a9..2510ace 100644
--- a/lib/src/dart_formatter.dart
+++ b/lib/src/dart_formatter.dart
@@ -89,6 +89,7 @@
var featureSet = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version(2, 13, 0),
flags: [
+ 'constructor-tearoffs',
'generic-metadata',
'nonfunction-type-aliases',
'triple-shift'
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index d08f18f..4a53ae6 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1806,6 +1806,12 @@
}
@override
+ void visitFunctionReference(FunctionReference node) {
+ visit(node.function);
+ visit(node.typeArguments);
+ }
+
+ @override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
visitMetadata(node.metadata);
diff --git a/pubspec.lock b/pubspec.lock
index e01e1cc..62aa5bd 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,28 +7,28 @@
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
- version: "22.0.0"
+ version: "26.0.0"
analyzer:
dependency: "direct main"
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
- version: "1.7.2"
+ version: "2.3.0"
args:
dependency: "direct main"
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.1"
+ version: "2.3.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.7.0"
+ version: "2.8.2"
boolean_selector:
dependency: transitive
description:
@@ -91,7 +91,7 @@
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0"
+ version: "2.1.2"
glob:
dependency: transitive
description:
@@ -140,14 +140,14 @@
name: logging
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "1.0.2"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.10"
+ version: "0.12.11"
meta:
dependency: transitive
description:
@@ -175,7 +175,7 @@
name: package_config
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.0.2"
path:
dependency: "direct main"
description:
@@ -203,7 +203,7 @@
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
shelf:
dependency: transitive
description:
@@ -287,21 +287,21 @@
name: test
url: "https://pub.dartlang.org"
source: hosted
- version: "1.17.9"
+ version: "1.17.12"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.4.1"
+ version: "0.4.3"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
- version: "0.3.29"
+ version: "0.4.2"
test_descriptor:
dependency: "direct dev"
description:
@@ -329,7 +329,7 @@
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
- version: "7.1.0"
+ version: "7.3.0"
watcher:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index d948147..d858cac 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
-version: 2.1.1
+version: 2.2.0
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
@@ -10,7 +10,7 @@
sdk: '>=2.12.0-0 <3.0.0'
dependencies:
- analyzer: '>=1.3.0 <3.0.0'
+ analyzer: '>=2.0.0 <3.0.0'
args: '>=1.0.0 <3.0.0'
path: ^1.0.0
pub_semver: '>=1.4.4 <3.0.0'
diff --git a/test/splitting/mixed.stmt b/test/splitting/mixed.stmt
index 7d8dfff..f14c4ef 100644
--- a/test/splitting/mixed.stmt
+++ b/test/splitting/mixed.stmt
@@ -222,4 +222,12 @@
<<<
var longVariableName =
identifierSoLongItWraps
- is SomeClassName;
\ No newline at end of file
+ is SomeClassName;
+>>> generic function reference nested inside expression
+veryLongFunction(argument, ConstructorTearOff<First, Second, Third, Fourth>, argument);
+<<<
+veryLongFunction(
+ argument,
+ ConstructorTearOff<First, Second,
+ Third, Fourth>,
+ argument);
\ No newline at end of file
diff --git a/test/splitting/type_arguments.stmt b/test/splitting/type_arguments.stmt
index 9675153..77a2eb3 100644
--- a/test/splitting/type_arguments.stmt
+++ b/test/splitting/type_arguments.stmt
@@ -94,4 +94,43 @@
fifth,
sixth,
seventh,
- eighth);
\ No newline at end of file
+ eighth);
+>>> generic instantiation all fit on one line
+Foo<A,B,C,D>;
+<<<
+Foo<A, B, C, D>;
+>>> generic instantiation split between args
+LongClassName<First, Second, Third, Fourth>;
+<<<
+LongClassName<First, Second, Third,
+ Fourth>;
+>>> generic instantiation split before first if needed
+LongClassName<FirstTypeArgumentIsTooLong, Second>;
+<<<
+LongClassName<
+ FirstTypeArgumentIsTooLong, Second>;
+>>> generic instantiation split in middle if fit in two lines
+LongClassName<First, Second, Third, Fourth, Fifth, Sixth, Seventh>;
+<<<
+LongClassName<First, Second, Third,
+ Fourth, Fifth, Sixth, Seventh>;
+>>> generic instantiation split one per line if they don't fit in two lines
+LongClassName<First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>;
+<<<
+LongClassName<
+ First,
+ Second,
+ Third,
+ Fourth,
+ Fifth,
+ Sixth,
+ Seventh,
+ Eighth>;
+>>> generic instantiation indent nested type arguments
+LongClassName<First, Inner<Second, Third, Fourth, Fifth, Sixth, Seventh>, Eighth>;
+<<<
+LongClassName<
+ First,
+ Inner<Second, Third, Fourth, Fifth,
+ Sixth, Seventh>,
+ Eighth>;
\ No newline at end of file
diff --git a/test/whitespace/expressions.stmt b/test/whitespace/expressions.stmt
index 1a138dc..23502ab 100644
--- a/test/whitespace/expressions.stmt
+++ b/test/whitespace/expressions.stmt
@@ -170,4 +170,20 @@
>>> generic function expression
var generic = < T,S >(){};
<<<
-var generic = <T, S>() {};
\ No newline at end of file
+var generic = <T, S>() {};
+>>> generic method instantiation
+void main() => id < int > ;
+<<<
+void main() => id<int>;
+>>> generic method instantiation
+void main() => id < int , String , bool > ;
+<<<
+void main() => id<int, String, bool>;
+>>> generic constructor tear-off
+var x = Class < int >;
+<<<
+var x = Class<int>;
+>>> generic name constructor tear-off
+var x = Class < int > . named;
+<<<
+var x = Class<int>.named;
\ No newline at end of file