Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dart-lang/dart_style
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.3
Choose a base ref
...
head repository: dart-lang/dart_style
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.1.0
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Jul 27, 2021

  1. Format generic function references and constructor tear-offs. (#1047)

    * Format generic function references and constructor tear-offs.
    
    Fix #1028.
    
    * Bump the minor version.
    munificent authored Jul 27, 2021
    Copy the full SHA
    b268371 View commit details

Commits on Aug 16, 2021

  1. Copy the full SHA
    14d9b6f View commit details
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.1.0

* Support generic function references and constructor tear-offs (#1028).

# 2.0.3

* Fix hang when reading from stdin (https://github.com/dart-lang/sdk/issues/46600).
2 changes: 1 addition & 1 deletion lib/src/cli/formatter_options.dart
Original file line number Diff line number Diff line change
@@ -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.0.3';
const dartStyleVersion = '2.1.0';

/// Global options that affect how the formatter produces and uses its outputs.
class FormatterOptions {
1 change: 1 addition & 0 deletions lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 6 additions & 0 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion 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.0.3
version: 2.1.0
description: >-
Opinionated, automatic Dart source code formatter.
Provides an API and a CLI tool.
10 changes: 9 additions & 1 deletion test/splitting/mixed.stmt
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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;