Skip to content

Re-introduce constructor tear-off support and fix analyzer constraint. #1059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/formatter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'show.dart';
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 {
Expand Down
1 change: 1 addition & 0 deletions lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class DartFormatter {
var featureSet = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version(2, 13, 0),
flags: [
'constructor-tearoffs',
'generic-metadata',
'nonfunction-type-aliases',
'triple-shift'
Expand Down
6 changes: 6 additions & 0 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,12 @@ class SourceVisitor extends ThrowingAstVisitor {
builder.endSpan();
}

@override
void visitFunctionReference(FunctionReference node) {
visit(node.function);
visit(node.typeArguments);
}

@override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
visitMetadata(node.metadata);
Expand Down
26 changes: 13 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ packages:
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:
Expand Down Expand Up @@ -91,7 +91,7 @@ packages:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -140,14 +140,14 @@ packages:
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:
Expand Down Expand Up @@ -175,7 +175,7 @@ packages:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
path:
dependency: "direct main"
description:
Expand Down Expand Up @@ -203,7 +203,7 @@ packages:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -287,21 +287,21 @@ packages:
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:
Expand Down Expand Up @@ -329,7 +329,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
version: "7.3.0"
watcher:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -10,7 +10,7 @@ environment:
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'
Expand Down
10 changes: 9 additions & 1 deletion test/splitting/mixed.stmt
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,12 @@ var longVariableName = identifierSoLongItWraps is SomeClassName;
<<<
var longVariableName =
identifierSoLongItWraps
is SomeClassName;
is SomeClassName;
>>> generic function reference nested inside expression
veryLongFunction(argument, ConstructorTearOff<First, Second, Third, Fourth>, argument);
<<<
veryLongFunction(
argument,
ConstructorTearOff<First, Second,
Third, Fourth>,
argument);
41 changes: 40 additions & 1 deletion test/splitting/type_arguments.stmt
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,43 @@ new SomeClass<
fifth,
sixth,
seventh,
eighth);
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>;
18 changes: 17 additions & 1 deletion test/whitespace/expressions.stmt
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,20 @@ obj?[foo];
>>> generic function expression
var generic = < T,S >(){};
<<<
var generic = <T, S>() {};
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;